forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenUtil.java
More file actions
30 lines (27 loc) · 737 Bytes
/
TokenUtil.java
File metadata and controls
30 lines (27 loc) · 737 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
package processing.mode.java.preproc;
import java.lang.reflect.Field;
import antlr.collections.AST;
import processing.mode.java.preproc.PdeTokenTypes;
/**
*
* @author Jonathan Feinberg <[email protected]>
*
*/
public class TokenUtil {
private static final String[] tokenNames= new String[200];
static {
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = "ERROR:" + i;
}
for (final Field f : PdeTokenTypes.class.getDeclaredFields()) {
try {
tokenNames[f.getInt(null)] = f.getName();
} catch (Exception unexpected) {
throw new RuntimeException(unexpected);
}
}
}
public static String nameOf(final AST node) {
return tokenNames[node.getType()];
}
}