-
Notifications
You must be signed in to change notification settings - Fork 0
/
VBase.java
142 lines (108 loc) · 2.38 KB
/
VBase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package ece351.vhdl;
import org.parboiled.Rule;
import org.parboiled.annotations.MemoMismatches;
import ece351.util.BaseParser351;
abstract class VBase extends BaseParser351 implements VConstants {
Rule Char() {
return FirstOf(CharRange('a', 'z'), CharRange('A', 'Z'));
}
Rule Digit() {
return CharRange('0', '9');
}
// *************************************Keyword
// Rules******************************************
// You can use these rules to match keywords in the VHDL grammar rules.
// Theses rules account
// for VHDL's case-insensitivity and enforce whitespaces following the
// keywords more carefully
// than just using the rule, WhiteSpace, or adding a space at the end of
// each keyword literal
// Boolean Operators
public Rule SingleKeyword(String keyword) {
return Sequence(IgnoreCase(keyword),
TestNot(FirstOf(Char(), Digit(), "_")));
}
Rule NOT() {
return SingleKeyword(NOT);
}
Rule AND() {
return SingleKeyword(AND);
}
Rule OR() {
return SingleKeyword(OR);
}
Rule XOR() {
return SingleKeyword(XOR);
}
Rule NAND() {
return SingleKeyword(NAND);
}
Rule NOR() {
return SingleKeyword(NOR);
}
Rule XNOR() {
return SingleKeyword(XNOR);
}
// Constructs
Rule IF() {
return SingleKeyword("if");
}
Rule THEN() {
return SingleKeyword("then");
}
Rule ELSE() {
return SingleKeyword("else");
}
Rule ENDIF() {
return Sequence(END(), W0(), IF());
}
Rule PROCESS() {
return SingleKeyword("process");
}
Rule ENDPROCESS() {
return Sequence(END(), W0(), PROCESS());
}
Rule ENTITY() {
return SingleKeyword("entity");
}
Rule PORT() {
return SingleKeyword("port");
}
Rule MAP() {
return SingleKeyword("map");
}
Rule ARCHITECTURE() {
return SingleKeyword("architecture");
}
Rule OF() {
return SingleKeyword("of");
}
Rule IS() {
return SingleKeyword("is");
}
Rule BEGIN() {
return SingleKeyword("begin");
}
Rule END() {
return SingleKeyword("end");
}
Rule SIGNAL() {
return SingleKeyword("signal");
}
Rule BIT() {
return SingleKeyword("bit");
}
Rule IN() {
return SingleKeyword("in");
}
Rule OUT() {
return SingleKeyword("out");
}
@MemoMismatches
Rule Keyword() {
return FirstOf(NOT(), AND(), OR(), XOR(), NAND(), NOR(), XNOR(), IF(),
THEN(), ELSE(), PROCESS(), ENTITY(), PORT(), MAP(),
ARCHITECTURE(), OF(), IS(), BEGIN(), END(), SIGNAL(), BIT(),
IN(), OUT());
}
}