diff --git a/app/Compiler.java b/app/Compiler.java index 4cafd107b..566917b40 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -1,11 +1,12 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + /* - Compiler - default compiler class that connects to the external compiler + Compiler - default compiler class that connects to avr-gcc + Part of the Arduino project - http://arduino.berlios.de/ - Part of the Arduino project - http://arduino.berlios.de + Copyright (c) 2004-05 Hernando Barragan - Derived from the Processing project - http://processing.org - - Copyleft 2005 Massimo Banzi (arduino modifications) + Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology @@ -22,6 +23,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id:$ */ package processing.app; @@ -32,8 +35,10 @@ import java.util.zip.*; import javax.swing.*; public class Compiler implements MessageConsumer { - static final String BUGS_URL = "http://arduino.berlios.de"; - static final String SUPER_BADNESS = "Compiler error, please submit this code to " + BUGS_URL; + static final String BUGS_URL = + "https://developer.berlios.de/bugs/?group_id=3590"; + static final String SUPER_BADNESS = + "Compiler error, please submit this code to " + BUGS_URL; Sketch sketch; String buildPath; @@ -57,11 +62,12 @@ public class Compiler implements MessageConsumer { public boolean compile(PrintStream leechErr) { */ - public Compiler() { } // null constructor + public Compiler() { } // consider this a warning, you werkin soon. + + + public boolean compile(Sketch sketch, String buildPath, Target target) + throws RunnerException { - public boolean compile(Sketch sketch, String buildPath) - throws RunnerException { - this.sketch = sketch; this.buildPath = buildPath; @@ -69,46 +75,402 @@ public class Compiler implements MessageConsumer { MessageStream pms = new MessageStream(this); String userdir = System.getProperty("user.dir") + File.separator; - - System.out.println("Compiling Arduino program"); - Process process; - String commandLine = ""; - //TODO test this in windows - // FIXME: this is really nasty, it seems that MACOS is making the - // compilation inside the lib folder, while windows is doing it - // inside the work folder ... why why why --DojoDave - if (Base.isWindows()) { - commandLine = userdir + "tools\\gnumake.exe -C " + userdir + ". compile"; - } else if (Base.isMacOS()) { - commandLine = userdir + "tools/gnumake -C " + userdir + "lib compile"; + + String baseCommandCompiler[] = new String[] { + ((!Base.isMacOS()) ? "tools/avr/bin/avr-gcc" : + userdir + "tools/avr/bin/avr-gcc"), + "-c", // compile, don't link + "-g", // include debugging info (so errors include line numbers) + "-Os", // optimize for size + "-I" + target.getPath(), + "-w", // surpress all warnings + "-mmcu=" + Preferences.get("build.mcu"), + "-DF_CPU=" + Preferences.get("build.f_cpu"), + " ", + " " + }; + + String baseCommandCompilerCPP[] = new String[] { + ((!Base.isMacOS()) ? "tools/avr/bin/avr-g++" : + userdir + "tools/avr/bin/avr-g++"), + "-c", // compile, don't link + "-g", // include debugging info (so errors include line numbers) + "-Os", // optimize for size + "-I" + target.getPath(), + "-w", // surpress all warnings + "-fno-exceptions", + "-mmcu=" + Preferences.get("build.mcu"), + "-DF_CPU=" + Preferences.get("build.f_cpu"), + " ", + " " + }; + + String baseCommandLinker[] = new String[] { + ((!Base.isMacOS()) ? "tools/avr/bin/avr-gcc" : + userdir + "tools/avr/bin/avr-gcc"), + " ", + "-mmcu=" + Preferences.get("build.mcu"), + "-o", + " ", +// ((!Base.isMacOS()) ? "" : userdir) + "lib/uart.o", +// ((!Base.isMacOS()) ? "" : userdir) + "lib/buffer.o", +// ((!Base.isMacOS()) ? "" : userdir) + "lib/timer.o", +// ((!Base.isMacOS()) ? "" : userdir) + "lib/wiring.o", +// ((!Base.isMacOS()) ? "" : userdir) + "lib/pins_arduino.o", + //((!Base.isMacOS()) ? "lib/WApplet.o" : + //userdir + "lib/WApplet.o"), + //((!Base.isMacOS()) ? "lib/WSerial.o" : + //userdir + "lib/WSerial.o"), + //((!Base.isMacOS()) ? "lib/WTimer.o" : + //userdir + "lib/WTimer.o"), + //((!Base.isMacOS()) ? "lib/Servo.o" : + //userdir + "lib/Servo.o"), + ////((!Base.isMacOS()) ? "lib/Wire.o" : + //// userdir + "lib/Wire.o"), + ////((!Base.isMacOS()) ? "lib/WServo.o" : + //// userdir + "lib/WServo.o"), + //((!Base.isMacOS()) ? "lib/WDisplay.o" : + //userdir + "lib/WDisplay.o"), + //((!Base.isMacOS()) ? "lib/WEncoder.o" : + //userdir + "lib/WEncoder.o"), + //((!Base.isMacOS()) ? "lib/WInterrupts.o" : + //userdir + "lib/WInterrupts.o"), + //((!Base.isMacOS()) ? "lib/WCounter.o" : + //userdir + "lib/WCounter.o"), + //((!Base.isMacOS()) ? "tools/avr/avr/lib/libm.a" : + //userdir + "tools/avr/avr/lib/libm.a") + }; + + String baseCommandObjcopy[] = new String[] { + ((!Base.isMacOS()) ? "tools/avr/bin/avr-objcopy" : + userdir + "tools/avr/bin/avr-objcopy"), + "-O", + " ", + "-R", + " ", + " ", + " " + }; + + /*String baseCommand[] = new String[] { + // user.dir is folder containing P5 (and therefore jikes) + // macosx needs the extra path info. linux doesn't like it, though + // windows doesn't seem to care. write once, headache anywhere. + ((!Base.isMacOS()) ? "jikes" : + System.getProperty("user.dir") + File.separator + "jikes"), + + // this doesn't help much.. also java 1.4 seems to not support + // -source 1.1 for javac, and jikes seems to also have dropped it. + // for versions of jikes that don't complain, "final int" inside + // a function doesn't throw an error, so it could just be a + // ms jvm error that this sort of thing doesn't work. blech. + //"-source", + //"1.1", + + // necessary to make output classes compatible with 1.1 + // i.e. so that exported applets can work with ms jvm on the web + "-target", + Preferences.get("preproc.jdk_version"), //"1.1", + // let the incompatability headache begin + + // used when run without a vm ("expert" mode) + "-bootclasspath", + calcBootClassPath(), + + // needed for macosx so that the classpath is set properly + // also for windows because qtjava will most likely be here + // and for linux, it just doesn't hurt + "-classpath", + sketch.classPath, //calcClassPath(includeFolder), + + "-nowarn", // we're not currently interested in warnings + "+E", // output errors in machine-parsable format + "-d", buildPath // output the classes in the buildPath + //buildPath + File.separator + className + ".java" // file to compile + };*/ + + // make list of code files that need to be compiled and the object files + // that they will be compiled to (includes code from the sketch and the + // library for the target platform) + String sourceNames[] = new String[sketch.codeCount + target.getSourceFilenames().size()]; + String sourceNamesCPP[] = new String[sketch.codeCount + target.getSourceFilenames().size()]; + String objectNames[] = new String[sketch.codeCount + target.getSourceFilenames().size()]; + String objectNamesCPP[] = new String[sketch.codeCount + target.getSourceFilenames().size()]; + int fileCount = 0; + int fileCountCPP = 0; + for (int i = 0; i < sketch.codeCount; i++) { + if (sketch.code[i].preprocName != null) { + if (sketch.code[i].preprocName.endsWith(".c")) { + sourceNames[fileCount] = buildPath + File.separator + sketch.code[i].preprocName; + objectNames[fileCount++] = buildPath + File.separator + sketch.code[i].preprocName + ".o"; + } else if (sketch.code[i].preprocName.endsWith(".cpp")) { + sourceNamesCPP[fileCountCPP] = buildPath + File.separator + sketch.code[i].preprocName; + objectNamesCPP[fileCountCPP++] = buildPath + File.separator + sketch.code[i].preprocName + ".o"; + } + } } - int result = 0; + for (Iterator iter = target.getSourceFilenames().iterator(); iter.hasNext(); ) { + String filename = (String) iter.next(); + if (filename != null) { + if (filename.endsWith(".c")) { + sourceNames[fileCount] = target.getPath() + File.separator + filename; + objectNames[fileCount++] = buildPath + File.separator + filename + ".o"; + } else if (filename.endsWith(".cpp")) { + sourceNamesCPP[fileCountCPP] = target.getPath() + File.separator + filename; + objectNamesCPP[fileCountCPP++] = buildPath + File.separator + filename + ".o"; + } + } + } + + + /* + String commandCompiler[] = new String[baseCommandCompiler.length + preprocCount]; + System.arraycopy(baseCommandCompiler, 0, commandCompiler, 0, baseCommandCompiler.length); + // append each of the files to the command string + for (int i = 0; i < preprocCount; i++) { + commandCompiler[baseCommandCompiler.length + i] = + buildPath + File.separator + preprocNames[i]; + } + + String commandCompilerCPP[] = new String[baseCommandCompilerCPP.length + preprocCountCPP]; + System.arraycopy(baseCommandCompilerCPP, 0, commandCompilerCPP, 0, baseCommandCompilerCPP.length); + for (int i = 0; i < preprocCountCPP; i++) { + commandCompilerCPP[baseCommandCompilerCPP.length + i] = + buildPath + File.separator + preprocNamesCPP[i]; + } + */ + //PApplet.printarr(command); + + baseCommandLinker[1] = "-Os -Wl,-u,vfprintf -lprintf_flt -lm,-Map=" + + ((!Base.isMacOS()) ? buildPath : userdir + buildPath) + + File.separator + sketch.name + ".map,--cref"; + baseCommandLinker[4] = ((!Base.isMacOS()) ? buildPath + : buildPath) + File.separator + sketch.name + ".elf"; + String commandLinker[] = new String[baseCommandLinker.length + fileCount + + fileCountCPP + target.getObjectFilenames().size()]; + System.arraycopy(baseCommandLinker, 0, commandLinker, 0, baseCommandLinker.length); + int idx = 0; + for(int i = 0; i < fileCount; i++, idx++) { + commandLinker[baseCommandLinker.length + idx] = objectNames[i]; + } + for(int i = 0; i < fileCountCPP; i++, idx++) { + commandLinker[baseCommandLinker.length + idx] = objectNamesCPP[i]; + } + for(Iterator iter = target.getObjectFilenames().iterator(); iter.hasNext(); idx++) { + commandLinker[baseCommandLinker.length + idx] = target.getPath() + File.separator + iter.next(); //already ends in ".o" + } + + /*String command[] = new String[baseCommand.length + preprocCount]; + System.arraycopy(baseCommand, 0, command, 0, baseCommand.length); + // append each of the files to the command string + for (int i = 0; i < preprocCount; i++) { + command[baseCommand.length + i] = + buildPath + File.separator + preprocNames[i]; + } + //PApplet.printarr(command); + */ + /* + String command[] = new String[baseCommand.length + sketch.codeCount]; + System.arraycopy(baseCommand, 0, command, 0, baseCommand.length); + // append each of the files to the command string + for (int i = 0; i < sketch.codeCount; i++) { + command[baseCommand.length + i] = + buildPath + File.separator + sketch.code[i].preprocName; + } + */ + + //for (int i = 0; i < command.length; i++) { + //System.out.println("cmd " + i + " " + command[i]); + //} + + firstErrorFound = false; // haven't found any errors yet + secondErrorFound = false; + + int result = 0; // pre-initialized to quiet a bogus warning from jikes try { - // System.out.println(commandLine); - process = Runtime.getRuntime().exec(commandLine); - - + // execute the compiler, and create threads to deal + // with the input and error streams + // + + Process process; + boolean compiling = true; + for(int i = 0; i < fileCount; i++) { + baseCommandCompiler[8] = sourceNames[i]; + baseCommandCompiler[9] = "-o"+ objectNames[i]; + //System.arraycopy(baseCommandCompiler.length + //for(int j = 0; j < baseCommandCompiler.length; j++) { + // System.out.println(baseCommandCompiler[j]); + //} + process = Runtime.getRuntime().exec(baseCommandCompiler); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + + // wait for the process to finish. if interrupted + // before waitFor returns, continue waiting + // + compiling = true; + while (compiling) { + try { + result = process.waitFor(); + //System.out.println("result is " + result); + compiling = false; + } catch (InterruptedException ignored) { } + } + if (exception != null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + } + + for(int i = 0; i < fileCountCPP; i++) { + baseCommandCompilerCPP[9] = sourceNamesCPP[i]; + baseCommandCompilerCPP[10] = "-o"+ objectNamesCPP[i]; + //for(int j = 0; j < baseCommandCompilerCPP.length; j++) { + // System.out.println(baseCommandCompilerCPP[j]); + //} + process = Runtime.getRuntime().exec(baseCommandCompilerCPP); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + + // wait for the process to finish. if interrupted + // before waitFor returns, continue waiting + // + compiling = true; + while (compiling) { + try { + result = process.waitFor(); + //System.out.println("result is " + result); + compiling = false; + } catch (InterruptedException ignored) { } + } + if (exception != null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + } + + + //for(int j = 0; j < commandLinker.length; j++) { + // System.out.println(commandLinker[j]); + //} + process = Runtime.getRuntime().exec(commandLinker); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); + compiling = true; + while(compiling) { + try { + result = process.waitFor(); + compiling = false; + } catch (InterruptedException intExc) { } + } + if (exception != null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + + /*for(int j = 0; j < baseCommandObjcopy.length; j++) { + System.out.println(baseCommandObjcopy[j]); + }*/ + baseCommandObjcopy[2] = "srec"; + baseCommandObjcopy[4] = ".eeprom"; + baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf"; + baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".rom"; + process = Runtime.getRuntime().exec(baseCommandObjcopy); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + compiling = true; + while(compiling) { + try { + result = process.waitFor(); + compiling = false; + } catch (InterruptedException intExc) { } + } + if (exception != null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + + baseCommandObjcopy[2] = "ihex"; + baseCommandObjcopy[4] = ".flash"; + baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf"; + baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".hex"; + process = Runtime.getRuntime().exec(baseCommandObjcopy); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + compiling = true; + while(compiling) { + try { + result = process.waitFor(); + compiling = false; + } catch (InterruptedException intExc) { } + } + if (exception != null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + + /*Process process = Runtime.getRuntime().exec(command); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + + // wait for the process to finish. if interrupted + // before waitFor returns, continue waiting + // boolean compiling = true; while (compiling) { try { result = process.waitFor(); + //System.out.println("result is " + result); compiling = false; } catch (InterruptedException ignored) { } - } + }*/ + } catch (Exception e) { - e.printStackTrace(); - System.out.println("Error: GNUMake probably couldn't be found"); - result = 99; + String msg = e.getMessage(); + if ((msg != null) && (msg.indexOf("avr-gcc: not found") != -1)) { + //System.err.println("jikes is missing"); + Base.showWarning("Compiler error", + "Could not find the compiler.\n" + + "avr-gcc is missing from your PATH,\n" + + "see readme.txt for help.", null); + return false; + + } else { + e.printStackTrace(); + result = -1; + } } - if(0 == result){ - System.out.println("Arduino Compilation Successful"); - }else{ - System.out.println("Arduino Compilation Unsuccessful (error: " + result + ")"); + + // an error was queued up by message(), barf this back to build() + // which will barf it back to Editor. if you're having trouble + // discerning the imagery, consider how cows regurgitate their food + // to digest it, and the fact that they have five stomaches. + // + //System.out.println("throwing up " + exception); + if (exception != null) throw exception; + + // if the result isn't a known, expected value it means that something + // is fairly wrong, one possibility is that jikes has crashed. + // + if (result != 0 && result != 1 ) { + //exception = new RunnerException(SUPER_BADNESS); + //editor.error(exception); // this will instead be thrown + Base.openURL(BUGS_URL); + throw new RunnerException(SUPER_BADNESS); } - return (result == 0); - + + // success would mean that 'result' is set to zero + return (result == 0); // ? true : false; } @@ -120,49 +482,21 @@ public class Compiler implements MessageConsumer { * whenever a piece (usually a line) of error message is spewed * out from the compiler. The errors are parsed for their contents * and line number, which is then reported back to Editor. - * In Arduino v1 this is very very crude */ public void message(String s) { // This receives messages as full lines, so a newline needs // to be added as they're printed to the console. - //System.out.print(s); - - - //if ((s.indexOf("warning:") != -1) && (s.indexOf("prog.c:") != -1) ) { - // String[] result = s.split(":"); - // for (int x=0; x Serial menu to select"); - System.out.println("where you have connected your arduino board"); - return false; - }; - - String commandLine = ""; - - - if (debug) System.out.println("userdir is "+userdir); - - int result = -1; - - - // TODO make this code more portable using File.separator - if (Base.isMacOS()) { - commandLine = userdir + "tools/avr/bin/uisp "; - commandLine += " -dprog=stk500 -dspeed=9600 "; - commandLine += " -dserial=" + serial_port; - commandLine += " -dpart=ATmega8"; - commandLine += " if=" +userdir + "lib/tmp/prog.hex --upload"; - } else { - commandLine = userdir + "tools\\gnumake.exe" + " SERIAL=" + serial_port + verbose + " -C " + userdir + ". program"; - } - if (debug) System.out.println(commandLine); - - // Launch the command as a thread (this way we can kill it - // in the case it times out) - Command command = new Command(commandLine, true); - command.setName("theDownloader"); - command.start(); - - // TODO move this to Preferences - // Default timeout when calling a command (in seconds) - final int maxTimeOut = 30; // 10 secs - - - // Start timer to monitor buffer timeout ==> deadlock in process - int timeCount = 0; - - while ((timeCount <= maxTimeOut) && (result == -1) && command.isAlive()) { - try { - result = command.waitResult; - Thread.currentThread().sleep(1000); - } catch (InterruptedException ie) { - } - timeCount++; - } - result = command.waitResult; - - if ((result != 0) && (command.errorResult == -1)) { -// result = 94; - System.out.println("Time out error when trying to upload the program"); - System.out.println("Board not present, bootloader not installed or processor's failure"); - System.out.println("Arduino download unsuccessful (error: " + result + ")"); - } else if (result == 0) { - System.out.println(command.errorMsg); - System.out.println("OK - Arduino download successful"); - } else if ((result != 0) && (49 == command.errorResult)) { - System.out.println(command.errorMsg); - System.out.println("Bootloader not responding"); - System.out.println("Arduino download unsuccessful (error: " + result + ")"); - } else { - System.out.println(command.errorMsg); - System.out.println("Arduino download unsuccessful (error: " + result + ")"); - } - if (command.isAlive()) command.process.destroy(); - } else { - System.out.println("You have to compile the code first"); - System.out.println("Arduino download unsuccessful"); - } - - return true; - } - - - - - - -} - diff --git a/app/Editor.java b/app/Editor.java index cd6e95aea..ef0ce0e92 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -20,6 +20,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id:$ */ package processing.app; @@ -1135,58 +1137,52 @@ public class Editor extends JFrame doClose(); running = true; buttons.run(); - + message("Compiling..."); // do this for the terminal window / dos prompt / etc for (int i = 0; i < 10; i++) System.out.println(); // clear the console on each run, unless the user doesn't want to + //if (Base.getBoolean("console.auto_clear", true)) { //if (Preferences.getBoolean("console.auto_clear", true)) { if (Preferences.getBoolean("console.auto_clear")) { - console.clear(); + console.clear(); } presenting = present; - // console.message("Arduino compiling\n", false,true); - - String cfilename = System.getProperty("user.dir") + File.separator + "lib/build/arduino.c"; - //console.message(" file = " + cfilename, false,true); - try { - Writer out = new FileWriter(cfilename); - out.write(textarea.getText()); - out.flush(); - out.close(); - } - catch (IOException e) - { - error(e); - } + if (presenting && Base.isMacOS()) { + // check to see if osx 10.2, if so, show a warning + String osver = System.getProperty("os.version").substring(0, 4); + if (osver.equals("10.2")) { + Base.showWarning("Time for an OS Upgrade", + "The \"Present\" feature may not be available on\n" + + "Mac OS X 10.2, because of what appears to be\n" + + "a bug in the Java 1.4 implementation on 10.2.\n" + + "In case it works on your machine, present mode\n" + + "will start, but if you get a flickering white\n" + + "window, using Command-Q to quit the sketch", null); + } + } - Compiler compiler = new Compiler(); - String buildPath = Preferences.get("build.path"); - //console.message(" buildpath = " + buildPath, false,true); - try { - boolean success = compiler.compile(sketch, buildPath); - } catch (RunnerException e) { - error(e); - } - // FIXED: 20050902 - DojoDave - // the clear button requires a the clearRun method instead of only clear!! - buttons.clearRun(); + try { + if (!sketch.handleRun(new Target( + System.getProperty("user.dir") + File.separator + "lib" + + File.separator + "targets", Preferences.get("build.target")))) + return; + //runtime = new Runner(sketch, Editor.this); + //runtime.start(appletLocation); + watcher = new RunButtonWatcher(); + message("Done compiling."); + if(watcher != null) watcher.stop(); - //- if (!sketch.handleRun()) return; - - //- runtime = new Runner(sketch, Editor.this); - //- runtime.start(appletLocation); - //- watcher = new RunButtonWatcher(); - - //- } catch (RunnerException e) { - //- error(e); - - //- } catch (Exception e) { - //- e.printStackTrace(); - //- } + } catch (RunnerException e) { + message("Error compiling..."); + error(e); + } catch (Exception e) { + e.printStackTrace(); + } + // this doesn't seem to help much or at all /* final SwingWorker worker = new SwingWorker() { @@ -1197,10 +1193,12 @@ public class Editor extends JFrame runtime = new Runner(sketch, Editor.this); runtime.start(presenting ? presentLocation : appletLocation); watcher = new RunButtonWatcher(); + message("Done compiling."); } catch (RunnerException e) { + message("Error compiling..."); error(e); - + } catch (Exception e) { e.printStackTrace(); } @@ -1210,6 +1208,7 @@ public class Editor extends JFrame worker.start(); */ //sketch.cleanup(); // where does this go? + buttons.clear(); } @@ -1661,9 +1660,30 @@ public class Editor extends JFrame * hitting export twice, quickly, and horking things up. */ synchronized public void handleExport() { + //if(debugging) + //doStop(); + console.clear(); + //String what = sketch.isLibrary() ? "Applet" : "Library"; //message("Exporting " + what + "..."); - Downloader d = new Downloader(); - d.downloadJava(); + message("Uploading to I/O Board..."); + try { + //boolean success = sketch.isLibrary() ? + //sketch.exportLibrary() : sketch.exportApplet(); + boolean success = sketch.exportApplet(new Target( + System.getProperty("user.dir") + File.separator + "lib" + + File.separator + "targets", Preferences.get("build.target"))); + if (success) { + message("Done uploading."); + } else { + // error message will already be visible + } + } catch (RunnerException e) { + message("Error during upload."); + //e.printStackTrace(); + error(e); + } catch (Exception e) { + e.printStackTrace(); + } buttons.clear(); } diff --git a/app/Sketch.java b/app/Sketch.java index b7b46a2d3..957fcdc4e 100644 --- a/app/Sketch.java +++ b/app/Sketch.java @@ -1,7 +1,7 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - Part of the Processing project - http://processing.org + Part of the Arduino project - http://arduino.berlios.de/ Copyright (c) 2004-05 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology @@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id:$ */ package processing.app; @@ -100,10 +102,11 @@ public class Sketch { // off of the main file name if (mainFilename.endsWith(".pde")) { name = mainFilename.substring(0, mainFilename.length() - 4); - } else if (mainFilename.endsWith(".java")) { - name = mainFilename.substring(0, mainFilename.length() - 5); + } else if (mainFilename.endsWith(".c")) { + name = mainFilename.substring(0, mainFilename.length() - 2); + } else if (mainFilename.endsWith(".cpp")) { + name = mainFilename.substring(0, mainFilename.length() - 4); } - // lib/build must exist when the application is started // it is added to the CLASSPATH by default, but if it doesn't // exist when the application is started, then java will remove @@ -132,15 +135,15 @@ public class Sketch { /** * Build the list of files. - *

+ * * Generally this is only done once, rather than * each time a change is made, because otherwise it gets to be * a nightmare to keep track of what files went where, because * not all the data will be saved to disk. - *

+ * * This also gets called when the main sketch file is renamed, * because the sketch has to be reloaded from a different folder. - *

+ * * Another exception is when an external editor is in use, * in which case the load happens each time "run" is hit. */ @@ -153,9 +156,11 @@ public class Sketch { for (int i = 0; i < list.length; i++) { if (list[i].endsWith(".pde")) codeCount++; - else if (list[i].endsWith(".java")) codeCount++; + else if (list[i].endsWith(".c")) codeCount++; + else if (list[i].endsWith(".cpp")) codeCount++; else if (list[i].endsWith(".pde.x")) hiddenCount++; - else if (list[i].endsWith(".java.x")) hiddenCount++; + else if (list[i].endsWith(".c.x")) hiddenCount++; + else if (list[i].endsWith(".cpp.x")) hiddenCount++; } code = new SketchCode[codeCount]; @@ -171,9 +176,15 @@ public class Sketch { new File(folder, list[i]), PDE); - } else if (list[i].endsWith(".java")) { + } else if (list[i].endsWith(".c")) { code[codeCounter++] = - new SketchCode(list[i].substring(0, list[i].length() - 5), + new SketchCode(list[i].substring(0, list[i].length() - 2), + new File(folder, list[i]), + JAVA); + + } else if (list[i].endsWith(".cpp")) { + code[codeCounter++] = + new SketchCode(list[i].substring(0, list[i].length() - 4), new File(folder, list[i]), JAVA); @@ -183,9 +194,14 @@ public class Sketch { new File(folder, list[i]), PDE); - } else if (list[i].endsWith(".java.x")) { + } else if (list[i].endsWith(".c.x")) { hidden[hiddenCounter++] = - new SketchCode(list[i].substring(0, list[i].length() - 7), + new SketchCode(list[i].substring(0, list[i].length() - 4), + new File(folder, list[i]), + JAVA); + } else if (list[i].endsWith(".cpp.x")) { + hidden[hiddenCounter++] = + new SketchCode(list[i].substring(0, list[i].length() - 6), new File(folder, list[i]), JAVA); } @@ -299,7 +315,7 @@ public class Sketch { String prompt = (current == code[0]) ? "New name for sketch:" : "New name for file:"; String oldName = - (current.flavor == PDE) ? current.name : current.name + ".java"; + (current.flavor == PDE) ? current.name : current.name + ".cpp"; editor.status.edit(prompt, oldName); } @@ -331,8 +347,9 @@ public class Sketch { return; } - if (newName.trim().equals(".java") || - newName.trim().equals(".pde")) { + if (newName.trim().equals(".c") || + newName.trim().equals(".pde") || + newName.trim().equals(".cpp")) { return; } @@ -346,18 +363,21 @@ public class Sketch { newName = newName.substring(0, newName.length() - 4); newFlavor = PDE; - } else if (newName.endsWith(".java")) { + } else if (newName.endsWith(".c") || newName.endsWith(".cpp")) { // don't show this error if creating a new tab if (renamingCode && (code[0] == current)) { Base.showWarning("Problem with rename", - "The main .pde file cannot be .java file.\n" + + "The main .pde file cannot be .c or .cpp file.\n" + "(It may be time for your to graduate to a\n" + "\"real\" programming environment)", null); return; } newFilename = newName; - newName = newName.substring(0, newName.length() - 5); + if(newName.endsWith(".c")) + newName = newName.substring(0, newName.length() - 2); + else if(newName.endsWith(".cpp")) + newName = newName.substring(0, newName.length() - 4); newFlavor = JAVA; } else { @@ -370,7 +390,7 @@ public class Sketch { // or something like that (nothing against poo time) if (newName.indexOf('.') != -1) { newName = Sketchbook.sanitizedName(newName); - newFilename = newName + ((newFlavor == PDE) ? ".pde" : ".java"); + newFilename = newName + ((newFlavor == PDE) ? ".pde" : ".cpp"); } // create the new file, new SketchCode object and load it @@ -522,6 +542,7 @@ public class Sketch { // update the tabs //editor.header.repaint(); + editor.header.rebuild(); // force the update on the mac? @@ -658,7 +679,6 @@ public class Sketch { // update the tabs setCurrent(0); editor.header.repaint(); - //editor.header.rebuild(); } @@ -981,17 +1001,18 @@ public class Sketch { // if the file appears to be code related, drop it // into the code folder, instead of the data folder - if (filename.toLowerCase().endsWith(".class") || + if (filename.toLowerCase().endsWith(".o") /*|| filename.toLowerCase().endsWith(".jar") || filename.toLowerCase().endsWith(".dll") || filename.toLowerCase().endsWith(".jnilib") || - filename.toLowerCase().endsWith(".so")) { + filename.toLowerCase().endsWith(".so") */ ) { //File codeFolder = new File(this.folder, "code"); if (!codeFolder.exists()) codeFolder.mkdirs(); destFile = new File(codeFolder, filename); } else if (filename.toLowerCase().endsWith(".pde") || - filename.toLowerCase().endsWith(".java")) { + filename.toLowerCase().endsWith(".c") || + filename.toLowerCase().endsWith(".cpp")) { destFile = new File(this.folder, filename); addingCode = true; @@ -1030,7 +1051,7 @@ public class Sketch { newName = newName.substring(0, newName.length() - 4); newFlavor = PDE; } else { - newName = newName.substring(0, newName.length() - 5); + newName = newName.substring(0, newName.length() - 2); newFlavor = JAVA; } @@ -1045,7 +1066,8 @@ public class Sketch { public void importLibrary(String jarPath) { - // make sure the user didn't hide the sketch folder + System.out.println(jarPath); +/* // make sure the user didn't hide the sketch folder ensureExistence(); String list[] = Compiler.packageListFromClassPath(jarPath); @@ -1068,7 +1090,7 @@ public class Sketch { buffer.append(editor.getText()); editor.setText(buffer.toString(), 0, 0); // scroll to start setModified(); - } +*/ } /** @@ -1174,7 +1196,7 @@ public class Sketch { * X. afterwards, some of these steps need a cleanup function * */ - public boolean handleRun() throws RunnerException { + public boolean handleRun(Target target) throws RunnerException { // make sure the user didn't hide the sketch folder ensureExistence(); @@ -1210,7 +1232,7 @@ public class Sketch { // handle preprocessing the main file's code //mainClassName = build(TEMP_BUILD_PATH, suggestedClassName); mainClassName = - build(tempBuildFolder.getAbsolutePath(), suggestedClassName); + build(target, tempBuildFolder.getAbsolutePath(), suggestedClassName); // externalPaths is magically set by build() if (!externalRuntime) { // only if not running externally already @@ -1240,7 +1262,7 @@ public class Sketch { * * @return null if compilation failed, main class name if not */ - protected String build(String buildPath, String suggestedClassName) + protected String build(Target target, String buildPath, String suggestedClassName) throws RunnerException { // make sure the user didn't hide the sketch folder ensureExistence(); @@ -1279,8 +1301,8 @@ public class Sketch { String codeFolderClassPath = Compiler.contentsToClassPath(codeFolder); // get list of packages found in those jars - codeFolderPackages = - Compiler.packageListFromClassPath(codeFolderClassPath); +// codeFolderPackages = +// Compiler.packageListFromClassPath(codeFolderClassPath); //PApplet.println(libraryPath); //PApplet.println("packages:"); //PApplet.printarr(codeFolderPackages); @@ -1329,11 +1351,11 @@ public class Sketch { // since using the special classloader, // run externally whenever there are extra classes defined - if ((bigCode.indexOf(" class ") != -1) || +/* if ((bigCode.indexOf(" class ") != -1) || (bigCode.indexOf("\nclass ") != -1)) { externalRuntime = true; } - +*/ // if running in opengl mode, this is gonna be external //if (Preferences.get("renderer").equals("opengl")) { //externalRuntime = true; @@ -1360,7 +1382,7 @@ public class Sketch { //System.out.println(); } else { - code[0].preprocName = className + ".java"; + code[0].preprocName = className + "." + Preferences.get("build.extension"); } // store this for the compiler and the runtime @@ -1384,6 +1406,7 @@ public class Sketch { } } errorLine -= code[errorFile].preprocOffset; + //errorLine -= preprocessor.prototypeCount; throw new RunnerException(re.getMessage(), errorFile, errorLine, re.getColumn()); @@ -1402,9 +1425,11 @@ public class Sketch { pattern = compiler.compile(mess); } catch (MalformedPatternException e) { Base.showWarning("Internal Problem", - "An internal error occurred while trying\n" + - "to compile the sketch. Please report\n" + - "this online at http://processing.org/bugs", e); + "An internal error occurred while trying\n" + + "to compile the sketch. Please report\n" + + "this online at " + + "https://developer.berlios.de/bugs/?group_id=3590", + e); } PatternMatcherInput input = @@ -1422,6 +1447,7 @@ public class Sketch { } } errorLine -= code[errorFile].preprocOffset; + //errorLine -= preprocessor.prototypeCount; throw new RunnerException(tsre.getMessage(), errorFile, errorLine, errorColumn); @@ -1485,7 +1511,7 @@ public class Sketch { // just write the the contents of 'program' to a .java file // into the build directory. uses byte stream and reader/writer // shtuff so that unicode bunk is properly handled - String filename = code[i].name + ".java"; + String filename = code[i].name + "." + Preferences.get("build.extension"); try { Base.saveFile(code[i].program, new File(buildPath, filename)); } catch (IOException e) { @@ -1500,12 +1526,53 @@ public class Sketch { // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build(). // + // note: this has been changed to catch build exceptions, adjust + // line number for number of included prototypes, and rethrow + Compiler compiler = new Compiler(); - boolean success = compiler.compile(this, buildPath); + boolean success; + try { + success = compiler.compile(this, buildPath, target); + } catch (RunnerException re) { + throw new RunnerException(re.getMessage(), + re.file, + re.line,// - preprocessor.prototypeCount, + re.column); + } catch (Exception ex) { + // TODO better method for handling this? + throw new RunnerException(ex.toString()); + } //System.out.println("success = " + success + " ... " + primaryClassName); return success ? primaryClassName : null; } + protected String upload(String buildPath, String suggestedClassName) + throws RunnerException { + + // download the program + // + Uploader downloader = + new Uploader(buildPath, suggestedClassName, this); + // macos9 now officially broken.. see PdeCompilerJavac + //PdeCompiler compiler = + // ((PdeBase.platform == PdeBase.MACOS9) ? + // new PdeCompilerJavac(buildPath, className, this) : + // new PdeCompiler(buildPath, className, this)); + + // run the compiler, and funnel errors to the leechErr + // which is a wrapped around + // (this will catch and parse errors during compilation + // the messageStream will call message() for 'compiler') + MessageStream messageStream = new MessageStream(downloader); + //PrintStream leechErr = new PrintStream(messageStream); + //boolean result = compiler.compileJava(leechErr); + //return compiler.compileJava(leechErr); + boolean success = + downloader.downloadJava(new PrintStream(messageStream)); + + return success ? suggestedClassName : null; + } + protected int countLines(String what) { char c[] = what.toCharArray(); @@ -1546,7 +1613,306 @@ public class Sketch { * +-------------------------------------------------------+ * */ - public boolean exportApplet() throws Exception { + public boolean exportApplet(Target target) throws RunnerException { + // make sure the user didn't hide the sketch folder + ensureExistence(); + + zipFileContents = new Hashtable(); + + // nuke the old applet folder because it can cause trouble + File appletFolder = new File(folder, "applet"); + Base.removeDir(appletFolder); + appletFolder.mkdirs(); + + // build the sketch + String foundName = build(target, appletFolder.getPath(), name); + foundName = upload(appletFolder.getPath(), name); + // (already reported) error during export, exit this function + if (foundName == null) return false; + + // if name != exportSketchName, then that's weirdness + // BUG unfortunately, that can also be a bug in the preproc :( + if (!name.equals(foundName)) { + Base.showWarning("Error during export", + "Sketch name is " + name + " but the sketch\n" + + "name in the code was " + foundName, null); + return false; + } + +/* int wide = PApplet.DEFAULT_WIDTH; + int high = PApplet.DEFAULT_HEIGHT; + + PatternMatcher matcher = new Perl5Matcher(); + PatternCompiler compiler = new Perl5Compiler(); + + // this matches against any uses of the size() function, + // whether they contain numbers of variables or whatever. + // this way, no warning is shown if size() isn't actually + // used in the applet, which is the case especially for + // beginners that are cutting/pasting from the reference. + // modified for 83 to match size(XXX, ddd so that it'll + // properly handle size(200, 200) and size(200, 200, P3D) + String sizing = + "[\\s\\;]size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\d+)"; + Pattern pattern = compiler.compile(sizing); + + // adds a space at the beginning, in case size() is the very + // first thing in the program (very common), since the regexp + // needs to check for things in front of it. + PatternMatcherInput input = + new PatternMatcherInput(" " + code[0].program); + if (matcher.contains(input, pattern)) { + MatchResult result = matcher.getMatch(); + try { + wide = Integer.parseInt(result.group(1).toString()); + high = Integer.parseInt(result.group(2).toString()); + + } catch (NumberFormatException e) { + // found a reference to size, but it didn't + // seem to contain numbers + final String message = + "The size of this applet could not automatically be\n" + + "determined from your code. You'll have to edit the\n" + + "HTML file to set the size of the applet."; + + Base.showWarning("Could not find applet size", message, null); + } + } // else no size() command found + + // originally tried to grab this with a regexp matcher, + // but it wouldn't span over multiple lines for the match. + // this could prolly be forced, but since that's the case + // better just to parse by hand. + StringBuffer dbuffer = new StringBuffer(); + String lines[] = PApplet.split(code[0].program, '\n'); + for (int i = 0; i < lines.length; i++) { + if (lines[i].trim().startsWith("/**")) { // this is our comment +*/ // some smartass put the whole thing on the same line + //if (lines[j].indexOf("*/") != -1) break; + +// for (int j = i+1; j < lines.length; j++) { +// if (lines[j].trim().endsWith("*/")) { + // remove the */ from the end, and any extra *s + // in case there's also content on this line + // nah, don't bother.. make them use the three lines +// break; +// } + +/* int offset = 0; + while ((offset < lines[j].length()) && + ((lines[j].charAt(offset) == '*') || + (lines[j].charAt(offset) == ' '))) { + offset++; + } + // insert the return into the html to help w/ line breaks + dbuffer.append(lines[j].substring(offset) + "\n"); + } + } + } + String description = dbuffer.toString(); + + StringBuffer sources = new StringBuffer(); + for (int i = 0; i < codeCount; i++) { + sources.append("" + + code[i].name + " "); + } + + File htmlOutputFile = new File(appletFolder, "index.html"); + FileOutputStream fos = new FileOutputStream(htmlOutputFile); + PrintStream ps = new PrintStream(fos); + + // @@sketch@@, @@width@@, @@height@@, @@archive@@, @@source@@ + // and now @@description@@ + + InputStream is = null; + // if there is an applet.html file in the sketch folder, use that + File customHtml = new File(folder, "applet.html"); + if (customHtml.exists()) { + is = new FileInputStream(customHtml); + } + if (is == null) { + is = Base.getStream("applet.html"); + } + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + + String line = null; + while ((line = reader.readLine()) != null) { + if (line.indexOf("@@") != -1) { + StringBuffer sb = new StringBuffer(line); + int index = 0; + while ((index = sb.indexOf("@@sketch@@")) != -1) { + sb.replace(index, index + "@@sketch@@".length(), + name); + } + while ((index = sb.indexOf("@@source@@")) != -1) { + sb.replace(index, index + "@@source@@".length(), + sources.toString()); + } + while ((index = sb.indexOf("@@archive@@")) != -1) { + sb.replace(index, index + "@@archive@@".length(), + name + ".jar"); + } + while ((index = sb.indexOf("@@width@@")) != -1) { + sb.replace(index, index + "@@width@@".length(), + String.valueOf(wide)); + } + while ((index = sb.indexOf("@@height@@")) != -1) { + sb.replace(index, index + "@@height@@".length(), + String.valueOf(high)); + } + while ((index = sb.indexOf("@@description@@")) != -1) { + sb.replace(index, index + "@@description@@".length(), + description); + } + line = sb.toString(); + } + ps.println(line); + } + + reader.close(); + ps.flush(); + ps.close(); + + // copy the loading gif to the applet + String LOADING_IMAGE = "loading.gif"; + File loadingImage = new File(folder, LOADING_IMAGE); + if (!loadingImage.exists()) { + loadingImage = new File("lib", LOADING_IMAGE); + } + Base.copyFile(loadingImage, new File(appletFolder, LOADING_IMAGE)); +*/ + // copy the source files to the target, since we like + // to encourage people to share their code + for (int i = 0; i < codeCount; i++) { + try { + Base.copyFile(code[i].file, + new File(appletFolder, code[i].file.getName())); + } catch (IOException e) { + e.printStackTrace(); + } + } + +/* // create new .jar file + FileOutputStream zipOutputFile = + new FileOutputStream(new File(appletFolder, name + ".jar")); + ZipOutputStream zos = new ZipOutputStream(zipOutputFile); + ZipEntry entry; + + // add the manifest file + addManifest(zos); + + // add the contents of the code folder to the jar + // unpacks all jar files + //File codeFolder = new File(folder, "code"); + if (codeFolder.exists()) { + String includes = Compiler.contentsToClassPath(codeFolder); + packClassPathIntoZipFile(includes, zos); + } + + // add contents of 'library' folders to the jar file + // if a file called 'export.txt' is in there, it contains + // a list of the files that should be exported. + // otherwise, all files are exported. + Enumeration en = importedLibraries.elements(); + while (en.hasMoreElements()) { + // in the list is a File object that points the + // library sketch's "library" folder + File libraryFolder = (File)en.nextElement(); + File exportSettings = new File(libraryFolder, "export.txt"); + String exportList[] = null; + if (exportSettings.exists()) { + String info[] = Base.loadStrings(exportSettings); + for (int i = 0; i < info.length; i++) { + if (info[i].startsWith("applet")) { + int idx = info[i].indexOf('='); // get applet= or applet = + String commas = info[i].substring(idx+1).trim(); + exportList = PApplet.split(commas, ", "); + } + } + } else { + exportList = libraryFolder.list(); + } + for (int i = 0; i < exportList.length; i++) { + if (exportList[i].equals(".") || + exportList[i].equals("..")) continue; + + exportList[i] = PApplet.trim(exportList[i]); + if (exportList[i].equals("")) continue; + + File exportFile = new File(libraryFolder, exportList[i]); + if (!exportFile.exists()) { + System.err.println("File " + exportList[i] + " does not exist"); + + } else if (exportFile.isDirectory()) { + System.err.println("Ignoring sub-folder \"" + exportList[i] + "\""); + + } else if (exportFile.getName().toLowerCase().endsWith(".zip") || + exportFile.getName().toLowerCase().endsWith(".jar")) { + packClassPathIntoZipFile(exportFile.getAbsolutePath(), zos); + + } else { // just copy the file over.. prolly a .dll or something + Base.copyFile(exportFile, + new File(appletFolder, exportFile.getName())); + } + } + } +*/ +/* String bagelJar = "lib/core.jar"; + packClassPathIntoZipFile(bagelJar, zos); + + // files to include from data directory + // TODO this needs to be recursive + if (dataFolder.exists()) { + String dataFiles[] = dataFolder.list(); + for (int i = 0; i < dataFiles.length; i++) { + // don't export hidden files + // skipping dot prefix removes all: . .. .DS_Store + if (dataFiles[i].charAt(0) == '.') continue; + + entry = new ZipEntry(dataFiles[i]); + zos.putNextEntry(entry); + zos.write(Base.grabFile(new File(dataFolder, dataFiles[i]))); + zos.closeEntry(); + } + } + + // add the project's .class files to the jar + // just grabs everything from the build directory + // since there may be some inner classes + // (add any .class files from the applet dir, then delete them) + // TODO this needs to be recursive (for packages) + String classfiles[] = appletFolder.list(); + for (int i = 0; i < classfiles.length; i++) { + if (classfiles[i].endsWith(".class")) { + entry = new ZipEntry(classfiles[i]); + zos.putNextEntry(entry); + zos.write(Base.grabFile(new File(appletFolder, classfiles[i]))); + zos.closeEntry(); + } + } +*/ + String classfiles[] = appletFolder.list(); + // remove the .class files from the applet folder. if they're not + // removed, the msjvm will complain about an illegal access error, + // since the classes are outside the jar file. + for (int i = 0; i < classfiles.length; i++) { + if (classfiles[i].endsWith(".class")) { + File deadguy = new File(appletFolder, classfiles[i]); + if (!deadguy.delete()) { + Base.showWarning("Could not delete", + classfiles[i] + " could not \n" + + "be deleted from the applet folder. \n" + + "You'll need to remove it by hand.", null); + } + } + } + + // close up the jar file +/* zos.flush(); + zos.close(); +*/ + if(Preferences.getBoolean("uploader.open_folder")) + Base.openFolder(appletFolder); return true; } @@ -1603,7 +1969,7 @@ public class Sketch { } - public void addManifest(ZipOutputStream zos) throws IOException { +/* public void addManifest(ZipOutputStream zos) throws IOException { ZipEntry entry = new ZipEntry("META-INF/MANIFEST.MF"); zos.putNextEntry(entry); @@ -1613,7 +1979,7 @@ public class Sketch { "Main-Class: " + name + "\n"; // TODO not package friendly zos.write(contents.getBytes()); zos.closeEntry(); - +*/ /* for (int i = 0; i < bagelClasses.length; i++) { if (!bagelClasses[i].endsWith(".class")) continue; @@ -1623,17 +1989,17 @@ public class Sketch { zos.closeEntry(); } */ - } - +/* } +*/ /** * Slurps up .class files from a colon (or semicolon on windows) * separated list of paths and adds them to a ZipOutputStream. */ - public void packClassPathIntoZipFile(String path, +/* public void packClassPathIntoZipFile(String path, ZipOutputStream zos) throws IOException { - String pieces[] = Base.split(path, File.pathSeparatorChar); + String pieces[] = PApplet.split(path, File.pathSeparatorChar); for (int i = 0; i < pieces.length; i++) { if (pieces[i].length() == 0) continue; @@ -1692,14 +2058,14 @@ public class Sketch { } } } - +*/ /** * Continue the process of magical exporting. This function * can be called recursively to walk through folders looking * for more goodies that will be added to the ZipOutputStream. */ - static public void packClassPathIntoZipFileRecursive(File dir, +/* static public void packClassPathIntoZipFileRecursive(File dir, String sofar, ZipOutputStream zos) throws IOException { @@ -1729,7 +2095,7 @@ public class Sketch { } } } - +*/ /** * Make sure the sketch hasn't been moved or deleted by some diff --git a/app/Sketchbook.java b/app/Sketchbook.java index d8a7102c7..08c2be03a 100644 --- a/app/Sketchbook.java +++ b/app/Sketchbook.java @@ -565,8 +565,8 @@ public class Sketchbook { librariesClassPath += File.pathSeparatorChar + libraryClassPath; // need to associate each import with a library folder - String packages[] = - Compiler.packageListFromClassPath(libraryClassPath); + String packages[] = new String[0]; + //Compiler.packageListFromClassPath(libraryClassPath); for (int k = 0; k < packages.length; k++) { importToLibraryTable.put(packages[k], exported); } diff --git a/app/Target.java b/app/Target.java new file mode 100644 index 000000000..cfd1bf07d --- /dev/null +++ b/app/Target.java @@ -0,0 +1,79 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Target - represents a target platform + Part of the Arduino project - http://arduino.berlios.de/ + + Copyright (c) 2005 + David A. Mellis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id:$ +*/ + +package processing.app; +import java.io.*; +import java.util.*; + +/** + * Represents a target platform (e.g. Wiring board, Arduino board). + */ +public class Target { + String path; + List sources = new ArrayList(); + List objects = new ArrayList(); + + /** + * Create a Target. + * @param path the directory containing config, source, and object files for + * the target platform. + */ + public Target(String base, String target) throws IOException { + path = base + File.separator + target; + String[] files = (new File(path)).list(); + + if (files == null) + throw new IOException("Target platform: \"" + target + "\" not found.\n" + + "Make sure that \"build.target\" in the \n" + + "preferences file points to a subdirectory of \n" + + base); + + for (int i = 0; i < files.length; i++) { + if (files[i].endsWith(".c") || files[i].endsWith(".cpp")) + sources.add(files[i]); + if (files[i].endsWith(".o")) + objects.add(files[i]); + } + } + + public String getPath() { return path; } + + /** + * The source files in the library for the target platform. + * @return A read-only collection of strings containing the name of each source file. + */ + public Collection getSourceFilenames() { + return Collections.unmodifiableList(sources); + } + + /** + * The object files in the library for the target platform. + * @return A read-only collection of strings containing the name of each object file. + */ + public Collection getObjectFilenames() { + return Collections.unmodifiableList(objects); + } +} diff --git a/app/Uploader.java b/app/Uploader.java new file mode 100755 index 000000000..84938dd62 --- /dev/null +++ b/app/Uploader.java @@ -0,0 +1,230 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Uploader - default downloader class that connects to uisp + Part of the Arduino project - http://arduino.berlios.de/ + + Copyright (c) 2004-05 + Hernando Barragan + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id:$ +*/ + +package processing.app; +import java.io.*; +import java.util.*; +import java.util.zip.*; +import javax.swing.*; +//#ifndef RXTX +//import javax.comm.*; +//#else +// rxtx uses package gnu.io, but all the class names +// are the same as those used by javax.comm +import gnu.io.*; +//#endif + + +public class Uploader implements MessageConsumer { + static final String BUGS_URL = + "https://developer.berlios.de/bugs/?group_id=3590"; + static final String SUPER_BADNESS = + "Compiler error, please submit this code to " + BUGS_URL; + + String buildPath; + String className; + File includeFolder; + RunnerException exception; + Sketch sketch; + //PdePreferences preferences; + + //Serial serialPort; + static InputStream serialInput; + static OutputStream serialOutput; + //int serial; // last byte of data received + + private String serial_port = "COM1"; + private int serial_rate = 9600; + private char serial_parity = 'N'; + private int serial_databits = 8; + private float serial_stopbits = 1; + + public void serialPreferences() { + //System.out.println("setting serial properties"); + serial_port = Preferences.get("serial.port"); + serial_rate = Preferences.getInteger("serial.download_rate"); + serial_parity = Preferences.get("serial.parity").charAt(0); + serial_databits = Preferences.getInteger("serial.databits"); + serial_stopbits = new Float(Preferences.get("serial.stopbits")).floatValue(); + } + + public Uploader(String buildPath, String className, + Sketch sketch) { + this.buildPath = buildPath; + this.includeFolder = includeFolder; + this.className = className; + this.sketch = sketch; + } + + public boolean downloadJava(PrintStream leechErr) throws RunnerException { + String userdir = System.getProperty("user.dir") + File.separator; +// String commandDownloader[] = new String[] { +// ((!Base.isMacOS()) ? "tools/avr/bin/uisp" : +// userdir + "tools/avr/bin/uisp"), +// //[2] Serial port +// //[3] Serial download rate +// //[6] hex class file +// "-dprog=stk500", +// " ", +// " ", +// "-dpart=" + Preferences.get("build.mcu"), +// "--upload", +// " " +// }; + + firstErrorFound = false; // haven't found any errors yet + secondErrorFound = false; + notFoundError = false; + int result=0; // pre-initialized to quiet a bogus warning from jikes + try { + serialPreferences(); + List commandDownloader = new ArrayList(); + commandDownloader.add((!Base.isMacOS() ? "" : userdir) + "tools/avr/bin/uisp"); + commandDownloader.add("-dprog=" + Preferences.get("upload.programmer")); + commandDownloader.add("-dpart=" + Preferences.get("build.mcu")); + if (Preferences.get("upload.programmer").equals("dapa")) + commandDownloader.add("-dlpt=" + Preferences.get("parallel.port")); + else { + commandDownloader.add("-dserial=" + (!Base.isMacOS() ? "/dev/" + serial_port.toLowerCase() : serial_port)); + commandDownloader.add("-dspeed=" + serial_rate); + } + if (Preferences.getBoolean("upload.erase")) + commandDownloader.add("--erase"); + commandDownloader.add("--upload"); + if (Preferences.getBoolean("upload.verify")) + commandDownloader.add("--verify"); + commandDownloader.add("if=" + buildPath + File.separator + className + ".hex"); + +// commandDownloader[2] = ((!Base.isMacOS()) ? "-dserial=/dev/" + serial_port.toLowerCase() : "-dserial=" + serial_port ); +// commandDownloader[3] = "-dspeed=" + serial_rate; +// commandDownloader[6] = "if=" + buildPath + File.separator + className + ".hex"; + /*for(int i = 0; i < commandDownloader.length; i++) { + System.out.println(commandDownloader[i]); + }*/ + + // Cleanup the serial buffer + /*serialPort = new Serial(); + byte[] readBuffer; + while(serialPort.available() > 0) { + readBuffer = serialPort.readBytes(); + Thread.sleep(100); + } + serialPort.dispose(); */ + + String[] commandArray = new String[commandDownloader.size()]; + Process process = Runtime.getRuntime().exec((String[]) commandDownloader.toArray(commandArray)); + new MessageSiphon(process.getInputStream(), this); + new MessageSiphon(process.getErrorStream(), this); + + // wait for the process to finish. if interrupted + // before waitFor returns, continue waiting + // + boolean compiling = true; + while (compiling) { + try { + result = process.waitFor(); + compiling = false; + } catch (InterruptedException intExc) { + } + } + if(exception!=null) { + exception.hideStackTrace = true; + throw exception; + } + if(result!=0) + return false; + } catch (Exception e) { + String msg = e.getMessage(); + if ((msg != null) && (msg.indexOf("uisp: not found") != -1)) { + //System.err.println("uisp is missing"); + //JOptionPane.showMessageDialog(editor.base, + // "Could not find the compiler.\n" + + // "uisp is missing from your PATH,\n" + + // "see readme.txt for help.", + // "Compiler error", + // JOptionPane.ERROR_MESSAGE); + return false; + } else { + e.printStackTrace(); + result = -1; + } + } + //System.out.println("result2 is "+result); + // if the result isn't a known, expected value it means that something + // is fairly wrong, one possibility is that jikes has crashed. + // + if (exception != null) throw exception; + + if ((result != 0) && (result != 1 )) { + exception = new RunnerException(SUPER_BADNESS); + //editor.error(exception); + //PdeBase.openURL(BUGS_URL); + //throw new PdeException(SUPER_BADNESS); + } + + return (result == 0); // ? true : false; + + } + + boolean firstErrorFound; + boolean secondErrorFound; + + // part of the PdeMessageConsumer interface + // + boolean notFoundError; + + public void message(String s) { + //System.err.println("MSG: " + s); + System.err.print(s); + + // ignore cautions + if (s.indexOf("Error") != -1) { + //exception = new RunnerException(s+" Check the serial port selected or your Board is connected"); + //System.out.println(s); + notFoundError = true; + return; + } + if(notFoundError) { + //System.out.println("throwing something"); + exception = new RunnerException("the selected serial port "+s+" does not exist or your board is not connected"); + return; + } + // jikes always uses a forward slash character as its separator, so + // we need to replace any platform-specific separator characters before + // attemping to compare + // + if (s.indexOf("Device is not responding") != -1 ) { + exception = new RunnerException("Device is not responding, check the right serial port is selected or RESET the board right before exporting"); + return; + } + if (s.indexOf("Programmer is not responding") != -1) { + exception = new RunnerException("Programmer is not responding, RESET the board right before exporting"); + return; + } + } + + +} diff --git a/app/preproc/.cvsignore b/app/preproc/.cvsignore deleted file mode 100644 index cd1971435..000000000 --- a/app/preproc/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -*Lexer.java -*Recognizer.java -*TokenTypes.java -*TokenTypes.txt -*TreeParser.java -*TreeParserTokenTypes.java -*TreeParserTokenTypes.txt -expanded*.g - diff --git a/app/preproc/CSymbolTable.java b/app/preproc/CSymbolTable.java new file mode 100755 index 000000000..aa752ef0e --- /dev/null +++ b/app/preproc/CSymbolTable.java @@ -0,0 +1,133 @@ +package processing.app.preproc; + + +import java.util.Vector; +import java.util.Hashtable; +import java.util.Enumeration; + + + +public class CSymbolTable { + + /** holds list of scopes */ + private Vector scopeStack; + + /** table where all defined names are mapped to TNode tree nodes */ + private Hashtable symTable; + + public CSymbolTable() { + scopeStack = new Vector(10); + symTable = new Hashtable(533); + } + + + /** push a new scope onto the scope stack. + */ + public void pushScope(String s) { + //System.out.println("push scope:" + s); + scopeStack.addElement(s); + } + + /** pop the last scope off the scope stack. + */ + public void popScope() { + //System.out.println("pop scope"); + int size = scopeStack.size(); + if(size > 0) + scopeStack.removeElementAt(size - 1); + } + + /** return the current scope as a string + */ + public String currentScopeAsString() { + StringBuffer buf = new StringBuffer(100); + boolean first = true; + Enumeration e = scopeStack.elements(); + while(e.hasMoreElements()) { + if(first) + first = false; + else + buf.append("::"); + buf.append(e.nextElement().toString()); + } + return buf.toString(); + } + + /** given a name for a type, append it with the + current scope. + */ + public String addCurrentScopeToName(String name) { + String currScope = currentScopeAsString(); + return addScopeToName(currScope, name); + } + + /** given a name for a type, append it with the + given scope. MBZ + */ + public String addScopeToName(String scope, String name) { + if(scope == null || scope.length() > 0) + return scope + "::" + name; + else + return name; + } + + /** remove one level of scope from name MBZ*/ + public String removeOneLevelScope(String scopeName) { + int index = scopeName.lastIndexOf("::"); + if (index > 0) { + return scopeName.substring(0,index); + } + if (scopeName.length() > 0) { + return ""; + } + return null; + } + + /** add a node to the table with it's key as + the current scope and the name */ + public TNode add(String name, TNode node) { + return (TNode)symTable.put(addCurrentScopeToName(name),node); + } + + + /** lookup a fully scoped name in the symbol table */ + public TNode lookupScopedName(String scopedName) { + return (TNode)symTable.get(scopedName); + } + + /** lookup an unscoped name in the table by prepending + the current scope. + MBZ -- if not found, pop scopes and look again + */ + public TNode lookupNameInCurrentScope(String name) { + String scope = currentScopeAsString(); + String scopedName; + TNode tnode = null; + + //System.out.println( "\n"+ this.toString() ); + + while (tnode == null && scope != null) { + scopedName = addScopeToName(scope, name); + //System.out.println("lookup trying " + scopedName); + tnode = (TNode)symTable.get(scopedName); + scope = removeOneLevelScope(scope); + } + return tnode; + } + + /** convert this table to a string */ + public String toString() { + StringBuffer buff = new StringBuffer(300); + buff.append("CSymbolTable { \nCurrentScope: " + currentScopeAsString() + + "\nDefinedSymbols:\n"); + Enumeration ke = symTable.keys(); + Enumeration ve = symTable.elements(); + while(ke.hasMoreElements()) { + buff.append(ke.nextElement().toString() + " (" + + TNode.getNameForType(((TNode)ve.nextElement()).getType()) + ")\n"); + } + buff.append("}\n"); + return buff.toString(); + } + +}; diff --git a/app/preproc/CToken.java b/app/preproc/CToken.java new file mode 100755 index 000000000..6cdb54206 --- /dev/null +++ b/app/preproc/CToken.java @@ -0,0 +1,32 @@ +package processing.app.preproc; + +import antlr.CommonToken; + +public class CToken extends antlr.CommonToken { + String source = ""; + int tokenNumber; + + public String getSource() + { + return source; + } + + public void setSource(String src) + { + source = src; + } + + public int getTokenNumber() + { + return tokenNumber; + } + + public void setTokenNumber(int i) + { + tokenNumber = i; + } + + public String toString() { + return "CToken:" +"(" + hashCode() + ")" + "[" + getType() + "] "+ getText() + " line:" + getLine() + " source:" + source ; + } +} diff --git a/app/preproc/CVS/Entries b/app/preproc/CVS/Entries new file mode 100644 index 000000000..9273971f1 --- /dev/null +++ b/app/preproc/CVS/Entries @@ -0,0 +1,15 @@ +/CSymbolTable.java/1.1.1.1/Thu Sep 22 15:32:54 2005// +/CToken.java/1.1.1.1/Thu Sep 22 15:32:54 2005// +/ExtendedCommonASTWithHiddenTokens.java/1.1.1.1/Thu Sep 22 15:32:55 2005// +/LineObject.java/1.1.1.1/Thu Sep 22 15:32:55 2005// +/Makefile/1.1.1.1/Thu Sep 22 15:32:55 2005// +/PreprocessorInfoChannel.java/1.1.1.1/Thu Sep 22 15:32:55 2005// +/StdCParser.g/1.1.1.1/Thu Sep 22 15:32:56 2005// +/TNode.java/1.1.1.1/Thu Sep 22 15:32:56 2005// +/TNodeFactory.java/1.1.1.1/Thu Sep 22 15:32:56 2005// +/WEmitter.g/1.4/Thu Sep 22 15:32:56 2005// +/WParser.g/1.4/Thu Sep 22 15:32:57 2005// +/WTreeParser.g/1.2/Thu Sep 22 15:32:57 2005// +/whitespace_test.pde/1.1.1.1/Thu Sep 22 15:32:56 2005// +/PdePreprocessor.java/1.13/Sat Sep 24 11:26:19 2005// +D diff --git a/app/preproc/CVS/Repository b/app/preproc/CVS/Repository new file mode 100644 index 000000000..8edc19831 --- /dev/null +++ b/app/preproc/CVS/Repository @@ -0,0 +1 @@ +wiring/app/preproc diff --git a/app/preproc/CVS/Root b/app/preproc/CVS/Root new file mode 100644 index 000000000..d59a7bfa3 --- /dev/null +++ b/app/preproc/CVS/Root @@ -0,0 +1 @@ +:ext:dmellis@wcvs.uniandes.edu.co:/home/cvs/cvsrep diff --git a/app/preproc/ExtendedCommonASTWithHiddenTokens.java b/app/preproc/ExtendedCommonASTWithHiddenTokens.java old mode 100644 new mode 100755 index 08547dd05..124ee1be2 --- a/app/preproc/ExtendedCommonASTWithHiddenTokens.java +++ b/app/preproc/ExtendedCommonASTWithHiddenTokens.java @@ -4,7 +4,7 @@ package antlr; * Project led by Terence Parr at http://www.jGuru.com * Software rights: http://www.antlr.org/RIGHTS.html * - * $Id: ExtendedCommonASTWithHiddenTokens.java,v 1.1 2005/04/09 02:30:36 benfry Exp $ + * $Id: ExtendedCommonASTWithHiddenTokens.java,v 1.1.1.1 2005/06/22 22:18:14 h Exp $ */ import java.io.*; diff --git a/app/preproc/JavaLexer.java b/app/preproc/JavaLexer.java deleted file mode 100644 index 3ac053011..000000000 --- a/app/preproc/JavaLexer.java +++ /dev/null @@ -1,1899 +0,0 @@ -// $ANTLR 2.7.2: "java.g" -> "JavaLexer.java"$ - -package antlr.java; - -import java.io.InputStream; -import antlr.TokenStreamException; -import antlr.TokenStreamIOException; -import antlr.TokenStreamRecognitionException; -import antlr.CharStreamException; -import antlr.CharStreamIOException; -import antlr.ANTLRException; -import java.io.Reader; -import java.util.Hashtable; -import antlr.CharScanner; -import antlr.InputBuffer; -import antlr.ByteBuffer; -import antlr.CharBuffer; -import antlr.Token; -import antlr.CommonToken; -import antlr.RecognitionException; -import antlr.NoViableAltForCharException; -import antlr.MismatchedCharException; -import antlr.TokenStream; -import antlr.ANTLRHashString; -import antlr.LexerSharedInputState; -import antlr.collections.impl.BitSet; -import antlr.SemanticException; - -public class JavaLexer extends antlr.CharScanner implements JavaTokenTypes, TokenStream - { -public JavaLexer(InputStream in) { - this(new ByteBuffer(in)); -} -public JavaLexer(Reader in) { - this(new CharBuffer(in)); -} -public JavaLexer(InputBuffer ib) { - this(new LexerSharedInputState(ib)); -} -public JavaLexer(LexerSharedInputState state) { - super(state); - caseSensitiveLiterals = true; - setCaseSensitive(true); - literals = new Hashtable(); - literals.put(new ANTLRHashString("byte", this), new Integer(51)); - literals.put(new ANTLRHashString("public", this), new Integer(62)); - literals.put(new ANTLRHashString("case", this), new Integer(95)); - literals.put(new ANTLRHashString("short", this), new Integer(53)); - literals.put(new ANTLRHashString("break", this), new Integer(89)); - literals.put(new ANTLRHashString("while", this), new Integer(87)); - literals.put(new ANTLRHashString("new", this), new Integer(138)); - literals.put(new ANTLRHashString("instanceof", this), new Integer(123)); - literals.put(new ANTLRHashString("implements", this), new Integer(76)); - literals.put(new ANTLRHashString("synchronized", this), new Integer(68)); - literals.put(new ANTLRHashString("float", this), new Integer(55)); - literals.put(new ANTLRHashString("package", this), new Integer(44)); - literals.put(new ANTLRHashString("return", this), new Integer(91)); - literals.put(new ANTLRHashString("throw", this), new Integer(93)); - literals.put(new ANTLRHashString("null", this), new Integer(137)); - literals.put(new ANTLRHashString("threadsafe", this), new Integer(67)); - literals.put(new ANTLRHashString("protected", this), new Integer(63)); - literals.put(new ANTLRHashString("class", this), new Integer(70)); - literals.put(new ANTLRHashString("throws", this), new Integer(82)); - literals.put(new ANTLRHashString("do", this), new Integer(88)); - literals.put(new ANTLRHashString("strictfp", this), new Integer(41)); - literals.put(new ANTLRHashString("super", this), new Integer(80)); - literals.put(new ANTLRHashString("transient", this), new Integer(65)); - literals.put(new ANTLRHashString("native", this), new Integer(66)); - literals.put(new ANTLRHashString("interface", this), new Integer(72)); - literals.put(new ANTLRHashString("final", this), new Integer(39)); - literals.put(new ANTLRHashString("if", this), new Integer(84)); - literals.put(new ANTLRHashString("double", this), new Integer(57)); - literals.put(new ANTLRHashString("volatile", this), new Integer(69)); - literals.put(new ANTLRHashString("assert", this), new Integer(94)); - literals.put(new ANTLRHashString("catch", this), new Integer(99)); - literals.put(new ANTLRHashString("try", this), new Integer(97)); - literals.put(new ANTLRHashString("int", this), new Integer(54)); - literals.put(new ANTLRHashString("for", this), new Integer(86)); - literals.put(new ANTLRHashString("extends", this), new Integer(71)); - literals.put(new ANTLRHashString("boolean", this), new Integer(50)); - literals.put(new ANTLRHashString("char", this), new Integer(52)); - literals.put(new ANTLRHashString("private", this), new Integer(61)); - literals.put(new ANTLRHashString("default", this), new Integer(96)); - literals.put(new ANTLRHashString("false", this), new Integer(136)); - literals.put(new ANTLRHashString("this", this), new Integer(79)); - literals.put(new ANTLRHashString("static", this), new Integer(64)); - literals.put(new ANTLRHashString("abstract", this), new Integer(40)); - literals.put(new ANTLRHashString("continue", this), new Integer(90)); - literals.put(new ANTLRHashString("finally", this), new Integer(98)); - literals.put(new ANTLRHashString("else", this), new Integer(85)); - literals.put(new ANTLRHashString("import", this), new Integer(46)); - literals.put(new ANTLRHashString("void", this), new Integer(49)); - literals.put(new ANTLRHashString("switch", this), new Integer(92)); - literals.put(new ANTLRHashString("true", this), new Integer(135)); - literals.put(new ANTLRHashString("long", this), new Integer(56)); -} - -public Token nextToken() throws TokenStreamException { - Token theRetToken=null; -tryAgain: - for (;;) { - Token _token = null; - int _ttype = Token.INVALID_TYPE; - resetText(); - try { // for char stream error handling - try { // for lexical error handling - switch ( LA(1)) { - case '?': - { - mQUESTION(true); - theRetToken=_returnToken; - break; - } - case '(': - { - mLPAREN(true); - theRetToken=_returnToken; - break; - } - case ')': - { - mRPAREN(true); - theRetToken=_returnToken; - break; - } - case '[': - { - mLBRACK(true); - theRetToken=_returnToken; - break; - } - case ']': - { - mRBRACK(true); - theRetToken=_returnToken; - break; - } - case '{': - { - mLCURLY(true); - theRetToken=_returnToken; - break; - } - case '}': - { - mRCURLY(true); - theRetToken=_returnToken; - break; - } - case ':': - { - mCOLON(true); - theRetToken=_returnToken; - break; - } - case ',': - { - mCOMMA(true); - theRetToken=_returnToken; - break; - } - case '~': - { - mBNOT(true); - theRetToken=_returnToken; - break; - } - case ';': - { - mSEMI(true); - theRetToken=_returnToken; - break; - } - case '\t': case '\n': case '\u000c': case '\r': - case ' ': - { - mWS(true); - theRetToken=_returnToken; - break; - } - case '\'': - { - mCHAR_LITERAL(true); - theRetToken=_returnToken; - break; - } - case '"': - { - mSTRING_LITERAL(true); - theRetToken=_returnToken; - break; - } - case '$': case 'A': case 'B': case 'C': - case 'D': case 'E': case 'F': case 'G': - case 'H': case 'I': case 'J': case 'K': - case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': - case 'T': case 'U': case 'V': case 'W': - case 'X': case 'Y': case 'Z': case '_': - case 'a': case 'b': case 'c': case 'd': - case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': - case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - { - mIDENT(true); - theRetToken=_returnToken; - break; - } - case '.': case '0': case '1': case '2': - case '3': case '4': case '5': case '6': - case '7': case '8': case '9': - { - mNUM_INT(true); - theRetToken=_returnToken; - break; - } - default: - if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='>') && (LA(4)=='=')) { - mBSR_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='=')) { - mSR_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='>') && (LA(2)=='>') && (LA(3)=='>') && (true)) { - mBSR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='<') && (LA(2)=='<') && (LA(3)=='=')) { - mSL_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='=') && (LA(2)=='=')) { - mEQUAL(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='!') && (LA(2)=='=')) { - mNOT_EQUAL(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='/') && (LA(2)=='=')) { - mDIV_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='+') && (LA(2)=='=')) { - mPLUS_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='+') && (LA(2)=='+')) { - mINC(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='-') && (LA(2)=='=')) { - mMINUS_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='-') && (LA(2)=='-')) { - mDEC(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='*') && (LA(2)=='=')) { - mSTAR_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='%') && (LA(2)=='=')) { - mMOD_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='>') && (LA(2)=='>') && (true)) { - mSR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='>') && (LA(2)=='=')) { - mGE(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='<') && (LA(2)=='<') && (true)) { - mSL(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='<') && (LA(2)=='=')) { - mLE(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='^') && (LA(2)=='=')) { - mBXOR_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='|') && (LA(2)=='=')) { - mBOR_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='|') && (LA(2)=='|')) { - mLOR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='&') && (LA(2)=='=')) { - mBAND_ASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='&') && (LA(2)=='&')) { - mLAND(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='/') && (LA(2)=='/')) { - mSL_COMMENT(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='/') && (LA(2)=='*')) { - mML_COMMENT(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='=') && (true)) { - mASSIGN(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='!') && (true)) { - mLNOT(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='/') && (true)) { - mDIV(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='+') && (true)) { - mPLUS(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='-') && (true)) { - mMINUS(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='*') && (true)) { - mSTAR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='%') && (true)) { - mMOD(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='>') && (true)) { - mGT(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='<') && (true)) { - mLT(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='^') && (true)) { - mBXOR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='|') && (true)) { - mBOR(true); - theRetToken=_returnToken; - } - else if ((LA(1)=='&') && (true)) { - mBAND(true); - theRetToken=_returnToken; - } - else { - if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} - else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - } - if ( _returnToken==null ) continue tryAgain; // found SKIP token - _ttype = _returnToken.getType(); - _returnToken.setType(_ttype); - return _returnToken; - } - catch (RecognitionException e) { - throw new TokenStreamRecognitionException(e); - } - } - catch (CharStreamException cse) { - if ( cse instanceof CharStreamIOException ) { - throw new TokenStreamIOException(((CharStreamIOException)cse).io); - } - else { - throw new TokenStreamException(cse.getMessage()); - } - } - } -} - - public final void mQUESTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = QUESTION; - int _saveIndex; - - match('?'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LPAREN; - int _saveIndex; - - match('('); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = RPAREN; - int _saveIndex; - - match(')'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LBRACK; - int _saveIndex; - - match('['); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mRBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = RBRACK; - int _saveIndex; - - match(']'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LCURLY; - int _saveIndex; - - match('{'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mRCURLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = RCURLY; - int _saveIndex; - - match('}'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mCOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = COLON; - int _saveIndex; - - match(':'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = COMMA; - int _saveIndex; - - match(','); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = ASSIGN; - int _saveIndex; - - match('='); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = EQUAL; - int _saveIndex; - - match("=="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LNOT; - int _saveIndex; - - match('!'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBNOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BNOT; - int _saveIndex; - - match('~'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mNOT_EQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = NOT_EQUAL; - int _saveIndex; - - match("!="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mDIV(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = DIV; - int _saveIndex; - - match('/'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mDIV_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = DIV_ASSIGN; - int _saveIndex; - - match("/="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = PLUS; - int _saveIndex; - - match('+'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mPLUS_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = PLUS_ASSIGN; - int _saveIndex; - - match("+="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mINC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = INC; - int _saveIndex; - - match("++"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = MINUS; - int _saveIndex; - - match('-'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mMINUS_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = MINUS_ASSIGN; - int _saveIndex; - - match("-="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mDEC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = DEC; - int _saveIndex; - - match("--"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSTAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = STAR; - int _saveIndex; - - match('*'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSTAR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = STAR_ASSIGN; - int _saveIndex; - - match("*="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mMOD(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = MOD; - int _saveIndex; - - match('%'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mMOD_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = MOD_ASSIGN; - int _saveIndex; - - match("%="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SR; - int _saveIndex; - - match(">>"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SR_ASSIGN; - int _saveIndex; - - match(">>="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBSR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BSR; - int _saveIndex; - - match(">>>"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBSR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BSR_ASSIGN; - int _saveIndex; - - match(">>>="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mGE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = GE; - int _saveIndex; - - match(">="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mGT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = GT; - int _saveIndex; - - match(">"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SL; - int _saveIndex; - - match("<<"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSL_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SL_ASSIGN; - int _saveIndex; - - match("<<="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LE; - int _saveIndex; - - match("<="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LT; - int _saveIndex; - - match('<'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBXOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BXOR; - int _saveIndex; - - match('^'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBXOR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BXOR_ASSIGN; - int _saveIndex; - - match("^="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BOR; - int _saveIndex; - - match('|'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBOR_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BOR_ASSIGN; - int _saveIndex; - - match("|="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LOR; - int _saveIndex; - - match("||"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BAND; - int _saveIndex; - - match('&'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mBAND_ASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = BAND_ASSIGN; - int _saveIndex; - - match("&="); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mLAND(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = LAND; - int _saveIndex; - - match("&&"); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSEMI(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SEMI; - int _saveIndex; - - match(';'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = WS; - int _saveIndex; - - { - int _cnt246=0; - _loop246: - do { - switch ( LA(1)) { - case ' ': - { - match(' '); - break; - } - case '\t': - { - match('\t'); - break; - } - case '\u000c': - { - match('\f'); - break; - } - case '\n': case '\r': - { - { - if ((LA(1)=='\r') && (LA(2)=='\n') && (true) && (true)) { - match("\r\n"); - } - else if ((LA(1)=='\r') && (true) && (true) && (true)) { - match('\r'); - } - else if ((LA(1)=='\n')) { - match('\n'); - } - else { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - - } - newline(); - break; - } - default: - { - if ( _cnt246>=1 ) { break _loop246; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - } - _cnt246++; - } while (true); - } - _ttype = Token.SKIP; - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSL_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = SL_COMMENT; - int _saveIndex; - - match("//"); - { - _loop250: - do { - if ((_tokenSet_0.member(LA(1)))) { - { - match(_tokenSet_0); - } - } - else { - break _loop250; - } - - } while (true); - } - { - switch ( LA(1)) { - case '\n': - { - match('\n'); - break; - } - case '\r': - { - match('\r'); - { - if ((LA(1)=='\n')) { - match('\n'); - } - else { - } - - } - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - _ttype = Token.SKIP; newline(); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mML_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = ML_COMMENT; - int _saveIndex; - - match("/*"); - { - _loop256: - do { - if ((LA(1)=='\r') && (LA(2)=='\n') && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')) && ((LA(4) >= '\u0003' && LA(4) <= '\uffff'))) { - match('\r'); - match('\n'); - newline(); - } - else if (((LA(1)=='*') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')))&&( LA(2)!='/' )) { - match('*'); - } - else if ((LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && ((LA(3) >= '\u0003' && LA(3) <= '\uffff')) && (true)) { - match('\r'); - newline(); - } - else if ((LA(1)=='\n')) { - match('\n'); - newline(); - } - else if ((_tokenSet_1.member(LA(1)))) { - { - match(_tokenSet_1); - } - } - else { - break _loop256; - } - - } while (true); - } - match("*/"); - _ttype = Token.SKIP; - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mCHAR_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = CHAR_LITERAL; - int _saveIndex; - - match('\''); - { - if ((LA(1)=='\\')) { - mESC(false); - } - else if ((_tokenSet_2.member(LA(1)))) { - matchNot('\''); - } - else { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - - } - match('\''); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = ESC; - int _saveIndex; - - match('\\'); - { - switch ( LA(1)) { - case 'n': - { - match('n'); - break; - } - case 'r': - { - match('r'); - break; - } - case 't': - { - match('t'); - break; - } - case 'b': - { - match('b'); - break; - } - case 'f': - { - match('f'); - break; - } - case '"': - { - match('"'); - break; - } - case '\'': - { - match('\''); - break; - } - case '\\': - { - match('\\'); - break; - } - case 'u': - { - { - int _cnt266=0; - _loop266: - do { - if ((LA(1)=='u')) { - match('u'); - } - else { - if ( _cnt266>=1 ) { break _loop266; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - - _cnt266++; - } while (true); - } - mHEX_DIGIT(false); - mHEX_DIGIT(false); - mHEX_DIGIT(false); - mHEX_DIGIT(false); - break; - } - case '0': case '1': case '2': case '3': - { - matchRange('0','3'); - { - if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && (true) && (true)) { - matchRange('0','7'); - { - if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && (true) && (true)) { - matchRange('0','7'); - } - else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true) && (true) && (true)) { - } - else { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - - } - } - else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true) && (true) && (true)) { - } - else { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - - } - break; - } - case '4': case '5': case '6': case '7': - { - matchRange('4','7'); - { - if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')) && (true) && (true)) { - matchRange('0','7'); - } - else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true) && (true) && (true)) { - } - else { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - - } - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mSTRING_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = STRING_LITERAL; - int _saveIndex; - - match('"'); - { - _loop262: - do { - if ((LA(1)=='\\')) { - mESC(false); - } - else if ((_tokenSet_3.member(LA(1)))) { - { - match(_tokenSet_3); - } - } - else { - break _loop262; - } - - } while (true); - } - match('"'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - protected final void mHEX_DIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = HEX_DIGIT; - int _saveIndex; - - { - switch ( LA(1)) { - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - { - matchRange('0','9'); - break; - } - case 'A': case 'B': case 'C': case 'D': - case 'E': case 'F': - { - matchRange('A','F'); - break; - } - case 'a': case 'b': case 'c': case 'd': - case 'e': case 'f': - { - matchRange('a','f'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - protected final void mVOCAB(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = VOCAB; - int _saveIndex; - - matchRange('\3','\377'); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mIDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = IDENT; - int _saveIndex; - - { - switch ( LA(1)) { - case 'a': case 'b': case 'c': case 'd': - case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': - case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - { - matchRange('a','z'); - break; - } - case 'A': case 'B': case 'C': case 'D': - case 'E': case 'F': case 'G': case 'H': - case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': - case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - { - matchRange('A','Z'); - break; - } - case '_': - { - match('_'); - break; - } - case '$': - { - match('$'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - { - _loop276: - do { - switch ( LA(1)) { - case 'a': case 'b': case 'c': case 'd': - case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': - case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - { - matchRange('a','z'); - break; - } - case 'A': case 'B': case 'C': case 'D': - case 'E': case 'F': case 'G': case 'H': - case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': - case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - { - matchRange('A','Z'); - break; - } - case '_': - { - match('_'); - break; - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - { - matchRange('0','9'); - break; - } - case '$': - { - match('$'); - break; - } - default: - { - break _loop276; - } - } - } while (true); - } - _ttype = testLiteralsTable(_ttype); - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - public final void mNUM_INT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = NUM_INT; - int _saveIndex; - Token f1=null; - Token f2=null; - Token f3=null; - Token f4=null; - boolean isDecimal=false; Token t=null; - - switch ( LA(1)) { - case '.': - { - match('.'); - _ttype = DOT; - { - if (((LA(1) >= '0' && LA(1) <= '9'))) { - { - int _cnt280=0; - _loop280: - do { - if (((LA(1) >= '0' && LA(1) <= '9'))) { - matchRange('0','9'); - } - else { - if ( _cnt280>=1 ) { break _loop280; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - - _cnt280++; - } while (true); - } - { - if ((LA(1)=='E'||LA(1)=='e')) { - mEXPONENT(false); - } - else { - } - - } - { - if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { - mFLOAT_SUFFIX(true); - f1=_returnToken; - t=f1; - } - else { - } - - } - - if (t != null && t.getText().toUpperCase().indexOf('F')>=0) { - _ttype = NUM_FLOAT; - } - else { - _ttype = NUM_DOUBLE; // assume double - } - - } - else { - } - - } - break; - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - { - { - switch ( LA(1)) { - case '0': - { - match('0'); - isDecimal = true; - { - switch ( LA(1)) { - case 'X': case 'x': - { - { - switch ( LA(1)) { - case 'x': - { - match('x'); - break; - } - case 'X': - { - match('X'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - { - int _cnt287=0; - _loop287: - do { - if ((_tokenSet_4.member(LA(1))) && (true) && (true) && (true)) { - mHEX_DIGIT(false); - } - else { - if ( _cnt287>=1 ) { break _loop287; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - - _cnt287++; - } while (true); - } - break; - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - { - { - int _cnt289=0; - _loop289: - do { - if (((LA(1) >= '0' && LA(1) <= '7'))) { - matchRange('0','7'); - } - else { - if ( _cnt289>=1 ) { break _loop289; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - - _cnt289++; - } while (true); - } - break; - } - default: - { - } - } - } - break; - } - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': - case '9': - { - { - matchRange('1','9'); - } - { - _loop292: - do { - if (((LA(1) >= '0' && LA(1) <= '9'))) { - matchRange('0','9'); - } - else { - break _loop292; - } - - } while (true); - } - isDecimal=true; - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - { - if ((LA(1)=='L'||LA(1)=='l')) { - { - switch ( LA(1)) { - case 'l': - { - match('l'); - break; - } - case 'L': - { - match('L'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - _ttype = NUM_LONG; - } - else if (((LA(1)=='.'||LA(1)=='D'||LA(1)=='E'||LA(1)=='F'||LA(1)=='d'||LA(1)=='e'||LA(1)=='f'))&&(isDecimal)) { - { - switch ( LA(1)) { - case '.': - { - match('.'); - { - _loop297: - do { - if (((LA(1) >= '0' && LA(1) <= '9'))) { - matchRange('0','9'); - } - else { - break _loop297; - } - - } while (true); - } - { - if ((LA(1)=='E'||LA(1)=='e')) { - mEXPONENT(false); - } - else { - } - - } - { - if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { - mFLOAT_SUFFIX(true); - f2=_returnToken; - t=f2; - } - else { - } - - } - break; - } - case 'E': case 'e': - { - mEXPONENT(false); - { - if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { - mFLOAT_SUFFIX(true); - f3=_returnToken; - t=f3; - } - else { - } - - } - break; - } - case 'D': case 'F': case 'd': case 'f': - { - mFLOAT_SUFFIX(true); - f4=_returnToken; - t=f4; - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - - if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) { - _ttype = NUM_FLOAT; - } - else { - _ttype = NUM_DOUBLE; // assume double - } - - } - else { - } - - } - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - protected final void mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = EXPONENT; - int _saveIndex; - - { - switch ( LA(1)) { - case 'e': - { - match('e'); - break; - } - case 'E': - { - match('E'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - { - switch ( LA(1)) { - case '+': - { - match('+'); - break; - } - case '-': - { - match('-'); - break; - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - { - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - } - { - int _cnt305=0; - _loop305: - do { - if (((LA(1) >= '0' && LA(1) <= '9'))) { - matchRange('0','9'); - } - else { - if ( _cnt305>=1 ) { break _loop305; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} - } - - _cnt305++; - } while (true); - } - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - protected final void mFLOAT_SUFFIX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { - int _ttype; Token _token=null; int _begin=text.length(); - _ttype = FLOAT_SUFFIX; - int _saveIndex; - - switch ( LA(1)) { - case 'f': - { - match('f'); - break; - } - case 'F': - { - match('F'); - break; - } - case 'd': - { - match('d'); - break; - } - case 'D': - { - match('D'); - break; - } - default: - { - throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); - } - } - if ( _createToken && _token==null && _ttype!=Token.SKIP ) { - _token = makeToken(_ttype); - _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); - } - _returnToken = _token; - } - - - private static final long[] mk_tokenSet_0() { - long[] data = new long[2048]; - data[0]=-9224L; - for (int i = 1; i<=1023; i++) { data[i]=-1L; } - return data; - } - public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); - private static final long[] mk_tokenSet_1() { - long[] data = new long[2048]; - data[0]=-4398046520328L; - for (int i = 1; i<=1023; i++) { data[i]=-1L; } - return data; - } - public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); - private static final long[] mk_tokenSet_2() { - long[] data = new long[2048]; - data[0]=-549755813896L; - data[1]=-268435457L; - for (int i = 2; i<=1023; i++) { data[i]=-1L; } - return data; - } - public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); - private static final long[] mk_tokenSet_3() { - long[] data = new long[2048]; - data[0]=-17179869192L; - data[1]=-268435457L; - for (int i = 2; i<=1023; i++) { data[i]=-1L; } - return data; - } - public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); - private static final long[] mk_tokenSet_4() { - long[] data = new long[1025]; - data[0]=287948901175001088L; - data[1]=541165879422L; - return data; - } - public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4()); - - } diff --git a/app/preproc/JavaRecognizer.java b/app/preproc/JavaRecognizer.java deleted file mode 100644 index 0226f1794..000000000 --- a/app/preproc/JavaRecognizer.java +++ /dev/null @@ -1,5050 +0,0 @@ -// $ANTLR 2.7.2: "java.g" -> "JavaRecognizer.java"$ - -package antlr.java; - -import antlr.TokenBuffer; -import antlr.TokenStreamException; -import antlr.TokenStreamIOException; -import antlr.ANTLRException; -import antlr.LLkParser; -import antlr.Token; -import antlr.TokenStream; -import antlr.RecognitionException; -import antlr.NoViableAltException; -import antlr.MismatchedTokenException; -import antlr.SemanticException; -import antlr.ParserSharedInputState; -import antlr.collections.impl.BitSet; -import antlr.collections.AST; -import java.util.Hashtable; -import antlr.ASTFactory; -import antlr.ASTPair; -import antlr.collections.impl.ASTArray; - -/** Java 1.3 Recognizer - * - * Run 'java Main [-showtree] directory-full-of-java-files' - * - * [The -showtree option pops up a Swing frame that shows - * the AST constructed from the parser.] - * - * Run 'java Main ' - * - * Contributing authors: - * John Mitchell johnm@non.net - * Terence Parr parrt@magelang.com - * John Lilley jlilley@empathy.com - * Scott Stanchfield thetick@magelang.com - * Markus Mohnen mohnen@informatik.rwth-aachen.de - * Peter Williams pete.williams@sun.com - * Allan Jacobs Allan.Jacobs@eng.sun.com - * Steve Messick messick@redhills.com - * John Pybus john@pybus.org - * - * Version 1.00 December 9, 1997 -- initial release - * Version 1.01 December 10, 1997 - * fixed bug in octal def (0..7 not 0..8) - * Version 1.10 August 1998 (parrt) - * added tree construction - * fixed definition of WS,comments for mac,pc,unix newlines - * added unary plus - * Version 1.11 (Nov 20, 1998) - * Added "shutup" option to turn off last ambig warning. - * Fixed inner class def to allow named class defs as statements - * synchronized requires compound not simple statement - * add [] after builtInType DOT class in primaryExpression - * "const" is reserved but not valid..removed from modifiers - * Version 1.12 (Feb 2, 1999) - * Changed LITERAL_xxx to xxx in tree grammar. - * Updated java.g to use tokens {...} now for 2.6.0 (new feature). - * - * Version 1.13 (Apr 23, 1999) - * Didn't have (stat)? for else clause in tree parser. - * Didn't gen ASTs for interface extends. Updated tree parser too. - * Updated to 2.6.0. - * Version 1.14 (Jun 20, 1999) - * Allowed final/abstract on local classes. - * Removed local interfaces from methods - * Put instanceof precedence where it belongs...in relationalExpr - * It also had expr not type as arg; fixed it. - * Missing ! on SEMI in classBlock - * fixed: (expr) + "string" was parsed incorrectly (+ as unary plus). - * fixed: didn't like Object[].class in parser or tree parser - * Version 1.15 (Jun 26, 1999) - * Screwed up rule with instanceof in it. :( Fixed. - * Tree parser didn't like (expr).something; fixed. - * Allowed multiple inheritance in tree grammar. oops. - * Version 1.16 (August 22, 1999) - * Extending an interface built a wacky tree: had extra EXTENDS. - * Tree grammar didn't allow multiple superinterfaces. - * Tree grammar didn't allow empty var initializer: {} - * Version 1.17 (October 12, 1999) - * ESC lexer rule allowed 399 max not 377 max. - * java.tree.g didn't handle the expression of synchronized - * statements. - * Version 1.18 (August 12, 2001) - * Terence updated to Java 2 Version 1.3 by - * observing/combining work of Allan Jacobs and Steve - * Messick. Handles 1.3 src. Summary: - * o primary didn't include boolean.class kind of thing - * o constructor calls parsed explicitly now: - * see explicitConstructorInvocation - * o add strictfp modifier - * o missing objBlock after new expression in tree grammar - * o merged local class definition alternatives, moved after declaration - * o fixed problem with ClassName.super.field - * o reordered some alternatives to make things more efficient - * o long and double constants were not differentiated from int/float - * o whitespace rule was inefficient: matched only one char - * o add an examples directory with some nasty 1.3 cases - * o made Main.java use buffered IO and a Reader for Unicode support - * o supports UNICODE? - * Using Unicode charVocabulay makes code file big, but only - * in the bitsets at the end. I need to make ANTLR generate - * unicode bitsets more efficiently. - * Version 1.19 (April 25, 2002) - * Terence added in nice fixes by John Pybus concerning floating - * constants and problems with super() calls. John did a nice - * reorg of the primary/postfix expression stuff to read better - * and makes f.g.super() parse properly (it was METHOD_CALL not - * a SUPER_CTOR_CALL). Also: - * - * o "finally" clause was a root...made it a child of "try" - * o Added stuff for asserts too for Java 1.4, but *commented out* - * as it is not backward compatible. - * - * Version 1.20 (October 27, 2002) - * - * Terence ended up reorging John Pybus' stuff to - * remove some nondeterminisms and some syntactic predicates. - * Note that the grammar is stricter now; e.g., this(...) must - * be the first statement. - * - * Trinary ?: operator wasn't working as array name: - * (isBig ? bigDigits : digits)[i]; - * - * Checked parser/tree parser on source for - * Resin-2.0.5, jive-2.1.1, jdk 1.3.1, Lucene, antlr 2.7.2a4, - * and the 110k-line jGuru server source. - * - * This grammar is in the PUBLIC DOMAIN - */ -public class JavaRecognizer extends antlr.LLkParser implements JavaTokenTypes - { - -protected JavaRecognizer(TokenBuffer tokenBuf, int k) { - super(tokenBuf,k); - tokenNames = _tokenNames; - buildTokenTypeASTClassMap(); - astFactory = new ASTFactory(getTokenTypeToASTClassMap()); -} - -public JavaRecognizer(TokenBuffer tokenBuf) { - this(tokenBuf,2); -} - -protected JavaRecognizer(TokenStream lexer, int k) { - super(lexer,k); - tokenNames = _tokenNames; - buildTokenTypeASTClassMap(); - astFactory = new ASTFactory(getTokenTypeToASTClassMap()); -} - -public JavaRecognizer(TokenStream lexer) { - this(lexer,2); -} - -public JavaRecognizer(ParserSharedInputState state) { - super(state,2); - tokenNames = _tokenNames; - buildTokenTypeASTClassMap(); - astFactory = new ASTFactory(getTokenTypeToASTClassMap()); -} - - public final void compilationUnit() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST compilationUnit_AST = null; - - { - switch ( LA(1)) { - case LITERAL_package: - { - packageDefinition(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case EOF: - case FINAL: - case ABSTRACT: - case STRICTFP: - case SEMI: - case LITERAL_import: - case LITERAL_private: - case LITERAL_public: - case LITERAL_protected: - case LITERAL_static: - case LITERAL_transient: - case LITERAL_native: - case LITERAL_threadsafe: - case LITERAL_synchronized: - case LITERAL_volatile: - case LITERAL_class: - case LITERAL_interface: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - { - _loop4: - do { - if ((LA(1)==LITERAL_import)) { - importDefinition(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop4; - } - - } while (true); - } - { - _loop6: - do { - if ((_tokenSet_0.member(LA(1)))) { - typeDefinition(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop6; - } - - } while (true); - } - match(Token.EOF_TYPE); - compilationUnit_AST = (AST)currentAST.root; - returnAST = compilationUnit_AST; - } - - public final void packageDefinition() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST packageDefinition_AST = null; - Token p = null; - AST p_AST = null; - - try { // for error handling - p = LT(1); - p_AST = astFactory.create(p); - astFactory.makeASTRoot(currentAST, p_AST); - match(LITERAL_package); - if ( inputState.guessing==0 ) { - p_AST.setType(PACKAGE_DEF); - } - identifier(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - packageDefinition_AST = (AST)currentAST.root; - } - catch (RecognitionException ex) { - if (inputState.guessing==0) { - reportError(ex); - consume(); - consumeUntil(_tokenSet_1); - } else { - throw ex; - } - } - returnAST = packageDefinition_AST; - } - - public final void importDefinition() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST importDefinition_AST = null; - Token i = null; - AST i_AST = null; - - try { // for error handling - i = LT(1); - i_AST = astFactory.create(i); - astFactory.makeASTRoot(currentAST, i_AST); - match(LITERAL_import); - if ( inputState.guessing==0 ) { - i_AST.setType(IMPORT); - } - identifierStar(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - importDefinition_AST = (AST)currentAST.root; - } - catch (RecognitionException ex) { - if (inputState.guessing==0) { - reportError(ex); - consume(); - consumeUntil(_tokenSet_1); - } else { - throw ex; - } - } - returnAST = importDefinition_AST; - } - - public final void typeDefinition() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST typeDefinition_AST = null; - AST m_AST = null; - - try { // for error handling - switch ( LA(1)) { - case FINAL: - case ABSTRACT: - case STRICTFP: - case LITERAL_private: - case LITERAL_public: - case LITERAL_protected: - case LITERAL_static: - case LITERAL_transient: - case LITERAL_native: - case LITERAL_threadsafe: - case LITERAL_synchronized: - case LITERAL_volatile: - case LITERAL_class: - case LITERAL_interface: - { - modifiers(); - m_AST = (AST)returnAST; - { - switch ( LA(1)) { - case LITERAL_class: - { - classDefinition(m_AST); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case LITERAL_interface: - { - interfaceDefinition(m_AST); - astFactory.addASTChild(currentAST, returnAST); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - typeDefinition_AST = (AST)currentAST.root; - break; - } - case SEMI: - { - match(SEMI); - typeDefinition_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - catch (RecognitionException ex) { - if (inputState.guessing==0) { - reportError(ex); - consume(); - consumeUntil(_tokenSet_2); - } else { - throw ex; - } - } - returnAST = typeDefinition_AST; - } - - public final void identifier() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST identifier_AST = null; - - AST tmp5_AST = null; - tmp5_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp5_AST); - match(IDENT); - { - _loop23: - do { - if ((LA(1)==DOT)) { - AST tmp6_AST = null; - tmp6_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp6_AST); - match(DOT); - AST tmp7_AST = null; - tmp7_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp7_AST); - match(IDENT); - } - else { - break _loop23; - } - - } while (true); - } - identifier_AST = (AST)currentAST.root; - returnAST = identifier_AST; - } - - public final void identifierStar() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST identifierStar_AST = null; - - AST tmp8_AST = null; - tmp8_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp8_AST); - match(IDENT); - { - _loop26: - do { - if ((LA(1)==DOT) && (LA(2)==IDENT)) { - AST tmp9_AST = null; - tmp9_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp9_AST); - match(DOT); - AST tmp10_AST = null; - tmp10_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp10_AST); - match(IDENT); - } - else { - break _loop26; - } - - } while (true); - } - { - switch ( LA(1)) { - case DOT: - { - AST tmp11_AST = null; - tmp11_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp11_AST); - match(DOT); - AST tmp12_AST = null; - tmp12_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp12_AST); - match(STAR); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - identifierStar_AST = (AST)currentAST.root; - returnAST = identifierStar_AST; - } - - public final void modifiers() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST modifiers_AST = null; - - { - _loop30: - do { - if ((_tokenSet_3.member(LA(1)))) { - modifier(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop30; - } - - } while (true); - } - if ( inputState.guessing==0 ) { - modifiers_AST = (AST)currentAST.root; - modifiers_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(MODIFIERS,"MODIFIERS")).add(modifiers_AST)); - currentAST.root = modifiers_AST; - currentAST.child = modifiers_AST!=null &&modifiers_AST.getFirstChild()!=null ? - modifiers_AST.getFirstChild() : modifiers_AST; - currentAST.advanceChildToEnd(); - } - modifiers_AST = (AST)currentAST.root; - returnAST = modifiers_AST; - } - - public final void classDefinition( - AST modifiers - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST classDefinition_AST = null; - AST sc_AST = null; - AST ic_AST = null; - AST cb_AST = null; - - match(LITERAL_class); - AST tmp14_AST = null; - tmp14_AST = astFactory.create(LT(1)); - match(IDENT); - superClassClause(); - sc_AST = (AST)returnAST; - implementsClause(); - ic_AST = (AST)returnAST; - classBlock(); - cb_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - classDefinition_AST = (AST)currentAST.root; - classDefinition_AST = (AST)astFactory.make( (new ASTArray(6)).add(astFactory.create(CLASS_DEF,"CLASS_DEF")).add(modifiers).add(tmp14_AST).add(sc_AST).add(ic_AST).add(cb_AST)); - currentAST.root = classDefinition_AST; - currentAST.child = classDefinition_AST!=null &&classDefinition_AST.getFirstChild()!=null ? - classDefinition_AST.getFirstChild() : classDefinition_AST; - currentAST.advanceChildToEnd(); - } - returnAST = classDefinition_AST; - } - - public final void interfaceDefinition( - AST modifiers - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST interfaceDefinition_AST = null; - AST ie_AST = null; - AST cb_AST = null; - - match(LITERAL_interface); - AST tmp16_AST = null; - tmp16_AST = astFactory.create(LT(1)); - match(IDENT); - interfaceExtends(); - ie_AST = (AST)returnAST; - classBlock(); - cb_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - interfaceDefinition_AST = (AST)currentAST.root; - interfaceDefinition_AST = (AST)astFactory.make( (new ASTArray(5)).add(astFactory.create(INTERFACE_DEF,"INTERFACE_DEF")).add(modifiers).add(tmp16_AST).add(ie_AST).add(cb_AST)); - currentAST.root = interfaceDefinition_AST; - currentAST.child = interfaceDefinition_AST!=null &&interfaceDefinition_AST.getFirstChild()!=null ? - interfaceDefinition_AST.getFirstChild() : interfaceDefinition_AST; - currentAST.advanceChildToEnd(); - } - returnAST = interfaceDefinition_AST; - } - -/** A declaration is the creation of a reference or primitive-type variable - * Create a separate Type/Var tree for each var in the var list. - */ - public final void declaration() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST declaration_AST = null; - AST m_AST = null; - AST t_AST = null; - AST v_AST = null; - - modifiers(); - m_AST = (AST)returnAST; - typeSpec(false); - t_AST = (AST)returnAST; - variableDefinitions(m_AST,t_AST); - v_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - declaration_AST = (AST)currentAST.root; - declaration_AST = v_AST; - currentAST.root = declaration_AST; - currentAST.child = declaration_AST!=null &&declaration_AST.getFirstChild()!=null ? - declaration_AST.getFirstChild() : declaration_AST; - currentAST.advanceChildToEnd(); - } - returnAST = declaration_AST; - } - - public final void typeSpec( - boolean addImagNode - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST typeSpec_AST = null; - - switch ( LA(1)) { - case IDENT: - { - classTypeSpec(addImagNode); - astFactory.addASTChild(currentAST, returnAST); - typeSpec_AST = (AST)currentAST.root; - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - { - builtInTypeSpec(addImagNode); - astFactory.addASTChild(currentAST, returnAST); - typeSpec_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = typeSpec_AST; - } - - public final void variableDefinitions( - AST mods, AST t - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST variableDefinitions_AST = null; - - variableDeclarator(getASTFactory().dupTree(mods), - getASTFactory().dupTree(t)); - astFactory.addASTChild(currentAST, returnAST); - { - _loop59: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - variableDeclarator(getASTFactory().dupTree(mods), - getASTFactory().dupTree(t)); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop59; - } - - } while (true); - } - variableDefinitions_AST = (AST)currentAST.root; - returnAST = variableDefinitions_AST; - } - - public final void classTypeSpec( - boolean addImagNode - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST classTypeSpec_AST = null; - Token lb = null; - AST lb_AST = null; - - identifier(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop15: - do { - if ((LA(1)==LBRACK)) { - lb = LT(1); - lb_AST = astFactory.create(lb); - astFactory.makeASTRoot(currentAST, lb_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lb_AST.setType(ARRAY_DECLARATOR); - } - match(RBRACK); - } - else { - break _loop15; - } - - } while (true); - } - if ( inputState.guessing==0 ) { - classTypeSpec_AST = (AST)currentAST.root; - - if ( addImagNode ) { - classTypeSpec_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(classTypeSpec_AST)); - } - - currentAST.root = classTypeSpec_AST; - currentAST.child = classTypeSpec_AST!=null &&classTypeSpec_AST.getFirstChild()!=null ? - classTypeSpec_AST.getFirstChild() : classTypeSpec_AST; - currentAST.advanceChildToEnd(); - } - classTypeSpec_AST = (AST)currentAST.root; - returnAST = classTypeSpec_AST; - } - - public final void builtInTypeSpec( - boolean addImagNode - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST builtInTypeSpec_AST = null; - Token lb = null; - AST lb_AST = null; - - builtInType(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop18: - do { - if ((LA(1)==LBRACK)) { - lb = LT(1); - lb_AST = astFactory.create(lb); - astFactory.makeASTRoot(currentAST, lb_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lb_AST.setType(ARRAY_DECLARATOR); - } - match(RBRACK); - } - else { - break _loop18; - } - - } while (true); - } - if ( inputState.guessing==0 ) { - builtInTypeSpec_AST = (AST)currentAST.root; - - if ( addImagNode ) { - builtInTypeSpec_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(builtInTypeSpec_AST)); - } - - currentAST.root = builtInTypeSpec_AST; - currentAST.child = builtInTypeSpec_AST!=null &&builtInTypeSpec_AST.getFirstChild()!=null ? - builtInTypeSpec_AST.getFirstChild() : builtInTypeSpec_AST; - currentAST.advanceChildToEnd(); - } - builtInTypeSpec_AST = (AST)currentAST.root; - returnAST = builtInTypeSpec_AST; - } - - public final void builtInType() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST builtInType_AST = null; - - switch ( LA(1)) { - case LITERAL_void: - { - AST tmp20_AST = null; - tmp20_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp20_AST); - match(LITERAL_void); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_boolean: - { - AST tmp21_AST = null; - tmp21_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp21_AST); - match(LITERAL_boolean); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_byte: - { - AST tmp22_AST = null; - tmp22_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp22_AST); - match(LITERAL_byte); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_char: - { - AST tmp23_AST = null; - tmp23_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp23_AST); - match(LITERAL_char); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_short: - { - AST tmp24_AST = null; - tmp24_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp24_AST); - match(LITERAL_short); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_int: - { - AST tmp25_AST = null; - tmp25_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp25_AST); - match(LITERAL_int); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_float: - { - AST tmp26_AST = null; - tmp26_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp26_AST); - match(LITERAL_float); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_long: - { - AST tmp27_AST = null; - tmp27_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp27_AST); - match(LITERAL_long); - builtInType_AST = (AST)currentAST.root; - break; - } - case LITERAL_double: - { - AST tmp28_AST = null; - tmp28_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp28_AST); - match(LITERAL_double); - builtInType_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = builtInType_AST; - } - - public final void type() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST type_AST = null; - - switch ( LA(1)) { - case IDENT: - { - identifier(); - astFactory.addASTChild(currentAST, returnAST); - type_AST = (AST)currentAST.root; - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - { - builtInType(); - astFactory.addASTChild(currentAST, returnAST); - type_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = type_AST; - } - - public final void modifier() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST modifier_AST = null; - - switch ( LA(1)) { - case LITERAL_private: - { - AST tmp29_AST = null; - tmp29_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp29_AST); - match(LITERAL_private); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_public: - { - AST tmp30_AST = null; - tmp30_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp30_AST); - match(LITERAL_public); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_protected: - { - AST tmp31_AST = null; - tmp31_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp31_AST); - match(LITERAL_protected); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_static: - { - AST tmp32_AST = null; - tmp32_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp32_AST); - match(LITERAL_static); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_transient: - { - AST tmp33_AST = null; - tmp33_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp33_AST); - match(LITERAL_transient); - modifier_AST = (AST)currentAST.root; - break; - } - case FINAL: - { - AST tmp34_AST = null; - tmp34_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp34_AST); - match(FINAL); - modifier_AST = (AST)currentAST.root; - break; - } - case ABSTRACT: - { - AST tmp35_AST = null; - tmp35_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp35_AST); - match(ABSTRACT); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_native: - { - AST tmp36_AST = null; - tmp36_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp36_AST); - match(LITERAL_native); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_threadsafe: - { - AST tmp37_AST = null; - tmp37_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp37_AST); - match(LITERAL_threadsafe); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_synchronized: - { - AST tmp38_AST = null; - tmp38_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp38_AST); - match(LITERAL_synchronized); - modifier_AST = (AST)currentAST.root; - break; - } - case LITERAL_volatile: - { - AST tmp39_AST = null; - tmp39_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp39_AST); - match(LITERAL_volatile); - modifier_AST = (AST)currentAST.root; - break; - } - case STRICTFP: - { - AST tmp40_AST = null; - tmp40_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp40_AST); - match(STRICTFP); - modifier_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = modifier_AST; - } - - public final void superClassClause() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST superClassClause_AST = null; - AST id_AST = null; - - { - switch ( LA(1)) { - case LITERAL_extends: - { - match(LITERAL_extends); - identifier(); - id_AST = (AST)returnAST; - break; - } - case LCURLY: - case LITERAL_implements: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - superClassClause_AST = (AST)currentAST.root; - superClassClause_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXTENDS_CLAUSE,"EXTENDS_CLAUSE")).add(id_AST)); - currentAST.root = superClassClause_AST; - currentAST.child = superClassClause_AST!=null &&superClassClause_AST.getFirstChild()!=null ? - superClassClause_AST.getFirstChild() : superClassClause_AST; - currentAST.advanceChildToEnd(); - } - returnAST = superClassClause_AST; - } - - public final void implementsClause() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST implementsClause_AST = null; - Token i = null; - AST i_AST = null; - - { - switch ( LA(1)) { - case LITERAL_implements: - { - i = LT(1); - i_AST = astFactory.create(i); - match(LITERAL_implements); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop46: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop46; - } - - } while (true); - } - break; - } - case LCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - implementsClause_AST = (AST)currentAST.root; - implementsClause_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(IMPLEMENTS_CLAUSE,"IMPLEMENTS_CLAUSE")).add(implementsClause_AST)); - currentAST.root = implementsClause_AST; - currentAST.child = implementsClause_AST!=null &&implementsClause_AST.getFirstChild()!=null ? - implementsClause_AST.getFirstChild() : implementsClause_AST; - currentAST.advanceChildToEnd(); - } - implementsClause_AST = (AST)currentAST.root; - returnAST = implementsClause_AST; - } - - public final void classBlock() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST classBlock_AST = null; - - match(LCURLY); - { - _loop38: - do { - switch ( LA(1)) { - case FINAL: - case ABSTRACT: - case STRICTFP: - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LITERAL_private: - case LITERAL_public: - case LITERAL_protected: - case LITERAL_static: - case LITERAL_transient: - case LITERAL_native: - case LITERAL_threadsafe: - case LITERAL_synchronized: - case LITERAL_volatile: - case LITERAL_class: - case LITERAL_interface: - case LCURLY: - { - field(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - { - match(SEMI); - break; - } - default: - { - break _loop38; - } - } - } while (true); - } - match(RCURLY); - if ( inputState.guessing==0 ) { - classBlock_AST = (AST)currentAST.root; - classBlock_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(OBJBLOCK,"OBJBLOCK")).add(classBlock_AST)); - currentAST.root = classBlock_AST; - currentAST.child = classBlock_AST!=null &&classBlock_AST.getFirstChild()!=null ? - classBlock_AST.getFirstChild() : classBlock_AST; - currentAST.advanceChildToEnd(); - } - classBlock_AST = (AST)currentAST.root; - returnAST = classBlock_AST; - } - - public final void interfaceExtends() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST interfaceExtends_AST = null; - Token e = null; - AST e_AST = null; - - { - switch ( LA(1)) { - case LITERAL_extends: - { - e = LT(1); - e_AST = astFactory.create(e); - match(LITERAL_extends); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop42: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop42; - } - - } while (true); - } - break; - } - case LCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - interfaceExtends_AST = (AST)currentAST.root; - interfaceExtends_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXTENDS_CLAUSE,"EXTENDS_CLAUSE")).add(interfaceExtends_AST)); - currentAST.root = interfaceExtends_AST; - currentAST.child = interfaceExtends_AST!=null &&interfaceExtends_AST.getFirstChild()!=null ? - interfaceExtends_AST.getFirstChild() : interfaceExtends_AST; - currentAST.advanceChildToEnd(); - } - interfaceExtends_AST = (AST)currentAST.root; - returnAST = interfaceExtends_AST; - } - - public final void field() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST field_AST = null; - AST mods_AST = null; - AST h_AST = null; - AST s_AST = null; - AST cd_AST = null; - AST id_AST = null; - AST t_AST = null; - AST param_AST = null; - AST rt_AST = null; - AST tc_AST = null; - AST s2_AST = null; - AST v_AST = null; - AST s3_AST = null; - AST s4_AST = null; - - if ((_tokenSet_4.member(LA(1))) && (_tokenSet_5.member(LA(2)))) { - modifiers(); - mods_AST = (AST)returnAST; - { - switch ( LA(1)) { - case LITERAL_class: - { - classDefinition(mods_AST); - cd_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = cd_AST; - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - break; - } - case LITERAL_interface: - { - interfaceDefinition(mods_AST); - id_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = id_AST; - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - break; - } - default: - if ((LA(1)==IDENT) && (LA(2)==LPAREN)) { - ctorHead(); - h_AST = (AST)returnAST; - constructorBody(); - s_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = (AST)astFactory.make( (new ASTArray(4)).add(astFactory.create(CTOR_DEF,"CTOR_DEF")).add(mods_AST).add(h_AST).add(s_AST)); - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - } - else if (((LA(1) >= LITERAL_void && LA(1) <= IDENT)) && (_tokenSet_6.member(LA(2)))) { - typeSpec(false); - t_AST = (AST)returnAST; - { - if ((LA(1)==IDENT) && (LA(2)==LPAREN)) { - AST tmp47_AST = null; - tmp47_AST = astFactory.create(LT(1)); - match(IDENT); - match(LPAREN); - parameterDeclarationList(); - param_AST = (AST)returnAST; - match(RPAREN); - declaratorBrackets(t_AST); - rt_AST = (AST)returnAST; - { - switch ( LA(1)) { - case LITERAL_throws: - { - throwsClause(); - tc_AST = (AST)returnAST; - break; - } - case SEMI: - case LCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - { - switch ( LA(1)) { - case LCURLY: - { - compoundStatement(); - s2_AST = (AST)returnAST; - break; - } - case SEMI: - { - AST tmp50_AST = null; - tmp50_AST = astFactory.create(LT(1)); - match(SEMI); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = (AST)astFactory.make( (new ASTArray(7)).add(astFactory.create(METHOD_DEF,"METHOD_DEF")).add(mods_AST).add((AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(rt_AST))).add(tmp47_AST).add(param_AST).add(tc_AST).add(s2_AST)); - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - } - else if ((LA(1)==IDENT) && (_tokenSet_7.member(LA(2)))) { - variableDefinitions(mods_AST,t_AST); - v_AST = (AST)returnAST; - AST tmp51_AST = null; - tmp51_AST = astFactory.create(LT(1)); - match(SEMI); - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = v_AST; - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - } - else if ((LA(1)==LITERAL_static) && (LA(2)==LCURLY)) { - match(LITERAL_static); - compoundStatement(); - s3_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(STATIC_INIT,"STATIC_INIT")).add(s3_AST)); - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - } - else if ((LA(1)==LCURLY)) { - compoundStatement(); - s4_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - field_AST = (AST)currentAST.root; - field_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(INSTANCE_INIT,"INSTANCE_INIT")).add(s4_AST)); - currentAST.root = field_AST; - currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ? - field_AST.getFirstChild() : field_AST; - currentAST.advanceChildToEnd(); - } - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - returnAST = field_AST; - } - - public final void ctorHead() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST ctorHead_AST = null; - - AST tmp53_AST = null; - tmp53_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp53_AST); - match(IDENT); - match(LPAREN); - parameterDeclarationList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - { - switch ( LA(1)) { - case LITERAL_throws: - { - throwsClause(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case LCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - ctorHead_AST = (AST)currentAST.root; - returnAST = ctorHead_AST; - } - - public final void constructorBody() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST constructorBody_AST = null; - Token lc = null; - AST lc_AST = null; - - lc = LT(1); - lc_AST = astFactory.create(lc); - astFactory.makeASTRoot(currentAST, lc_AST); - match(LCURLY); - if ( inputState.guessing==0 ) { - lc_AST.setType(SLIST); - } - { - if ((LA(1)==LITERAL_this||LA(1)==LITERAL_super) && (LA(2)==LPAREN)) { - explicitConstructorInvocation(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((_tokenSet_8.member(LA(1))) && (_tokenSet_9.member(LA(2)))) { - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - { - _loop55: - do { - if ((_tokenSet_10.member(LA(1)))) { - statement(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop55; - } - - } while (true); - } - match(RCURLY); - constructorBody_AST = (AST)currentAST.root; - returnAST = constructorBody_AST; - } - - public final void parameterDeclarationList() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST parameterDeclarationList_AST = null; - - { - switch ( LA(1)) { - case FINAL: - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - { - parameterDeclaration(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop80: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - parameterDeclaration(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop80; - } - - } while (true); - } - break; - } - case RPAREN: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - parameterDeclarationList_AST = (AST)currentAST.root; - parameterDeclarationList_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(PARAMETERS,"PARAMETERS")).add(parameterDeclarationList_AST)); - currentAST.root = parameterDeclarationList_AST; - currentAST.child = parameterDeclarationList_AST!=null &¶meterDeclarationList_AST.getFirstChild()!=null ? - parameterDeclarationList_AST.getFirstChild() : parameterDeclarationList_AST; - currentAST.advanceChildToEnd(); - } - parameterDeclarationList_AST = (AST)currentAST.root; - returnAST = parameterDeclarationList_AST; - } - - public final void declaratorBrackets( - AST typ - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST declaratorBrackets_AST = null; - Token lb = null; - AST lb_AST = null; - - if ( inputState.guessing==0 ) { - declaratorBrackets_AST = (AST)currentAST.root; - declaratorBrackets_AST=typ; - currentAST.root = declaratorBrackets_AST; - currentAST.child = declaratorBrackets_AST!=null &&declaratorBrackets_AST.getFirstChild()!=null ? - declaratorBrackets_AST.getFirstChild() : declaratorBrackets_AST; - currentAST.advanceChildToEnd(); - } - { - _loop63: - do { - if ((LA(1)==LBRACK)) { - lb = LT(1); - lb_AST = astFactory.create(lb); - astFactory.makeASTRoot(currentAST, lb_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lb_AST.setType(ARRAY_DECLARATOR); - } - match(RBRACK); - } - else { - break _loop63; - } - - } while (true); - } - declaratorBrackets_AST = (AST)currentAST.root; - returnAST = declaratorBrackets_AST; - } - - public final void throwsClause() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST throwsClause_AST = null; - - AST tmp59_AST = null; - tmp59_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp59_AST); - match(LITERAL_throws); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop76: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - identifier(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop76; - } - - } while (true); - } - throwsClause_AST = (AST)currentAST.root; - returnAST = throwsClause_AST; - } - - public final void compoundStatement() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST compoundStatement_AST = null; - Token lc = null; - AST lc_AST = null; - - lc = LT(1); - lc_AST = astFactory.create(lc); - astFactory.makeASTRoot(currentAST, lc_AST); - match(LCURLY); - if ( inputState.guessing==0 ) { - lc_AST.setType(SLIST); - } - { - _loop86: - do { - if ((_tokenSet_10.member(LA(1)))) { - statement(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop86; - } - - } while (true); - } - match(RCURLY); - compoundStatement_AST = (AST)currentAST.root; - returnAST = compoundStatement_AST; - } - -/** Catch obvious constructor calls, but not the expr.super(...) calls */ - public final void explicitConstructorInvocation() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST explicitConstructorInvocation_AST = null; - Token lp1 = null; - AST lp1_AST = null; - Token lp2 = null; - AST lp2_AST = null; - - switch ( LA(1)) { - case LITERAL_this: - { - match(LITERAL_this); - lp1 = LT(1); - lp1_AST = astFactory.create(lp1); - astFactory.makeASTRoot(currentAST, lp1_AST); - match(LPAREN); - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - match(SEMI); - if ( inputState.guessing==0 ) { - lp1_AST.setType(CTOR_CALL); - } - explicitConstructorInvocation_AST = (AST)currentAST.root; - break; - } - case LITERAL_super: - { - match(LITERAL_super); - lp2 = LT(1); - lp2_AST = astFactory.create(lp2); - astFactory.makeASTRoot(currentAST, lp2_AST); - match(LPAREN); - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - match(SEMI); - if ( inputState.guessing==0 ) { - lp2_AST.setType(SUPER_CTOR_CALL); - } - explicitConstructorInvocation_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = explicitConstructorInvocation_AST; - } - - public final void statement() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST statement_AST = null; - AST m_AST = null; - Token c = null; - AST c_AST = null; - Token s = null; - AST s_AST = null; - - switch ( LA(1)) { - case LCURLY: - { - compoundStatement(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_if: - { - AST tmp68_AST = null; - tmp68_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp68_AST); - match(LITERAL_if); - match(LPAREN); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - statement(); - astFactory.addASTChild(currentAST, returnAST); - { - if ((LA(1)==LITERAL_else) && (_tokenSet_10.member(LA(2)))) { - match(LITERAL_else); - statement(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((_tokenSet_11.member(LA(1))) && (_tokenSet_12.member(LA(2)))) { - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_for: - { - AST tmp72_AST = null; - tmp72_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp72_AST); - match(LITERAL_for); - match(LPAREN); - forInit(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - forCond(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - forIter(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - statement(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_while: - { - AST tmp77_AST = null; - tmp77_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp77_AST); - match(LITERAL_while); - match(LPAREN); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - statement(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_do: - { - AST tmp80_AST = null; - tmp80_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp80_AST); - match(LITERAL_do); - statement(); - astFactory.addASTChild(currentAST, returnAST); - match(LITERAL_while); - match(LPAREN); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_break: - { - AST tmp85_AST = null; - tmp85_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp85_AST); - match(LITERAL_break); - { - switch ( LA(1)) { - case IDENT: - { - AST tmp86_AST = null; - tmp86_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp86_AST); - match(IDENT); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_continue: - { - AST tmp88_AST = null; - tmp88_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp88_AST); - match(LITERAL_continue); - { - switch ( LA(1)) { - case IDENT: - { - AST tmp89_AST = null; - tmp89_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp89_AST); - match(IDENT); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_return: - { - AST tmp91_AST = null; - tmp91_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp91_AST); - match(LITERAL_return); - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_switch: - { - AST tmp93_AST = null; - tmp93_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp93_AST); - match(LITERAL_switch); - match(LPAREN); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - match(LCURLY); - { - _loop95: - do { - if ((LA(1)==LITERAL_case||LA(1)==LITERAL_default)) { - casesGroup(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop95; - } - - } while (true); - } - match(RCURLY); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_try: - { - tryBlock(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_throw: - { - AST tmp98_AST = null; - tmp98_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp98_AST); - match(LITERAL_throw); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case LITERAL_assert: - { - AST tmp100_AST = null; - tmp100_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp100_AST); - match(LITERAL_assert); - expression(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case COLON: - { - match(COLON); - expression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(SEMI); - statement_AST = (AST)currentAST.root; - break; - } - case SEMI: - { - s = LT(1); - s_AST = astFactory.create(s); - astFactory.addASTChild(currentAST, s_AST); - match(SEMI); - if ( inputState.guessing==0 ) { - s_AST.setType(EMPTY_STAT); - } - statement_AST = (AST)currentAST.root; - break; - } - default: - boolean synPredMatched89 = false; - if (((_tokenSet_13.member(LA(1))) && (_tokenSet_14.member(LA(2))))) { - int _m89 = mark(); - synPredMatched89 = true; - inputState.guessing++; - try { - { - declaration(); - } - } - catch (RecognitionException pe) { - synPredMatched89 = false; - } - rewind(_m89); - inputState.guessing--; - } - if ( synPredMatched89 ) { - declaration(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - statement_AST = (AST)currentAST.root; - } - else if ((_tokenSet_15.member(LA(1))) && (_tokenSet_16.member(LA(2)))) { - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(SEMI); - statement_AST = (AST)currentAST.root; - } - else if ((_tokenSet_17.member(LA(1))) && (_tokenSet_18.member(LA(2)))) { - modifiers(); - m_AST = (AST)returnAST; - classDefinition(m_AST); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - } - else if ((LA(1)==IDENT) && (LA(2)==COLON)) { - AST tmp105_AST = null; - tmp105_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp105_AST); - match(IDENT); - c = LT(1); - c_AST = astFactory.create(c); - astFactory.makeASTRoot(currentAST, c_AST); - match(COLON); - if ( inputState.guessing==0 ) { - c_AST.setType(LABELED_STAT); - } - statement(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - } - else if ((LA(1)==LITERAL_synchronized) && (LA(2)==LPAREN)) { - AST tmp106_AST = null; - tmp106_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp106_AST); - match(LITERAL_synchronized); - match(LPAREN); - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - compoundStatement(); - astFactory.addASTChild(currentAST, returnAST); - statement_AST = (AST)currentAST.root; - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = statement_AST; - } - - public final void argList() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST argList_AST = null; - - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expressionList(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case RPAREN: - { - if ( inputState.guessing==0 ) { - argList_AST = (AST)currentAST.root; - argList_AST = astFactory.create(ELIST,"ELIST"); - currentAST.root = argList_AST; - currentAST.child = argList_AST!=null &&argList_AST.getFirstChild()!=null ? - argList_AST.getFirstChild() : argList_AST; - currentAST.advanceChildToEnd(); - } - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - argList_AST = (AST)currentAST.root; - returnAST = argList_AST; - } - -/** Declaration of a variable. This can be a class/instance variable, - * or a local variable in a method - * It can also include possible initialization. - */ - public final void variableDeclarator( - AST mods, AST t - ) throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST variableDeclarator_AST = null; - Token id = null; - AST id_AST = null; - AST d_AST = null; - AST v_AST = null; - - id = LT(1); - id_AST = astFactory.create(id); - match(IDENT); - declaratorBrackets(t); - d_AST = (AST)returnAST; - varInitializer(); - v_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - variableDeclarator_AST = (AST)currentAST.root; - variableDeclarator_AST = (AST)astFactory.make( (new ASTArray(5)).add(astFactory.create(VARIABLE_DEF,"VARIABLE_DEF")).add(mods).add((AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(d_AST))).add(id_AST).add(v_AST)); - currentAST.root = variableDeclarator_AST; - currentAST.child = variableDeclarator_AST!=null &&variableDeclarator_AST.getFirstChild()!=null ? - variableDeclarator_AST.getFirstChild() : variableDeclarator_AST; - currentAST.advanceChildToEnd(); - } - returnAST = variableDeclarator_AST; - } - - public final void varInitializer() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST varInitializer_AST = null; - - { - switch ( LA(1)) { - case ASSIGN: - { - AST tmp109_AST = null; - tmp109_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp109_AST); - match(ASSIGN); - initializer(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - case COMMA: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - varInitializer_AST = (AST)currentAST.root; - returnAST = varInitializer_AST; - } - - public final void initializer() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST initializer_AST = null; - - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expression(); - astFactory.addASTChild(currentAST, returnAST); - initializer_AST = (AST)currentAST.root; - break; - } - case LCURLY: - { - arrayInitializer(); - astFactory.addASTChild(currentAST, returnAST); - initializer_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = initializer_AST; - } - - public final void arrayInitializer() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST arrayInitializer_AST = null; - Token lc = null; - AST lc_AST = null; - - lc = LT(1); - lc_AST = astFactory.create(lc); - astFactory.makeASTRoot(currentAST, lc_AST); - match(LCURLY); - if ( inputState.guessing==0 ) { - lc_AST.setType(ARRAY_INIT); - } - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LCURLY: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - initializer(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop69: - do { - if ((LA(1)==COMMA) && (_tokenSet_19.member(LA(2)))) { - match(COMMA); - initializer(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop69; - } - - } while (true); - } - { - switch ( LA(1)) { - case COMMA: - { - match(COMMA); - break; - } - case RCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - break; - } - case RCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(RCURLY); - arrayInitializer_AST = (AST)currentAST.root; - returnAST = arrayInitializer_AST; - } - - public final void expression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST expression_AST = null; - - assignmentExpression(); - astFactory.addASTChild(currentAST, returnAST); - if ( inputState.guessing==0 ) { - expression_AST = (AST)currentAST.root; - expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXPR,"EXPR")).add(expression_AST)); - currentAST.root = expression_AST; - currentAST.child = expression_AST!=null &&expression_AST.getFirstChild()!=null ? - expression_AST.getFirstChild() : expression_AST; - currentAST.advanceChildToEnd(); - } - expression_AST = (AST)currentAST.root; - returnAST = expression_AST; - } - - public final void parameterDeclaration() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST parameterDeclaration_AST = null; - AST pm_AST = null; - AST t_AST = null; - Token id = null; - AST id_AST = null; - AST pd_AST = null; - - parameterModifier(); - pm_AST = (AST)returnAST; - typeSpec(false); - t_AST = (AST)returnAST; - id = LT(1); - id_AST = astFactory.create(id); - match(IDENT); - declaratorBrackets(t_AST); - pd_AST = (AST)returnAST; - if ( inputState.guessing==0 ) { - parameterDeclaration_AST = (AST)currentAST.root; - parameterDeclaration_AST = (AST)astFactory.make( (new ASTArray(4)).add(astFactory.create(PARAMETER_DEF,"PARAMETER_DEF")).add(pm_AST).add((AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(pd_AST))).add(id_AST)); - currentAST.root = parameterDeclaration_AST; - currentAST.child = parameterDeclaration_AST!=null &¶meterDeclaration_AST.getFirstChild()!=null ? - parameterDeclaration_AST.getFirstChild() : parameterDeclaration_AST; - currentAST.advanceChildToEnd(); - } - returnAST = parameterDeclaration_AST; - } - - public final void parameterModifier() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST parameterModifier_AST = null; - Token f = null; - AST f_AST = null; - - { - switch ( LA(1)) { - case FINAL: - { - f = LT(1); - f_AST = astFactory.create(f); - astFactory.addASTChild(currentAST, f_AST); - match(FINAL); - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - parameterModifier_AST = (AST)currentAST.root; - parameterModifier_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(MODIFIERS,"MODIFIERS")).add(f_AST)); - currentAST.root = parameterModifier_AST; - currentAST.child = parameterModifier_AST!=null &¶meterModifier_AST.getFirstChild()!=null ? - parameterModifier_AST.getFirstChild() : parameterModifier_AST; - currentAST.advanceChildToEnd(); - } - parameterModifier_AST = (AST)currentAST.root; - returnAST = parameterModifier_AST; - } - - public final void forInit() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST forInit_AST = null; - - { - boolean synPredMatched108 = false; - if (((_tokenSet_13.member(LA(1))) && (_tokenSet_14.member(LA(2))))) { - int _m108 = mark(); - synPredMatched108 = true; - inputState.guessing++; - try { - { - declaration(); - } - } - catch (RecognitionException pe) { - synPredMatched108 = false; - } - rewind(_m108); - inputState.guessing--; - } - if ( synPredMatched108 ) { - declaration(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((_tokenSet_15.member(LA(1))) && (_tokenSet_20.member(LA(2)))) { - expressionList(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((LA(1)==SEMI)) { - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - if ( inputState.guessing==0 ) { - forInit_AST = (AST)currentAST.root; - forInit_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FOR_INIT,"FOR_INIT")).add(forInit_AST)); - currentAST.root = forInit_AST; - currentAST.child = forInit_AST!=null &&forInit_AST.getFirstChild()!=null ? - forInit_AST.getFirstChild() : forInit_AST; - currentAST.advanceChildToEnd(); - } - forInit_AST = (AST)currentAST.root; - returnAST = forInit_AST; - } - - public final void forCond() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST forCond_AST = null; - - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - forCond_AST = (AST)currentAST.root; - forCond_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FOR_CONDITION,"FOR_CONDITION")).add(forCond_AST)); - currentAST.root = forCond_AST; - currentAST.child = forCond_AST!=null &&forCond_AST.getFirstChild()!=null ? - forCond_AST.getFirstChild() : forCond_AST; - currentAST.advanceChildToEnd(); - } - forCond_AST = (AST)currentAST.root; - returnAST = forCond_AST; - } - - public final void forIter() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST forIter_AST = null; - - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expressionList(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case RPAREN: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - if ( inputState.guessing==0 ) { - forIter_AST = (AST)currentAST.root; - forIter_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FOR_ITERATOR,"FOR_ITERATOR")).add(forIter_AST)); - currentAST.root = forIter_AST; - currentAST.child = forIter_AST!=null &&forIter_AST.getFirstChild()!=null ? - forIter_AST.getFirstChild() : forIter_AST; - currentAST.advanceChildToEnd(); - } - forIter_AST = (AST)currentAST.root; - returnAST = forIter_AST; - } - - public final void casesGroup() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST casesGroup_AST = null; - - { - int _cnt99=0; - _loop99: - do { - if ((LA(1)==LITERAL_case||LA(1)==LITERAL_default) && (_tokenSet_21.member(LA(2)))) { - aCase(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - if ( _cnt99>=1 ) { break _loop99; } else {throw new NoViableAltException(LT(1), getFilename());} - } - - _cnt99++; - } while (true); - } - caseSList(); - astFactory.addASTChild(currentAST, returnAST); - if ( inputState.guessing==0 ) { - casesGroup_AST = (AST)currentAST.root; - casesGroup_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(CASE_GROUP,"CASE_GROUP")).add(casesGroup_AST)); - currentAST.root = casesGroup_AST; - currentAST.child = casesGroup_AST!=null &&casesGroup_AST.getFirstChild()!=null ? - casesGroup_AST.getFirstChild() : casesGroup_AST; - currentAST.advanceChildToEnd(); - } - casesGroup_AST = (AST)currentAST.root; - returnAST = casesGroup_AST; - } - - public final void tryBlock() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST tryBlock_AST = null; - - AST tmp113_AST = null; - tmp113_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp113_AST); - match(LITERAL_try); - compoundStatement(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop115: - do { - if ((LA(1)==LITERAL_catch)) { - handler(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop115; - } - - } while (true); - } - { - switch ( LA(1)) { - case LITERAL_finally: - { - finallyClause(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case FINAL: - case ABSTRACT: - case STRICTFP: - case SEMI: - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LITERAL_private: - case LITERAL_public: - case LITERAL_protected: - case LITERAL_static: - case LITERAL_transient: - case LITERAL_native: - case LITERAL_threadsafe: - case LITERAL_synchronized: - case LITERAL_volatile: - case LITERAL_class: - case LCURLY: - case RCURLY: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case LITERAL_if: - case LITERAL_else: - case LITERAL_for: - case LITERAL_while: - case LITERAL_do: - case LITERAL_break: - case LITERAL_continue: - case LITERAL_return: - case LITERAL_switch: - case LITERAL_throw: - case LITERAL_assert: - case LITERAL_case: - case LITERAL_default: - case LITERAL_try: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - tryBlock_AST = (AST)currentAST.root; - returnAST = tryBlock_AST; - } - - public final void aCase() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST aCase_AST = null; - - { - switch ( LA(1)) { - case LITERAL_case: - { - AST tmp114_AST = null; - tmp114_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp114_AST); - match(LITERAL_case); - expression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case LITERAL_default: - { - AST tmp115_AST = null; - tmp115_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp115_AST); - match(LITERAL_default); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(COLON); - aCase_AST = (AST)currentAST.root; - returnAST = aCase_AST; - } - - public final void caseSList() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST caseSList_AST = null; - - { - _loop104: - do { - if ((_tokenSet_10.member(LA(1)))) { - statement(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop104; - } - - } while (true); - } - if ( inputState.guessing==0 ) { - caseSList_AST = (AST)currentAST.root; - caseSList_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(SLIST,"SLIST")).add(caseSList_AST)); - currentAST.root = caseSList_AST; - currentAST.child = caseSList_AST!=null &&caseSList_AST.getFirstChild()!=null ? - caseSList_AST.getFirstChild() : caseSList_AST; - currentAST.advanceChildToEnd(); - } - caseSList_AST = (AST)currentAST.root; - returnAST = caseSList_AST; - } - - public final void expressionList() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST expressionList_AST = null; - - expression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop122: - do { - if ((LA(1)==COMMA)) { - match(COMMA); - expression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop122; - } - - } while (true); - } - if ( inputState.guessing==0 ) { - expressionList_AST = (AST)currentAST.root; - expressionList_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ELIST,"ELIST")).add(expressionList_AST)); - currentAST.root = expressionList_AST; - currentAST.child = expressionList_AST!=null &&expressionList_AST.getFirstChild()!=null ? - expressionList_AST.getFirstChild() : expressionList_AST; - currentAST.advanceChildToEnd(); - } - expressionList_AST = (AST)currentAST.root; - returnAST = expressionList_AST; - } - - public final void handler() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST handler_AST = null; - - AST tmp118_AST = null; - tmp118_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp118_AST); - match(LITERAL_catch); - match(LPAREN); - parameterDeclaration(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - compoundStatement(); - astFactory.addASTChild(currentAST, returnAST); - handler_AST = (AST)currentAST.root; - returnAST = handler_AST; - } - - public final void finallyClause() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST finallyClause_AST = null; - - AST tmp121_AST = null; - tmp121_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp121_AST); - match(LITERAL_finally); - compoundStatement(); - astFactory.addASTChild(currentAST, returnAST); - finallyClause_AST = (AST)currentAST.root; - returnAST = finallyClause_AST; - } - - public final void assignmentExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST assignmentExpression_AST = null; - - conditionalExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case ASSIGN: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - { - { - switch ( LA(1)) { - case ASSIGN: - { - AST tmp122_AST = null; - tmp122_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp122_AST); - match(ASSIGN); - break; - } - case PLUS_ASSIGN: - { - AST tmp123_AST = null; - tmp123_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp123_AST); - match(PLUS_ASSIGN); - break; - } - case MINUS_ASSIGN: - { - AST tmp124_AST = null; - tmp124_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp124_AST); - match(MINUS_ASSIGN); - break; - } - case STAR_ASSIGN: - { - AST tmp125_AST = null; - tmp125_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp125_AST); - match(STAR_ASSIGN); - break; - } - case DIV_ASSIGN: - { - AST tmp126_AST = null; - tmp126_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp126_AST); - match(DIV_ASSIGN); - break; - } - case MOD_ASSIGN: - { - AST tmp127_AST = null; - tmp127_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp127_AST); - match(MOD_ASSIGN); - break; - } - case SR_ASSIGN: - { - AST tmp128_AST = null; - tmp128_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp128_AST); - match(SR_ASSIGN); - break; - } - case BSR_ASSIGN: - { - AST tmp129_AST = null; - tmp129_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp129_AST); - match(BSR_ASSIGN); - break; - } - case SL_ASSIGN: - { - AST tmp130_AST = null; - tmp130_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp130_AST); - match(SL_ASSIGN); - break; - } - case BAND_ASSIGN: - { - AST tmp131_AST = null; - tmp131_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp131_AST); - match(BAND_ASSIGN); - break; - } - case BXOR_ASSIGN: - { - AST tmp132_AST = null; - tmp132_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp132_AST); - match(BXOR_ASSIGN); - break; - } - case BOR_ASSIGN: - { - AST tmp133_AST = null; - tmp133_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp133_AST); - match(BOR_ASSIGN); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - assignmentExpression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - case RBRACK: - case RCURLY: - case COMMA: - case RPAREN: - case COLON: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - assignmentExpression_AST = (AST)currentAST.root; - returnAST = assignmentExpression_AST; - } - - public final void conditionalExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST conditionalExpression_AST = null; - - logicalOrExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case QUESTION: - { - AST tmp134_AST = null; - tmp134_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp134_AST); - match(QUESTION); - assignmentExpression(); - astFactory.addASTChild(currentAST, returnAST); - match(COLON); - conditionalExpression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - case RBRACK: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - conditionalExpression_AST = (AST)currentAST.root; - returnAST = conditionalExpression_AST; - } - - public final void logicalOrExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST logicalOrExpression_AST = null; - - logicalAndExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop130: - do { - if ((LA(1)==LOR)) { - AST tmp136_AST = null; - tmp136_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp136_AST); - match(LOR); - logicalAndExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop130; - } - - } while (true); - } - logicalOrExpression_AST = (AST)currentAST.root; - returnAST = logicalOrExpression_AST; - } - - public final void logicalAndExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST logicalAndExpression_AST = null; - - inclusiveOrExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop133: - do { - if ((LA(1)==LAND)) { - AST tmp137_AST = null; - tmp137_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp137_AST); - match(LAND); - inclusiveOrExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop133; - } - - } while (true); - } - logicalAndExpression_AST = (AST)currentAST.root; - returnAST = logicalAndExpression_AST; - } - - public final void inclusiveOrExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST inclusiveOrExpression_AST = null; - - exclusiveOrExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop136: - do { - if ((LA(1)==BOR)) { - AST tmp138_AST = null; - tmp138_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp138_AST); - match(BOR); - exclusiveOrExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop136; - } - - } while (true); - } - inclusiveOrExpression_AST = (AST)currentAST.root; - returnAST = inclusiveOrExpression_AST; - } - - public final void exclusiveOrExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST exclusiveOrExpression_AST = null; - - andExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop139: - do { - if ((LA(1)==BXOR)) { - AST tmp139_AST = null; - tmp139_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp139_AST); - match(BXOR); - andExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop139; - } - - } while (true); - } - exclusiveOrExpression_AST = (AST)currentAST.root; - returnAST = exclusiveOrExpression_AST; - } - - public final void andExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST andExpression_AST = null; - - equalityExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop142: - do { - if ((LA(1)==BAND)) { - AST tmp140_AST = null; - tmp140_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp140_AST); - match(BAND); - equalityExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop142; - } - - } while (true); - } - andExpression_AST = (AST)currentAST.root; - returnAST = andExpression_AST; - } - - public final void equalityExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST equalityExpression_AST = null; - - relationalExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop146: - do { - if ((LA(1)==NOT_EQUAL||LA(1)==EQUAL)) { - { - switch ( LA(1)) { - case NOT_EQUAL: - { - AST tmp141_AST = null; - tmp141_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp141_AST); - match(NOT_EQUAL); - break; - } - case EQUAL: - { - AST tmp142_AST = null; - tmp142_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp142_AST); - match(EQUAL); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - relationalExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop146; - } - - } while (true); - } - equalityExpression_AST = (AST)currentAST.root; - returnAST = equalityExpression_AST; - } - - public final void relationalExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST relationalExpression_AST = null; - - shiftExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case SEMI: - case RBRACK: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - { - { - _loop151: - do { - if (((LA(1) >= LT && LA(1) <= GE))) { - { - switch ( LA(1)) { - case LT: - { - AST tmp143_AST = null; - tmp143_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp143_AST); - match(LT); - break; - } - case GT: - { - AST tmp144_AST = null; - tmp144_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp144_AST); - match(GT); - break; - } - case LE: - { - AST tmp145_AST = null; - tmp145_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp145_AST); - match(LE); - break; - } - case GE: - { - AST tmp146_AST = null; - tmp146_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp146_AST); - match(GE); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - shiftExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop151; - } - - } while (true); - } - break; - } - case LITERAL_instanceof: - { - AST tmp147_AST = null; - tmp147_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp147_AST); - match(LITERAL_instanceof); - typeSpec(true); - astFactory.addASTChild(currentAST, returnAST); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - relationalExpression_AST = (AST)currentAST.root; - returnAST = relationalExpression_AST; - } - - public final void shiftExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST shiftExpression_AST = null; - - additiveExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop155: - do { - if (((LA(1) >= SL && LA(1) <= BSR))) { - { - switch ( LA(1)) { - case SL: - { - AST tmp148_AST = null; - tmp148_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp148_AST); - match(SL); - break; - } - case SR: - { - AST tmp149_AST = null; - tmp149_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp149_AST); - match(SR); - break; - } - case BSR: - { - AST tmp150_AST = null; - tmp150_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp150_AST); - match(BSR); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - additiveExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop155; - } - - } while (true); - } - shiftExpression_AST = (AST)currentAST.root; - returnAST = shiftExpression_AST; - } - - public final void additiveExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST additiveExpression_AST = null; - - multiplicativeExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop159: - do { - if ((LA(1)==PLUS||LA(1)==MINUS)) { - { - switch ( LA(1)) { - case PLUS: - { - AST tmp151_AST = null; - tmp151_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp151_AST); - match(PLUS); - break; - } - case MINUS: - { - AST tmp152_AST = null; - tmp152_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp152_AST); - match(MINUS); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - multiplicativeExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop159; - } - - } while (true); - } - additiveExpression_AST = (AST)currentAST.root; - returnAST = additiveExpression_AST; - } - - public final void multiplicativeExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST multiplicativeExpression_AST = null; - - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop163: - do { - if ((_tokenSet_22.member(LA(1)))) { - { - switch ( LA(1)) { - case STAR: - { - AST tmp153_AST = null; - tmp153_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp153_AST); - match(STAR); - break; - } - case DIV: - { - AST tmp154_AST = null; - tmp154_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp154_AST); - match(DIV); - break; - } - case MOD: - { - AST tmp155_AST = null; - tmp155_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp155_AST); - match(MOD); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - break _loop163; - } - - } while (true); - } - multiplicativeExpression_AST = (AST)currentAST.root; - returnAST = multiplicativeExpression_AST; - } - - public final void unaryExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST unaryExpression_AST = null; - - switch ( LA(1)) { - case INC: - { - AST tmp156_AST = null; - tmp156_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp156_AST); - match(INC); - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpression_AST = (AST)currentAST.root; - break; - } - case DEC: - { - AST tmp157_AST = null; - tmp157_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp157_AST); - match(DEC); - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpression_AST = (AST)currentAST.root; - break; - } - case MINUS: - { - AST tmp158_AST = null; - tmp158_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp158_AST); - match(MINUS); - if ( inputState.guessing==0 ) { - tmp158_AST.setType(UNARY_MINUS); - } - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpression_AST = (AST)currentAST.root; - break; - } - case PLUS: - { - AST tmp159_AST = null; - tmp159_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp159_AST); - match(PLUS); - if ( inputState.guessing==0 ) { - tmp159_AST.setType(UNARY_PLUS); - } - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - unaryExpressionNotPlusMinus(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpression_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = unaryExpression_AST; - } - - public final void unaryExpressionNotPlusMinus() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST unaryExpressionNotPlusMinus_AST = null; - Token lpb = null; - AST lpb_AST = null; - Token lp = null; - AST lp_AST = null; - - switch ( LA(1)) { - case BNOT: - { - AST tmp160_AST = null; - tmp160_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp160_AST); - match(BNOT); - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpressionNotPlusMinus_AST = (AST)currentAST.root; - break; - } - case LNOT: - { - AST tmp161_AST = null; - tmp161_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp161_AST); - match(LNOT); - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - unaryExpressionNotPlusMinus_AST = (AST)currentAST.root; - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - { - if ((LA(1)==LPAREN) && ((LA(2) >= LITERAL_void && LA(2) <= LITERAL_double))) { - lpb = LT(1); - lpb_AST = astFactory.create(lpb); - astFactory.makeASTRoot(currentAST, lpb_AST); - match(LPAREN); - if ( inputState.guessing==0 ) { - lpb_AST.setType(TYPECAST); - } - builtInTypeSpec(true); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - unaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - boolean synPredMatched168 = false; - if (((LA(1)==LPAREN) && (LA(2)==IDENT))) { - int _m168 = mark(); - synPredMatched168 = true; - inputState.guessing++; - try { - { - match(LPAREN); - classTypeSpec(true); - match(RPAREN); - unaryExpressionNotPlusMinus(); - } - } - catch (RecognitionException pe) { - synPredMatched168 = false; - } - rewind(_m168); - inputState.guessing--; - } - if ( synPredMatched168 ) { - lp = LT(1); - lp_AST = astFactory.create(lp); - astFactory.makeASTRoot(currentAST, lp_AST); - match(LPAREN); - if ( inputState.guessing==0 ) { - lp_AST.setType(TYPECAST); - } - classTypeSpec(true); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - unaryExpressionNotPlusMinus(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((_tokenSet_23.member(LA(1))) && (_tokenSet_24.member(LA(2)))) { - postfixExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - unaryExpressionNotPlusMinus_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = unaryExpressionNotPlusMinus_AST; - } - - public final void postfixExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST postfixExpression_AST = null; - Token lp = null; - AST lp_AST = null; - Token lp3 = null; - AST lp3_AST = null; - Token lps = null; - AST lps_AST = null; - Token lb = null; - AST lb_AST = null; - Token in = null; - AST in_AST = null; - Token de = null; - AST de_AST = null; - - primaryExpression(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop174: - do { - if ((LA(1)==DOT) && (LA(2)==IDENT)) { - AST tmp164_AST = null; - tmp164_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp164_AST); - match(DOT); - AST tmp165_AST = null; - tmp165_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp165_AST); - match(IDENT); - { - switch ( LA(1)) { - case LPAREN: - { - lp = LT(1); - lp_AST = astFactory.create(lp); - astFactory.makeASTRoot(currentAST, lp_AST); - match(LPAREN); - if ( inputState.guessing==0 ) { - lp_AST.setType(METHOD_CALL); - } - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - break; - } - case SEMI: - case LBRACK: - case RBRACK: - case DOT: - case STAR: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - case LITERAL_instanceof: - case SL: - case SR: - case BSR: - case PLUS: - case MINUS: - case DIV: - case MOD: - case INC: - case DEC: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - } - else if ((LA(1)==DOT) && (LA(2)==LITERAL_this)) { - AST tmp167_AST = null; - tmp167_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp167_AST); - match(DOT); - AST tmp168_AST = null; - tmp168_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp168_AST); - match(LITERAL_this); - } - else if ((LA(1)==DOT) && (LA(2)==LITERAL_super)) { - AST tmp169_AST = null; - tmp169_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp169_AST); - match(DOT); - AST tmp170_AST = null; - tmp170_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp170_AST); - match(LITERAL_super); - { - switch ( LA(1)) { - case LPAREN: - { - lp3 = LT(1); - lp3_AST = astFactory.create(lp3); - astFactory.makeASTRoot(currentAST, lp3_AST); - match(LPAREN); - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - if ( inputState.guessing==0 ) { - lp3_AST.setType(SUPER_CTOR_CALL); - } - break; - } - case DOT: - { - AST tmp172_AST = null; - tmp172_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp172_AST); - match(DOT); - AST tmp173_AST = null; - tmp173_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp173_AST); - match(IDENT); - { - switch ( LA(1)) { - case LPAREN: - { - lps = LT(1); - lps_AST = astFactory.create(lps); - astFactory.makeASTRoot(currentAST, lps_AST); - match(LPAREN); - if ( inputState.guessing==0 ) { - lps_AST.setType(METHOD_CALL); - } - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - break; - } - case SEMI: - case LBRACK: - case RBRACK: - case DOT: - case STAR: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - case LITERAL_instanceof: - case SL: - case SR: - case BSR: - case PLUS: - case MINUS: - case DIV: - case MOD: - case INC: - case DEC: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - } - else if ((LA(1)==DOT) && (LA(2)==LITERAL_new)) { - AST tmp175_AST = null; - tmp175_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp175_AST); - match(DOT); - newExpression(); - astFactory.addASTChild(currentAST, returnAST); - } - else if ((LA(1)==LBRACK)) { - lb = LT(1); - lb_AST = astFactory.create(lb); - astFactory.makeASTRoot(currentAST, lb_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lb_AST.setType(INDEX_OP); - } - expression(); - astFactory.addASTChild(currentAST, returnAST); - match(RBRACK); - } - else { - break _loop174; - } - - } while (true); - } - { - switch ( LA(1)) { - case INC: - { - in = LT(1); - in_AST = astFactory.create(in); - astFactory.makeASTRoot(currentAST, in_AST); - match(INC); - if ( inputState.guessing==0 ) { - in_AST.setType(POST_INC); - } - break; - } - case DEC: - { - de = LT(1); - de_AST = astFactory.create(de); - astFactory.makeASTRoot(currentAST, de_AST); - match(DEC); - if ( inputState.guessing==0 ) { - de_AST.setType(POST_DEC); - } - break; - } - case SEMI: - case RBRACK: - case STAR: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - case LITERAL_instanceof: - case SL: - case SR: - case BSR: - case PLUS: - case MINUS: - case DIV: - case MOD: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - postfixExpression_AST = (AST)currentAST.root; - returnAST = postfixExpression_AST; - } - - public final void primaryExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST primaryExpression_AST = null; - Token lbt = null; - AST lbt_AST = null; - - switch ( LA(1)) { - case IDENT: - { - identPrimary(); - astFactory.addASTChild(currentAST, returnAST); - { - if ((LA(1)==DOT) && (LA(2)==LITERAL_class)) { - AST tmp177_AST = null; - tmp177_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp177_AST); - match(DOT); - AST tmp178_AST = null; - tmp178_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp178_AST); - match(LITERAL_class); - } - else if ((_tokenSet_25.member(LA(1))) && (_tokenSet_26.member(LA(2)))) { - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - primaryExpression_AST = (AST)currentAST.root; - break; - } - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - constant(); - astFactory.addASTChild(currentAST, returnAST); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_true: - { - AST tmp179_AST = null; - tmp179_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp179_AST); - match(LITERAL_true); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_false: - { - AST tmp180_AST = null; - tmp180_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp180_AST); - match(LITERAL_false); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_null: - { - AST tmp181_AST = null; - tmp181_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp181_AST); - match(LITERAL_null); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_new: - { - newExpression(); - astFactory.addASTChild(currentAST, returnAST); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_this: - { - AST tmp182_AST = null; - tmp182_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp182_AST); - match(LITERAL_this); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_super: - { - AST tmp183_AST = null; - tmp183_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp183_AST); - match(LITERAL_super); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LPAREN: - { - match(LPAREN); - assignmentExpression(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - primaryExpression_AST = (AST)currentAST.root; - break; - } - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - { - builtInType(); - astFactory.addASTChild(currentAST, returnAST); - { - _loop179: - do { - if ((LA(1)==LBRACK)) { - lbt = LT(1); - lbt_AST = astFactory.create(lbt); - astFactory.makeASTRoot(currentAST, lbt_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lbt_AST.setType(ARRAY_DECLARATOR); - } - match(RBRACK); - } - else { - break _loop179; - } - - } while (true); - } - AST tmp187_AST = null; - tmp187_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp187_AST); - match(DOT); - AST tmp188_AST = null; - tmp188_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp188_AST); - match(LITERAL_class); - primaryExpression_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = primaryExpression_AST; - } - -/** object instantiation. - * Trees are built as illustrated by the following input/tree pairs: - * - * new T() - * - * new - * | - * T -- ELIST - * | - * arg1 -- arg2 -- .. -- argn - * - * new int[] - * - * new - * | - * int -- ARRAY_DECLARATOR - * - * new int[] {1,2} - * - * new - * | - * int -- ARRAY_DECLARATOR -- ARRAY_INIT - * | - * EXPR -- EXPR - * | | - * 1 2 - * - * new int[3] - * new - * | - * int -- ARRAY_DECLARATOR - * | - * EXPR - * | - * 3 - * - * new int[1][2] - * - * new - * | - * int -- ARRAY_DECLARATOR - * | - * ARRAY_DECLARATOR -- EXPR - * | | - * EXPR 1 - * | - * 2 - * - */ - public final void newExpression() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST newExpression_AST = null; - - AST tmp189_AST = null; - tmp189_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp189_AST); - match(LITERAL_new); - type(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case LPAREN: - { - match(LPAREN); - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - { - switch ( LA(1)) { - case LCURLY: - { - classBlock(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - case LBRACK: - case RBRACK: - case DOT: - case STAR: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - case LITERAL_instanceof: - case SL: - case SR: - case BSR: - case PLUS: - case MINUS: - case DIV: - case MOD: - case INC: - case DEC: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - break; - } - case LBRACK: - { - newArrayDeclarator(); - astFactory.addASTChild(currentAST, returnAST); - { - switch ( LA(1)) { - case LCURLY: - { - arrayInitializer(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case SEMI: - case LBRACK: - case RBRACK: - case DOT: - case STAR: - case RCURLY: - case COMMA: - case RPAREN: - case ASSIGN: - case COLON: - case PLUS_ASSIGN: - case MINUS_ASSIGN: - case STAR_ASSIGN: - case DIV_ASSIGN: - case MOD_ASSIGN: - case SR_ASSIGN: - case BSR_ASSIGN: - case SL_ASSIGN: - case BAND_ASSIGN: - case BXOR_ASSIGN: - case BOR_ASSIGN: - case QUESTION: - case LOR: - case LAND: - case BOR: - case BXOR: - case BAND: - case NOT_EQUAL: - case EQUAL: - case LT: - case GT: - case LE: - case GE: - case LITERAL_instanceof: - case SL: - case SR: - case BSR: - case PLUS: - case MINUS: - case DIV: - case MOD: - case INC: - case DEC: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - newExpression_AST = (AST)currentAST.root; - returnAST = newExpression_AST; - } - -/** Match a, a.b.c refs, a.b.c(...) refs, a.b.c[], a.b.c[].class, - * and a.b.c.class refs. Also this(...) and super(...). Match - * this or super. - */ - public final void identPrimary() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST identPrimary_AST = null; - Token lp = null; - AST lp_AST = null; - Token lbc = null; - AST lbc_AST = null; - - AST tmp192_AST = null; - tmp192_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp192_AST); - match(IDENT); - { - _loop182: - do { - if ((LA(1)==DOT) && (LA(2)==IDENT)) { - AST tmp193_AST = null; - tmp193_AST = astFactory.create(LT(1)); - astFactory.makeASTRoot(currentAST, tmp193_AST); - match(DOT); - AST tmp194_AST = null; - tmp194_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp194_AST); - match(IDENT); - } - else { - break _loop182; - } - - } while (true); - } - { - if ((LA(1)==LPAREN)) { - { - lp = LT(1); - lp_AST = astFactory.create(lp); - astFactory.makeASTRoot(currentAST, lp_AST); - match(LPAREN); - if ( inputState.guessing==0 ) { - lp_AST.setType(METHOD_CALL); - } - argList(); - astFactory.addASTChild(currentAST, returnAST); - match(RPAREN); - } - } - else if ((LA(1)==LBRACK) && (LA(2)==RBRACK)) { - { - int _cnt186=0; - _loop186: - do { - if ((LA(1)==LBRACK) && (LA(2)==RBRACK)) { - lbc = LT(1); - lbc_AST = astFactory.create(lbc); - astFactory.makeASTRoot(currentAST, lbc_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lbc_AST.setType(ARRAY_DECLARATOR); - } - match(RBRACK); - } - else { - if ( _cnt186>=1 ) { break _loop186; } else {throw new NoViableAltException(LT(1), getFilename());} - } - - _cnt186++; - } while (true); - } - } - else if ((_tokenSet_25.member(LA(1))) && (_tokenSet_26.member(LA(2)))) { - } - else { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - identPrimary_AST = (AST)currentAST.root; - returnAST = identPrimary_AST; - } - - public final void constant() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST constant_AST = null; - - switch ( LA(1)) { - case NUM_INT: - { - AST tmp197_AST = null; - tmp197_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp197_AST); - match(NUM_INT); - constant_AST = (AST)currentAST.root; - break; - } - case CHAR_LITERAL: - { - AST tmp198_AST = null; - tmp198_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp198_AST); - match(CHAR_LITERAL); - constant_AST = (AST)currentAST.root; - break; - } - case STRING_LITERAL: - { - AST tmp199_AST = null; - tmp199_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp199_AST); - match(STRING_LITERAL); - constant_AST = (AST)currentAST.root; - break; - } - case NUM_FLOAT: - { - AST tmp200_AST = null; - tmp200_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp200_AST); - match(NUM_FLOAT); - constant_AST = (AST)currentAST.root; - break; - } - case NUM_LONG: - { - AST tmp201_AST = null; - tmp201_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp201_AST); - match(NUM_LONG); - constant_AST = (AST)currentAST.root; - break; - } - case NUM_DOUBLE: - { - AST tmp202_AST = null; - tmp202_AST = astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp202_AST); - match(NUM_DOUBLE); - constant_AST = (AST)currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - returnAST = constant_AST; - } - - public final void newArrayDeclarator() throws RecognitionException, TokenStreamException { - - returnAST = null; - ASTPair currentAST = new ASTPair(); - AST newArrayDeclarator_AST = null; - Token lb = null; - AST lb_AST = null; - - { - int _cnt196=0; - _loop196: - do { - if ((LA(1)==LBRACK) && (_tokenSet_27.member(LA(2)))) { - lb = LT(1); - lb_AST = astFactory.create(lb); - astFactory.makeASTRoot(currentAST, lb_AST); - match(LBRACK); - if ( inputState.guessing==0 ) { - lb_AST.setType(ARRAY_DECLARATOR); - } - { - switch ( LA(1)) { - case LITERAL_void: - case LITERAL_boolean: - case LITERAL_byte: - case LITERAL_char: - case LITERAL_short: - case LITERAL_int: - case LITERAL_float: - case LITERAL_long: - case LITERAL_double: - case IDENT: - case LPAREN: - case LITERAL_this: - case LITERAL_super: - case PLUS: - case MINUS: - case INC: - case DEC: - case BNOT: - case LNOT: - case LITERAL_true: - case LITERAL_false: - case LITERAL_null: - case LITERAL_new: - case NUM_INT: - case CHAR_LITERAL: - case STRING_LITERAL: - case NUM_FLOAT: - case NUM_LONG: - case NUM_DOUBLE: - { - expression(); - astFactory.addASTChild(currentAST, returnAST); - break; - } - case RBRACK: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - match(RBRACK); - } - else { - if ( _cnt196>=1 ) { break _loop196; } else {throw new NoViableAltException(LT(1), getFilename());} - } - - _cnt196++; - } while (true); - } - newArrayDeclarator_AST = (AST)currentAST.root; - returnAST = newArrayDeclarator_AST; - } - - - public static final String[] _tokenNames = { - "<0>", - "EOF", - "<2>", - "NULL_TREE_LOOKAHEAD", - "BLOCK", - "MODIFIERS", - "OBJBLOCK", - "SLIST", - "CTOR_DEF", - "METHOD_DEF", - "VARIABLE_DEF", - "INSTANCE_INIT", - "STATIC_INIT", - "TYPE", - "CLASS_DEF", - "INTERFACE_DEF", - "PACKAGE_DEF", - "ARRAY_DECLARATOR", - "EXTENDS_CLAUSE", - "IMPLEMENTS_CLAUSE", - "PARAMETERS", - "PARAMETER_DEF", - "LABELED_STAT", - "TYPECAST", - "INDEX_OP", - "POST_INC", - "POST_DEC", - "METHOD_CALL", - "EXPR", - "ARRAY_INIT", - "IMPORT", - "UNARY_MINUS", - "UNARY_PLUS", - "CASE_GROUP", - "ELIST", - "FOR_INIT", - "FOR_CONDITION", - "FOR_ITERATOR", - "EMPTY_STAT", - "\"final\"", - "\"abstract\"", - "\"strictfp\"", - "SUPER_CTOR_CALL", - "CTOR_CALL", - "\"package\"", - "SEMI", - "\"import\"", - "LBRACK", - "RBRACK", - "\"void\"", - "\"boolean\"", - "\"byte\"", - "\"char\"", - "\"short\"", - "\"int\"", - "\"float\"", - "\"long\"", - "\"double\"", - "IDENT", - "DOT", - "STAR", - "\"private\"", - "\"public\"", - "\"protected\"", - "\"static\"", - "\"transient\"", - "\"native\"", - "\"threadsafe\"", - "\"synchronized\"", - "\"volatile\"", - "\"class\"", - "\"extends\"", - "\"interface\"", - "LCURLY", - "RCURLY", - "COMMA", - "\"implements\"", - "LPAREN", - "RPAREN", - "\"this\"", - "\"super\"", - "ASSIGN", - "\"throws\"", - "COLON", - "\"if\"", - "\"else\"", - "\"for\"", - "\"while\"", - "\"do\"", - "\"break\"", - "\"continue\"", - "\"return\"", - "\"switch\"", - "\"throw\"", - "\"assert\"", - "\"case\"", - "\"default\"", - "\"try\"", - "\"finally\"", - "\"catch\"", - "PLUS_ASSIGN", - "MINUS_ASSIGN", - "STAR_ASSIGN", - "DIV_ASSIGN", - "MOD_ASSIGN", - "SR_ASSIGN", - "BSR_ASSIGN", - "SL_ASSIGN", - "BAND_ASSIGN", - "BXOR_ASSIGN", - "BOR_ASSIGN", - "QUESTION", - "LOR", - "LAND", - "BOR", - "BXOR", - "BAND", - "NOT_EQUAL", - "EQUAL", - "LT", - "GT", - "LE", - "GE", - "\"instanceof\"", - "SL", - "SR", - "BSR", - "PLUS", - "MINUS", - "DIV", - "MOD", - "INC", - "DEC", - "BNOT", - "LNOT", - "\"true\"", - "\"false\"", - "\"null\"", - "\"new\"", - "NUM_INT", - "CHAR_LITERAL", - "STRING_LITERAL", - "NUM_FLOAT", - "NUM_LONG", - "NUM_DOUBLE", - "WS", - "SL_COMMENT", - "ML_COMMENT", - "ESC", - "HEX_DIGIT", - "VOCAB", - "EXPONENT", - "FLOAT_SUFFIX" - }; - - protected void buildTokenTypeASTClassMap() { - tokenTypeToASTClassMap=null; - }; - - private static final long[] mk_tokenSet_0() { - long[] data = { -2305803976550907904L, 383L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); - private static final long[] mk_tokenSet_1() { - long[] data = { -2305733607806730238L, 383L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); - private static final long[] mk_tokenSet_2() { - long[] data = { -2305803976550907902L, 383L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); - private static final long[] mk_tokenSet_3() { - long[] data = { -2305839160922996736L, 63L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); - private static final long[] mk_tokenSet_4() { - long[] data = { -1729941358572994560L, 383L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4()); - private static final long[] mk_tokenSet_5() { - long[] data = { -1153339868781215744L, 8575L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5()); - private static final long[] mk_tokenSet_6() { - long[] data = { 864831865943490560L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6()); - private static final long[] mk_tokenSet_7() { - long[] data = { 175921860444160L, 133120L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7()); - private static final long[] mk_tokenSet_8() { - long[] data = { -1729906174200905728L, -9223372026120395137L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_8 = new BitSet(mk_tokenSet_8()); - private static final long[] mk_tokenSet_9() { - long[] data = { -383179802279936L, -57984440449L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_9 = new BitSet(mk_tokenSet_9()); - private static final long[] mk_tokenSet_10() { - long[] data = { -1729906174200905728L, -9223372026120396161L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10()); - private static final long[] mk_tokenSet_11() { - long[] data = { -1729906174200905728L, -9223372019675847041L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_11 = new BitSet(mk_tokenSet_11()); - private static final long[] mk_tokenSet_12() { - long[] data = { -383179802279936L, -284801L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12()); - private static final long[] mk_tokenSet_13() { - long[] data = { -1729941358572994560L, 63L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_13 = new BitSet(mk_tokenSet_13()); - private static final long[] mk_tokenSet_14() { - long[] data = { -1153339868781215744L, 63L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_14 = new BitSet(mk_tokenSet_14()); - private static final long[] mk_tokenSet_15() { - long[] data = { 575897802350002176L, -9223372036854669312L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_15 = new BitSet(mk_tokenSet_15()); - private static final long[] mk_tokenSet_16() { - long[] data = { 2305455981120716800L, -68719239168L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_16 = new BitSet(mk_tokenSet_16()); - private static final long[] mk_tokenSet_17() { - long[] data = { -2305839160922996736L, 127L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_17 = new BitSet(mk_tokenSet_17()); - private static final long[] mk_tokenSet_18() { - long[] data = { -2017608784771284992L, 127L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_18 = new BitSet(mk_tokenSet_18()); - private static final long[] mk_tokenSet_19() { - long[] data = { 575897802350002176L, -9223372036854668800L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_19 = new BitSet(mk_tokenSet_19()); - private static final long[] mk_tokenSet_20() { - long[] data = { 2305455981120716800L, -68719237120L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_20 = new BitSet(mk_tokenSet_20()); - private static final long[] mk_tokenSet_21() { - long[] data = { 575897802350002176L, -9223372036854145024L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_21 = new BitSet(mk_tokenSet_21()); - private static final long[] mk_tokenSet_22() { - long[] data = { 1152921504606846976L, 0L, 6L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_22 = new BitSet(mk_tokenSet_22()); - private static final long[] mk_tokenSet_23() { - long[] data = { 575897802350002176L, 106496L, 130944L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_23 = new BitSet(mk_tokenSet_23()); - private static final long[] mk_tokenSet_24() { - long[] data = { 2305737456097427456L, -68718695424L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_24 = new BitSet(mk_tokenSet_24()); - private static final long[] mk_tokenSet_25() { - long[] data = { 1729839653747425280L, -68718801920L, 31L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_25 = new BitSet(mk_tokenSet_25()); - private static final long[] mk_tokenSet_26() { - long[] data = { -101704825569280L, -51539873921L, 131071L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_26 = new BitSet(mk_tokenSet_26()); - private static final long[] mk_tokenSet_27() { - long[] data = { 576179277326712832L, -9223372036854669312L, 131065L, 0L, 0L, 0L}; - return data; - } - public static final BitSet _tokenSet_27 = new BitSet(mk_tokenSet_27()); - - } diff --git a/app/preproc/JavaTokenTypes.java b/app/preproc/JavaTokenTypes.java deleted file mode 100644 index 2701cf727..000000000 --- a/app/preproc/JavaTokenTypes.java +++ /dev/null @@ -1,157 +0,0 @@ -// $ANTLR 2.7.2: "java.g" -> "JavaLexer.java"$ - -package antlr.java; - -public interface JavaTokenTypes { - int EOF = 1; - int NULL_TREE_LOOKAHEAD = 3; - int BLOCK = 4; - int MODIFIERS = 5; - int OBJBLOCK = 6; - int SLIST = 7; - int CTOR_DEF = 8; - int METHOD_DEF = 9; - int VARIABLE_DEF = 10; - int INSTANCE_INIT = 11; - int STATIC_INIT = 12; - int TYPE = 13; - int CLASS_DEF = 14; - int INTERFACE_DEF = 15; - int PACKAGE_DEF = 16; - int ARRAY_DECLARATOR = 17; - int EXTENDS_CLAUSE = 18; - int IMPLEMENTS_CLAUSE = 19; - int PARAMETERS = 20; - int PARAMETER_DEF = 21; - int LABELED_STAT = 22; - int TYPECAST = 23; - int INDEX_OP = 24; - int POST_INC = 25; - int POST_DEC = 26; - int METHOD_CALL = 27; - int EXPR = 28; - int ARRAY_INIT = 29; - int IMPORT = 30; - int UNARY_MINUS = 31; - int UNARY_PLUS = 32; - int CASE_GROUP = 33; - int ELIST = 34; - int FOR_INIT = 35; - int FOR_CONDITION = 36; - int FOR_ITERATOR = 37; - int EMPTY_STAT = 38; - int FINAL = 39; - int ABSTRACT = 40; - int STRICTFP = 41; - int SUPER_CTOR_CALL = 42; - int CTOR_CALL = 43; - int LITERAL_package = 44; - int SEMI = 45; - int LITERAL_import = 46; - int LBRACK = 47; - int RBRACK = 48; - int LITERAL_void = 49; - int LITERAL_boolean = 50; - int LITERAL_byte = 51; - int LITERAL_char = 52; - int LITERAL_short = 53; - int LITERAL_int = 54; - int LITERAL_float = 55; - int LITERAL_long = 56; - int LITERAL_double = 57; - int IDENT = 58; - int DOT = 59; - int STAR = 60; - int LITERAL_private = 61; - int LITERAL_public = 62; - int LITERAL_protected = 63; - int LITERAL_static = 64; - int LITERAL_transient = 65; - int LITERAL_native = 66; - int LITERAL_threadsafe = 67; - int LITERAL_synchronized = 68; - int LITERAL_volatile = 69; - int LITERAL_class = 70; - int LITERAL_extends = 71; - int LITERAL_interface = 72; - int LCURLY = 73; - int RCURLY = 74; - int COMMA = 75; - int LITERAL_implements = 76; - int LPAREN = 77; - int RPAREN = 78; - int LITERAL_this = 79; - int LITERAL_super = 80; - int ASSIGN = 81; - int LITERAL_throws = 82; - int COLON = 83; - int LITERAL_if = 84; - int LITERAL_else = 85; - int LITERAL_for = 86; - int LITERAL_while = 87; - int LITERAL_do = 88; - int LITERAL_break = 89; - int LITERAL_continue = 90; - int LITERAL_return = 91; - int LITERAL_switch = 92; - int LITERAL_throw = 93; - int LITERAL_assert = 94; - int LITERAL_case = 95; - int LITERAL_default = 96; - int LITERAL_try = 97; - int LITERAL_finally = 98; - int LITERAL_catch = 99; - int PLUS_ASSIGN = 100; - int MINUS_ASSIGN = 101; - int STAR_ASSIGN = 102; - int DIV_ASSIGN = 103; - int MOD_ASSIGN = 104; - int SR_ASSIGN = 105; - int BSR_ASSIGN = 106; - int SL_ASSIGN = 107; - int BAND_ASSIGN = 108; - int BXOR_ASSIGN = 109; - int BOR_ASSIGN = 110; - int QUESTION = 111; - int LOR = 112; - int LAND = 113; - int BOR = 114; - int BXOR = 115; - int BAND = 116; - int NOT_EQUAL = 117; - int EQUAL = 118; - int LT = 119; - int GT = 120; - int LE = 121; - int GE = 122; - int LITERAL_instanceof = 123; - int SL = 124; - int SR = 125; - int BSR = 126; - int PLUS = 127; - int MINUS = 128; - int DIV = 129; - int MOD = 130; - int INC = 131; - int DEC = 132; - int BNOT = 133; - int LNOT = 134; - int LITERAL_true = 135; - int LITERAL_false = 136; - int LITERAL_null = 137; - int LITERAL_new = 138; - int NUM_INT = 139; - int CHAR_LITERAL = 140; - int STRING_LITERAL = 141; - int NUM_FLOAT = 142; - int NUM_LONG = 143; - int NUM_DOUBLE = 144; - int WS = 145; - int SL_COMMENT = 146; - int ML_COMMENT = 147; - int ESC = 148; - int HEX_DIGIT = 149; - int VOCAB = 150; - int EXPONENT = 151; - int FLOAT_SUFFIX = 152; -} diff --git a/app/preproc/JavaTokenTypes.txt b/app/preproc/JavaTokenTypes.txt deleted file mode 100644 index 2805f9c97..000000000 --- a/app/preproc/JavaTokenTypes.txt +++ /dev/null @@ -1,151 +0,0 @@ -// $ANTLR 2.7.2: java.g -> JavaTokenTypes.txt$ -Java // output token vocab name -BLOCK=4 -MODIFIERS=5 -OBJBLOCK=6 -SLIST=7 -CTOR_DEF=8 -METHOD_DEF=9 -VARIABLE_DEF=10 -INSTANCE_INIT=11 -STATIC_INIT=12 -TYPE=13 -CLASS_DEF=14 -INTERFACE_DEF=15 -PACKAGE_DEF=16 -ARRAY_DECLARATOR=17 -EXTENDS_CLAUSE=18 -IMPLEMENTS_CLAUSE=19 -PARAMETERS=20 -PARAMETER_DEF=21 -LABELED_STAT=22 -TYPECAST=23 -INDEX_OP=24 -POST_INC=25 -POST_DEC=26 -METHOD_CALL=27 -EXPR=28 -ARRAY_INIT=29 -IMPORT=30 -UNARY_MINUS=31 -UNARY_PLUS=32 -CASE_GROUP=33 -ELIST=34 -FOR_INIT=35 -FOR_CONDITION=36 -FOR_ITERATOR=37 -EMPTY_STAT=38 -FINAL="final"=39 -ABSTRACT="abstract"=40 -STRICTFP="strictfp"=41 -SUPER_CTOR_CALL=42 -CTOR_CALL=43 -LITERAL_package="package"=44 -SEMI=45 -LITERAL_import="import"=46 -LBRACK=47 -RBRACK=48 -LITERAL_void="void"=49 -LITERAL_boolean="boolean"=50 -LITERAL_byte="byte"=51 -LITERAL_char="char"=52 -LITERAL_short="short"=53 -LITERAL_int="int"=54 -LITERAL_float="float"=55 -LITERAL_long="long"=56 -LITERAL_double="double"=57 -IDENT=58 -DOT=59 -STAR=60 -LITERAL_private="private"=61 -LITERAL_public="public"=62 -LITERAL_protected="protected"=63 -LITERAL_static="static"=64 -LITERAL_transient="transient"=65 -LITERAL_native="native"=66 -LITERAL_threadsafe="threadsafe"=67 -LITERAL_synchronized="synchronized"=68 -LITERAL_volatile="volatile"=69 -LITERAL_class="class"=70 -LITERAL_extends="extends"=71 -LITERAL_interface="interface"=72 -LCURLY=73 -RCURLY=74 -COMMA=75 -LITERAL_implements="implements"=76 -LPAREN=77 -RPAREN=78 -LITERAL_this="this"=79 -LITERAL_super="super"=80 -ASSIGN=81 -LITERAL_throws="throws"=82 -COLON=83 -LITERAL_if="if"=84 -LITERAL_else="else"=85 -LITERAL_for="for"=86 -LITERAL_while="while"=87 -LITERAL_do="do"=88 -LITERAL_break="break"=89 -LITERAL_continue="continue"=90 -LITERAL_return="return"=91 -LITERAL_switch="switch"=92 -LITERAL_throw="throw"=93 -LITERAL_assert="assert"=94 -LITERAL_case="case"=95 -LITERAL_default="default"=96 -LITERAL_try="try"=97 -LITERAL_finally="finally"=98 -LITERAL_catch="catch"=99 -PLUS_ASSIGN=100 -MINUS_ASSIGN=101 -STAR_ASSIGN=102 -DIV_ASSIGN=103 -MOD_ASSIGN=104 -SR_ASSIGN=105 -BSR_ASSIGN=106 -SL_ASSIGN=107 -BAND_ASSIGN=108 -BXOR_ASSIGN=109 -BOR_ASSIGN=110 -QUESTION=111 -LOR=112 -LAND=113 -BOR=114 -BXOR=115 -BAND=116 -NOT_EQUAL=117 -EQUAL=118 -LT=119 -GT=120 -LE=121 -GE=122 -LITERAL_instanceof="instanceof"=123 -SL=124 -SR=125 -BSR=126 -PLUS=127 -MINUS=128 -DIV=129 -MOD=130 -INC=131 -DEC=132 -BNOT=133 -LNOT=134 -LITERAL_true="true"=135 -LITERAL_false="false"=136 -LITERAL_null="null"=137 -LITERAL_new="new"=138 -NUM_INT=139 -CHAR_LITERAL=140 -STRING_LITERAL=141 -NUM_FLOAT=142 -NUM_LONG=143 -NUM_DOUBLE=144 -WS=145 -SL_COMMENT=146 -ML_COMMENT=147 -ESC=148 -HEX_DIGIT=149 -VOCAB=150 -EXPONENT=151 -FLOAT_SUFFIX=152 diff --git a/app/preproc/LineObject.java b/app/preproc/LineObject.java new file mode 100755 index 000000000..ac6bde917 --- /dev/null +++ b/app/preproc/LineObject.java @@ -0,0 +1,126 @@ +package processing.app.preproc; + +class LineObject { + LineObject parent = null; + String source = ""; + int line = 1; + boolean enteringFile = false; + boolean returningToFile = false; + boolean systemHeader = false; + boolean treatAsC = false; + + public LineObject() + { + super(); + } + + public LineObject( LineObject lobj ) + { + parent = lobj.getParent(); + source = lobj.getSource(); + line = lobj.getLine(); + enteringFile = lobj.getEnteringFile(); + returningToFile = lobj.getReturningToFile(); + systemHeader = lobj.getSystemHeader(); + treatAsC = lobj.getTreatAsC(); + } + + public LineObject( String src) + { + source = src; + } + + public void setSource(String src) + { + source = src; + } + + public String getSource() + { + return source; + } + + public void setParent(LineObject par) + { + parent = par; + } + + public LineObject getParent() + { + return parent; + } + + public void setLine(int l) + { + line = l; + } + + public int getLine() + { + return line; + } + + public void newline() + { + line++; + } + + public void setEnteringFile(boolean v) + { + enteringFile = v; + } + + public boolean getEnteringFile() + { + return enteringFile; + } + + public void setReturningToFile(boolean v) + { + returningToFile = v; + } + + public boolean getReturningToFile() + { + return returningToFile; + } + + public void setSystemHeader(boolean v) + { + systemHeader = v; + } + + public boolean getSystemHeader() + { + return systemHeader; + } + + public void setTreatAsC(boolean v) + { + treatAsC = v; + } + + public boolean getTreatAsC() + { + return treatAsC; + } + + public String toString() { + StringBuffer ret; + ret = new StringBuffer("# " + line + " \"" + source + "\""); + if (enteringFile) { + ret.append(" 1"); + } + if (returningToFile) { + ret.append(" 2"); + } + if (systemHeader) { + ret.append(" 3"); + } + if (treatAsC) { + ret.append(" 4"); + } + return ret.toString(); + } +} + diff --git a/app/preproc/Makefile b/app/preproc/Makefile new file mode 100755 index 000000000..75d3d8848 --- /dev/null +++ b/app/preproc/Makefile @@ -0,0 +1,36 @@ +classfiles = LineObject.class PreprocessorInfoChannel.class StdCParser.class StdCLexer.class WParser.class WLexer.class WTreeParser.class WEmitter.class +javafiles = CSymbolTable.java TNode.java TNodeFactory.java CToken.java LineObject.java PreprocessorInfoChannel.java StdCParser.java StdCLexer.java WParser.java WLexer.java WTreeParser.java WEmitter.java + + +all : $(javafiles) $(classfiles) + + + +clean : + + + +StdCParser.java StdCLexer.java : StdCParser.g + java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool StdCParser.g + + +WParser.java WLexer.java : WParser.g WParser.g + java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool -glib "StdCParser.g" WParser.g + + +WTreeParser.java : WTreeParser.g + java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool WTreeParser.g + + +WEmitter.java : WEmitter.g WTreeParser.g + java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool -glib "WTreeParser.g" WEmitter.g + + + +.SUFFIXES: .java .class + +.java.class : + ../../build/windows/work/jikes -cp "..\\..\\build\\windows\\work\\java\\lib\\rt.jar;..\\..\\build\\windows\\work\\lib\\mrj.jar;..\\..\\build\\windows\\work\\lib\\antlr.jar;." $< + + + diff --git a/app/preproc/PdeEmitter.java b/app/preproc/PdeEmitter.java deleted file mode 100644 index c701f3038..000000000 --- a/app/preproc/PdeEmitter.java +++ /dev/null @@ -1,922 +0,0 @@ -/* -*- 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