All Downloads are FREE. Search and download functionalities are using the official Maven repository.

processing.mode.java.preproc.TokenUtil Maven / Gradle / Ivy

Go to download

Processing is a programming language, development environment, and online community. This Java Mode package contains the Java mode for Processing IDE.

There is a newer version: 3.3.7
Show newest version
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()];
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy