-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTokenType.java
More file actions
44 lines (35 loc) · 995 Bytes
/
TokenType.java
File metadata and controls
44 lines (35 loc) · 995 Bytes
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
package translator;
public enum TokenType {
// Token types cannot have underscores
WHITESPACE("\\s"),
VAR("[$]{1}[A-Za-z]{1}[A-Za-z_0-9]*"),
ASSIGN("="),
OPEN("\\("),
CLOSE("\\)"),
SEMICOLON(";"),
COMMA(","),
OPP("[+-]"),
OPM("[*/%]"),
INT("0|[1-9]{1}[0-9]*"),
FLOAT("\\d+\\.\\d+"),
TEXT("\"(\\.|[^\"])*\""),
FUNAME("[a-zA-Z]{1}\\w*"),
FOR("for"),
WHILE("while"),
IF("if"),
ELSE("else"),
OPEN2("\\{"),
CLOSE2("\\}"),
DOT("\\."),
UNEQUAL("[<>]"),
EQUAL("[=]{2}"),
INC("[+]{2}"),
DEC("[-]{2}"),
FUNCTION("function"),
ECHO("echo"),
PRINT("print");
public final String pattern;
private TokenType(String pattern) {
this.pattern = pattern;
}
}