-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExpParser.java
36 lines (35 loc) · 1.22 KB
/
ExpParser.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
class ExpParser extends StringWalker {
ExpParser(String expression) {
super(expression.replaceAll("\\s", "").toLowerCase(), getAllOpCodes());
}
static String[] getAllOpCodes() {
int setSize = LogicalExp.OPCODES.length
+ RelationExp.OPCODES.length
+ TermExp.OPCODES.length
+ FactorExp.OPCODES.length
+ PrimaryExp.OPCODES.length;
String[] opCodes = new String[setSize];
int i = 0;
int start = 0;
for (; i < start + LogicalExp.OPCODES.length; i++) {
opCodes[i] = LogicalExp.OPCODES[i - start];
}
start = i;
for (; i < start + RelationExp.OPCODES.length; i++) {
opCodes[i] = RelationExp.OPCODES[i - start];
}
start = i;
for (; i < start + TermExp.OPCODES.length; i++) {
opCodes[i] = TermExp.OPCODES[i - start];
}
start = i;
for (; i < start + FactorExp.OPCODES.length; i++) {
opCodes[i] = FactorExp.OPCODES[i - start];
}
start = i;
for (; i < start + PrimaryExp.OPCODES.length; i++) {
opCodes[i] = PrimaryExp.OPCODES[i - start];
}
return opCodes;
}
}