-
Notifications
You must be signed in to change notification settings - Fork 2
/
TokenFactory.java
55 lines (42 loc) · 1.36 KB
/
TokenFactory.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
package jua.token;
public class TokenFactory {
public static TokenOperator create(Operator op) {
return new TokenOperator(op, 0, 0);
}
public static TokenOperator create(Operator op, int line, int pos) {
return new TokenOperator(op, line, pos);
}
public static Token create(Keyword kw) {
return new TokenKeyword(kw, 0, 0);
}
public static Token create(Keyword kw, int line, int pos) {
return new TokenKeyword(kw, line, pos);
}
public static Token create(Delimiter d) {
return new TokenDelimiter(d, 0, 0);
}
public static Token create(Delimiter d, int line, int pos) {
return new TokenDelimiter(d, line, pos);
}
public static Token create(Literal l, String value) {
return new TokenLiteral(l, value, 0, 0);
}
public static Token create(Literal l, String value, int line, int pos) {
return new TokenLiteral(l, value, line, pos);
}
public static TokenIdentifier create(String identifier) {
return new TokenIdentifier(identifier, 0, 0);
}
public static Token create(String identifier, int line, int pos) {
return new TokenIdentifier(identifier, line, pos);
}
public static Token create(Special spec, int line, int pos) {
switch (spec) {
case TokenEOF:
return new TokenEOF(line, pos);
case TokenInvalid:
return new TokenInvalid(line, pos);
}
return null;
}
}