-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.java
58 lines (52 loc) · 1.39 KB
/
Token.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
56
57
/*
Alex Lapena
Token.java
*/
class Token {
public final static int ERROR = 0;
public final static int OPEN = 1;
public final static int CLOSE = 2;
public final static int WORD = 3;
public final static int NUMBER = 4;
public final static int APOSTROPHIZED = 5;
public final static int HYPHENATED = 6;
public final static int PUNCTUATIONS = 7;
public final static int DELIMETERS = 8;
public final static int ELSE = 9;
public int m_type;
public String m_value;
public int m_line;
public int m_column;
Token (int type, String value, int line, int column) {
m_type = type;
m_value = value;
m_line = line;
m_column = column;
}
public String toString() {
switch (m_type) {
case OPEN:
return "OPEN-" + m_value;
case CLOSE:
return "CLOSE-" + m_value;
case WORD:
return "WORD(" + m_value + ")";
case NUMBER:
return "NUMBER(" + m_value+ ")";
case APOSTROPHIZED:
return "APOSTROPHIZED(" + m_value+ ")";
case HYPHENATED:
return "HYPHENATED(" + m_value+ ")";
case PUNCTUATIONS:
return "PUNCTUATIONS(" + m_value+ ")";
case DELIMETERS:
return "DELIMETERS(" + m_value+ ")";
case ERROR:
return "ERROR(" + m_value + ")";
case ELSE:
return "ELSE (" + m_value + ")";
default:
return "UNKNOWN(" + m_value + ")";
}
}
}