-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIToken.java
More file actions
80 lines (67 loc) · 2.24 KB
/
IToken.java
File metadata and controls
80 lines (67 loc) · 2.24 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package edu.ufl.cise.plc;
import edu.ufl.cise.plc.IToken.Kind;
public interface IToken {
public record SourceLocation(int line, int column) {}
public static enum Kind {
IDENT,
INT_LIT,
FLOAT_LIT,
STRING_LIT,
BOOLEAN_LIT,// 'true','false'
LPAREN, // '('
RPAREN, // ')'
LSQUARE, // '['
RSQUARE, // ']'
LANGLE, // '<<'
RANGLE, // '>>'
PLUS, // '+'
MINUS, // '-'
TIMES, // '*'
DIV, // '/'
MOD, // '%'
COLOR_CONST, // 'BLACK','BLUE','CYAN','DARK_GRAY','GRAY','GREEN','LIGHT_GRAY','MAGENTA','ORANGE','PINK',
// 'RED','WHITE','YELLOW'
KW_IF, // 'if'
KW_FI, //'fi'
KW_ELSE, //'else'
KW_WRITE, // 'write'
KW_CONSOLE, // 'console'
AND, // '&'
OR, // '|'
BANG, // '!'
LT, // '<'
GT, // '>'
EQUALS, // '=='
NOT_EQUALS, // '!='
LE, // '<='
GE, // '>='
TYPE, //int, float, string, boolean, color, image
COLOR_OP, //getRed, getGreen, getBlue
IMAGE_OP, //getWidth, getHeight
SEMI, // ';'
COMMA, // ','
ASSIGN, // '='
RARROW, // '->'
LARROW, // '<-'
KW_VOID, // 'void'
RETURN,// '^'
EOF, // used as sentinal, does not correspond to input
ERROR, // use to avoid exceptions if scanning all input at once
}
//returns the token kind
public Kind getKind();
//returns the characters in the source code that correspond to this token
//if the token is a STRING_LIT, this returns the raw characters, including delimiting "s and unhandled escape sequences.
public String getText();
//returns the location in the source code of the first character of the token.
public SourceLocation getSourceLocation();
//returns the int value represented by the characters of this token if kind is INT_LIT
public int getIntValue();
//returns the float value represented by the characters of this token if kind is FLOAT_LIT
public float getFloatValue();
//returns the boolean value represented by the characters of this token if kind is BOOLEAN_LIT
public boolean getBooleanValue();
//returns the String represented by the characters of this token if kind is STRING_LIT
//The delimiters should be removed and escape sequences replaced by the characters they represent.
public String getStringValue();
}