/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ package processing.app.preproc; import processing.app.*; /* Based on original code copyright (c) 2003 Andy Tripp . * shipped under GPL with permission. */ import antlr.*; import antlr.collections.*; import antlr.collections.impl.*; import java.io.*; import java.util.*; /** * PDEEmitter: A class that can take an ANTLR Java AST and produce * reasonably formatted Java code from it. To use it, create a * PDEEmitter object, call setOut() if you want to print to something * other than System.out, and then call print(), passing the * AST. Typically, the AST node that you pass would be the root of a * tree - the ROOT_ID node that represents a Java file. */ public class PdeEmitter implements PdeTokenTypes { private PrintStream out = System.out; private PrintStream debug = System.err; private static int ALL = -1; private java.util.Stack stack = new java.util.Stack(); private static String[] tokenNames; private final static int ROOT_ID = 0; static { setupTokenNames(); } /* private static Hashtable publicMethods; private static final String publicMethodList[] = { "setup", "draw", //"loop", "mousePressed", "mouseReleased", "mouseClicked", "mouseEntered", "mouseExited", "mouseMoved", "mouseDragged", "keyPressed", "keyReleased", "keyTyped" }; static { publicMethods = new Hashtable(); for (int i = 0; i < publicMethodList.length; i++) { publicMethods.put(publicMethodList[i], new Object()); } } */ // Map each AST token type to a String private static void setupTokenNames() { tokenNames = new String[200]; for (int i=0; i