-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.java
44 lines (36 loc) · 881 Bytes
/
Common.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
public class Common{
public enum Token {
LEFT_PARENTHESIS,
RIGHT_PARENTHESIS,
LEFT_BRACKET,
RIGHT_BRACKET,
WHILE_KEYWORD,
RETURN_KEYWORD,
EQUAL,
COMMA,
EOL,
VARTYPE,
IDENTIFIER,
BINOP,
NUMBER,
INVALID //custom added token for error checking
}
public static class Lex{
private Token token;
private String lexeme;
public Lex(Token aToken, String aLexeme){
token = aToken;
lexeme = aLexeme;
}
//NOTE: forgoing the use of setters to enforce immutability
public Token getToken() {
return token;
}
public String getLexeme(){
return lexeme;
}
public String toString(){
return token + " " + lexeme;
}
}
}