moving things back off the branch, and into full disaster mode

This commit is contained in:
benfry
2011-01-20 19:29:39 +00:00
parent 4922d95e59
commit 5ecf3fdf36
67 changed files with 6032 additions and 3645 deletions

View File

@@ -0,0 +1,30 @@
package processing.mode.java.preproc;
import java.lang.reflect.Field;
import antlr.collections.AST;
import processing.app.antlr.PdeTokenTypes;
/**
*
* @author Jonathan Feinberg <jdf@pobox.com>
*
*/
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()];
}
}