-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathToken.java
More file actions
34 lines (28 loc) · 761 Bytes
/
Copy pathToken.java
File metadata and controls
34 lines (28 loc) · 761 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
public class Token {
public final TokenType type;
public final String lexeme;
public final Object literal;
public final int line;
public Token(TokenType type, String lexeme, Object literal, int line) {
this.type = type;
this.lexeme = lexeme;
this.literal = literal;
this.line = line;
}
public TokenType getType() {
return type;
}
public String getLexeme() {
return lexeme;
}
public Object getLiteral() {
return literal;
}
public int getLine() {
return line;
}
@Override
public String toString() {
return "Token[" + type + " \"" + lexeme + "\" " + (literal == null ? "null" : literal) + " at line " + line + "]";
}
}