jtb-1.4.4/0000755000175000017500000000000011420623644012121 5ustar cavedoncavedonjtb-1.4.4/Releases_Notes.txt0000644000175000017500000001572111416555620015606 0ustar cavedoncavedon--------------- Version 1.4.4 --------------- -> xx/07/2010 - Fixed missing space after throws issue in visiting MethodDeclaration & ConstructorDeclaration of JavaPrinter - Fixed index issue in visiting TypeArguments of JavaPrinter --------------- Version 1.4.3.2 --------------- -> 26/04/2010 - Fixed index issue in visiting Expansion of AcceptInliner (bug #2991455) --------------- Version 1.4.3.1 --------------- -> 23/04/2010 - Fixed output of AcceptInliner for -f option (bug #2989497) - Fixed case 4 of getExpUnitBaseNodeType of CommentsPrinter (bug #2990962) and tuned number of dots --------------- Version 1.4.3 --------------- -> 31/03/2010 - Added node declarations initialization in all cases - Fixed output of else bug in Annotator - Fixed output of constructor in TreeFormatter --------------- Version 1.4.2 --------------- -> 25/02/2010 - Fixed missing "java.util package" in generated JTBToolkit class - Fixed issue in visiting ExpansionChoices of AcceptInliner --------------- Version 1.4.1 --------------- -> 17/02/2010 - Fixed unprocessed n.f0.which == 0 case in visit(ExpansionUnit) in SemanticChecker - Fixed missing static modifier for JTB generated return variables in case static = true in Annotator & JTB & Globals --------------- Version 1.4.0.2 --------------- -> 21/01/2010 - Fixed output of else bug in JavaPrinter --------------- Version 1.4.0.1 --------------- -> 20/01/2010 - Fixed command line options overwrite bug ------------- Version 1.4.0 ------------- -> 19/11/2009 - Fixed NPE bug in visitors generation when no -jd is set - Added JTB options commenting in the output file - Added parent directories creation ------------------ Version 1.4.j.m.15 ------------------ -> 16/11/2009 - Back to JDK 1.5 (for use under the JavaCC Eclipse Plug-in) - Changed to JavaCC 5.0 the JavaCC jar used to compile the jtb.out.jj file - Added -d, -nd & -vd options, modified -p, -pd & -vp options (to separate directories from packages) ------------------ Version 1.4.j.m.14 ------------------ -> 16/11/2009 - Copied and optimized visit(ExpansionChoices) and visit(Expansion) from DepthFirstVoidVisitor to ExpansionUnitTypeCounter - Extracted ExpansionUnitInTCF production in grammar - Modified visitors and generators accordingly - Finished ExpansionUnitInTCF management in DepthFirstVisitorGenerator ------------------ Version 1.4.j.m.13 ------------------ -> 25/08/2009 15:01 - Added part of ExpansionUnit type 3 management in visitors ------------------ Version 1.4.j.m.12 ------------------ -> 24/08/2009 18.07 - Inlined accept methods in generated visitors with new class AcceptInliner - Added -dl option for depth level management generation - Fixed bug in CommentPrinter - Fixed bug in Annotator ------------------ Version 1.4.j.m.11 ------------------ -> 29/07/2009 18:21 - Fixed visit ReturnStatement in Annotator ------------------ Version 1.4.j.m.10 ------------------ -> 29/07/2009 14:22 - Added which value in javadoc comments for productions with choices - Removed arguments in javadoc comments for productions - Print on an indented new line regular expressions in javadoc comments for productions - Changed behavior of option -jd: now turns on printing classes, methods and fields javadoc comments - Added NodeList and NodeListOptional list of nodes allocation increment algorithm - Fixed parent pointer methods - Added -ia option for inlining visitor accept methods on base nodes - Added switch statement in inlining a NodeChoice - Renamed CommentPrinter into CommentsPrinter and moved it from misc.ClassInfo to visitor - Added fieldComments in ClassInfo and associated methods - Enhanced field comments with indentation - Added StringBuilders and javadoc in TreeFormatterGenerator and TreeDumperGenerator - Changed \n into line.separator in all generation classes - Updated all grammar comments in visitors ----------------- Version 1.4.j.m.9 ----------------- -> 12/07/2009 20:48 - Removed "only non void JavaCodeProduction" limitation - Fixed some errors - Added proper handling of PrimaryExpression() = Identifier() ... | RegularExpression() ... - Cleaned grammar with temporary modifications for generics, return types and pe() = id() | re() ----------------- Version 1.4.j.m.8 ----------------- -> 10/07/2009 17:19 - Removed "only void BNFProduction result type" limitation - Removed ModMMa comments, fixed some javadoc comments ----------------- Version 1.4.j.m.7 ----------------- -> 05/07/2009 09:05 - Fixed calls to AccessModifiers - Fixed some specials printing - Added missing methods in JavaPrinter - Renamed Printer in JavaCCPrinter - Enhanced generated comments - Added javadoc comments to visitors and generators - Added javadoc comments to JTB classes ----------------- Version 1.4.j.m.6 ----------------- -> 25/06/2009 09:18 - "instanceof" changed into "int variable" in ExpansionTreeWalker forgotten method - Removed jtbgram.jtb temporary changes for being processed by JTB 1.3.2 on generics - Generics types put back in jtbgram.jtb ----------------- Version 1.4.j.m.5 ----------------- -> 22/06/2009 18:45 - Refactoring ClassInfo, Printer, JavaPrinter, Annotator, JavaStringMaker (StringBuilders, BufferedWriters, methods signatures) - Renames JavaStringMaker into JavaBranchPrinter - Vectors changed into ArrayLists - "instanceof" changed into "int variable" in ExpansionTreeWalker and Expansion_ subclasses - Changed direct use of node.tokenImage in node.accept to be able to print specials - Moved addUnicodeEscapes to UnicodeConverter and use it for printing tokens in literals - Corrections in JavaPrinter ----------------- Version 1.4.j.m.4 ----------------- -> 18/06/2009 12:41 - Refactoring misc files : - Added base classes and visitors related constants in Globals - Auto classes refactored (StringBuilders, BufferedWriters, renamed, common code, ...) and all merged in BaseClasses - Depth First Visitor Generators refactored (StringBuilders, BufferedWriters, renamed, common code, ...) and all merged in DepthFirstVisitorsGenerator - toolkit files deleted or renamed and moved up to misc ----------------- Version 1.4.j.m.3 ----------------- -> 12/06/2009 18:03 - Work on syntaxtree classes : node interfaces and classes for visitors - Renamed the Node and NodeListInterface interfaces into INode and INodeList - jar generated and jtb parser looks functional ----------------- Version 1.4.j.m.2 ----------------- -> 12/06/2009 12:06 - Work on ClassInfo, and JavaPrinter, Printer & Annotator visitors : adapted to JavaCC 4.2 grammar, performance improvements - jar generated and jtb parser looks functional ----------------- Version 1.4.j.m.1 ----------------- -> 11/06/2009 15:26 - parser classes taken from JavaCC 4.2 classes and adapted : no generics, no assignation of bnfproduction return info - build_jtb.xml and build_jtb_props.xml adapted - jar generated but jtb parser not functional jtb-1.4.4/META-INF/0000755000175000017500000000000011416555710013264 5ustar cavedoncavedonjtb-1.4.4/META-INF/MANIFEST.MF0000644000175000017500000000021411416555706014720 0ustar cavedoncavedonManifest-Version: 1.4.0 Ant-Version: Apache Ant 1.7.1 Created-By: 1.5.0_17-b04 (Sun Microsystems Inc.) Main-Class: EDU.purdue.jtb.JTB jtb-1.4.4/EDU/0000755000175000017500000000000011363255304012536 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/0000755000175000017500000000000011363255304014042 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/0000755000175000017500000000000011420623645014622 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/jtb.out.jj0000644000175000017500000055430111416555700016545 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ /** * JavaCC Grammar used by JTB. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.x : 05-11/2009 : MMa * adapted from JavaCC v4.2 grammar (JavaCC.jj) * to fit with JTB.java and * to use the try-ExpansionChoices-catch-finally syntax * through the ExpansionUnitInTCF production */ /* * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * JTB 1.3.x is a derivation of JTB 1.2.1 which has the following * license: **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ // // Java Tree Builder (JTB) Grammar // // Converted from the JavaCC 0.6 grammar in the documentation. // Appended to the Java1.1.jj grammar provided in JavaCC. // // AUTHOR: Kevin Tao, taokr@cs.purdue.edu // // This grammar is basically the JavaCC grammar, adapted from the // documentation. A few changes have been made to fix possible bugs in the // grammar. // /***************************************************************************/ /* * * Copyright (C) 1996, 1997 Sun Microsystems Inc. * * Use of this file and the system it is part of is constrained by the * file COPYRIGHT in the root directory of this system. You may, however, * make any modifications you wish to this file. * * Java files generated by running JavaCC on this file (or modified versions * of this file) may be used in exactly the same manner as Java files * generated from any grammar developed by you. * * Author: Sriram Sankar * Date: 3/5/97 * * This file contains a Java grammar and actions that implement a front-end. * */ options { // MMa : added (does not exist in JavaCC.jj nor in jtbgram.jj, but needed for Eclipse plugin) OUTPUT_DIRECTORY = "parser"; // MMa : kept (from JavaCC.jj and jtbgram.jj) JAVA_UNICODE_ESCAPE = true; // MMa : kept (from JavaCC.jj, but it does not exist in jtbgram.jj) STATIC = false; } // MMa : adapted from JavaCC.jj to fit to JTB parser name, package, imports PARSER_BEGIN(JTBParser) package EDU.purdue.jtb.parser; import java.util.List; import java.util.ArrayList; import EDU.purdue.jtb.syntaxtree.*; /** * This file contains the code for JavaCCParser generated * by JavaCCParser itself. */ // MMa : adapted from JavaCC.jj to fit to JTB class name public class JTBParser extends JavaCCParserInternals { /* * JTB generated return variables declarations */ /** Return variable for {@link #LocalLookahead} production */ Lookahead jtbrt_LocalLookahead; /** Return variable for {@link #Identifier} production */ String jtbrt_Identifier; /** Return variable for {@link #JavaIdentifier} production */ Token jtbrt_JavaIdentifier; /** Return variable for {@link #Modifiers} production */ int jtbrt_Modifiers; /** Return variable for {@link #IntegerLiteral} production */ int jtbrt_IntegerLiteral; /** Return variable for {@link #BooleanLiteral} production */ boolean jtbrt_BooleanLiteral; /** Return variable for {@link #StringLiteral} production */ String jtbrt_StringLiteral; /** * The name of the parser class. */ String parser_class_name; /** * This flag is set to true when the part between PARSER_BEGIN and * PARSER_END is being parsed. */ boolean processing_cu = false; /** * The level of class nesting. */ int class_nesting = 0; /** * This int variable is incremented while parsing local lookaheads. * Hence it keeps track of *syntactic* lookahead nesting. * This is used to provide warnings when actions and nested lookaheads * are used in syntactic lookahead productions. This is to prevent * typos such as leaving out the comma in LOOKAHEAD( foo(), {check()} ). */ int inLocalLA = 0; /** * Set to true when the parser is within an action. */ boolean inAction = false; /** * This flag keeps track of whether or not return and throw * statements have been patched during the parsing of a production. * The value of this flag is assigned the field with the same * name in BNFProduction_.java. */ boolean jumpPatched = false; /* * Returns true if the next token is not in the FOLLOW list of "expansion". * It is used to decide when the end of an "expansion" has been reached. */ private boolean notTailOfExpansionUnit() { final Token t = getToken(1); if (t.kind == BIT_OR || t.kind == COMMA || t.kind == RPAREN || t.kind == RBRACE || t.kind == RBRACKET) return false; return true; } /** * Class to hold modifiers. */ static public final class ModifierSet { /* Definitions of the bits in the modifiers field */ public static final int M_PUBLIC = 0x0001; public static final int M_PROTECTED = 0x0002; public static final int M_PRIVATE = 0x0004; public static final int M_ABSTRACT = 0x0008; public static final int M_STATIC = 0x0010; public static final int M_FINAL = 0x0020; public static final int M_SYNCHRONIZED = 0x0040; public static final int M_NATIVE = 0x0080; public static final int M_TRANSIENT = 0x0100; public static final int M_VOLATILE = 0x0200; public static final int M_STRICTFP = 0x1000; /* A set of accessors that indicate whether the specified modifier is in the set */ public boolean isPublic(int modifiers) { return (modifiers & M_PUBLIC) != 0; } public boolean isProtected(int modifiers) { return (modifiers & M_PROTECTED) != 0; } public boolean isPrivate(int modifiers) { return (modifiers & M_PRIVATE) != 0; } public boolean isStatic(int modifiers) { return (modifiers & M_STATIC) != 0; } public boolean isAbstract(int modifiers) { return (modifiers & M_ABSTRACT) != 0; } public boolean isFinal(int modifiers) { return (modifiers & M_FINAL) != 0; } public boolean isNative(int modifiers) { return (modifiers & M_NATIVE) != 0; } public boolean isStrictfp(int modifiers) { return (modifiers & M_STRICTFP) != 0; } public boolean isSynchronized(int modifiers) { return (modifiers & M_SYNCHRONIZED) != 0; } public boolean isTransient(int modifiers) { return (modifiers & M_TRANSIENT) != 0; } public boolean isVolatile(int modifiers) { return (modifiers & M_VOLATILE) != 0; } /* Removes the given modifier */ static int removeModifier(int modifiers, int mod) { return modifiers & ~mod; } } } class JTBToolkit { static NodeToken makeNodeToken(final Token tok) { final NodeToken node = new NodeToken(tok.image.intern(), tok.kind, tok.beginLine, tok.beginColumn, tok.endLine, tok.endColumn); if (tok.specialToken == null) return node; final java.util.ArrayList temp = new java.util.ArrayList(); Token t = tok; while (t.specialToken != null) { t = t.specialToken; temp.add(new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn)); } for (int i = temp.size() - 1; i >= 0; --i) node.addSpecial(temp.get(i)); node.trimSpecials(); return node; } } // MMa : adapted from JavaCC.jj to fit to JTB parser name PARSER_END(JTBParser) TOKEN_MGR_DECLS : { int size = 20; int beginLine[] = new int[size]; int beginCol[] = new int[size]; int depth = 0; final void saveBeginLineCol(final int l, final int c) { if (depth == size) { size += 10; final int tmpbeginLine[] = new int[size]; final int tmpbeginCol[] = new int[size]; System.arraycopy(beginLine, 0, tmpbeginLine, 0, depth); System.arraycopy(beginCol, 0, tmpbeginCol, 0, depth); beginLine = tmpbeginLine; beginCol = tmpbeginCol; } beginLine[depth] = l; beginCol[depth] = c; depth++; } final void restoreBeginLineCol() { depth--; input_stream.adjustBeginLineColumn(beginLine[depth], beginCol[depth]); } } /********************************************** * THE JAVACC TOKEN SPECIFICATION STARTS HERE * **********************************************/ /* JAVACC RESERVED WORDS: These are the only tokens in JavaCC but not in Java */ TOKEN : { // "options" is no longer reserved (see issue 126). // < _OPTIONS: "options" > < _LOOKAHEAD : "LOOKAHEAD" > | < _IGNORE_CASE : "IGNORE_CASE" > | < _PARSER_BEGIN : "PARSER_BEGIN" > | < _PARSER_END : "PARSER_END" > | < _JAVACODE : "JAVACODE" > | < _TOKEN : "TOKEN" > | < _SPECIAL_TOKEN : "SPECIAL_TOKEN" > | < _MORE : "MORE" > | < _SKIP : "SKIP" > | < _TOKEN_MGR_DECLS : "TOKEN_MGR_DECLS" > | < _EOF : "EOF" > } /* * The remainder of the tokens are exactly (except for the removal of tokens * containing ">>" and "<<") as in the Java grammar and must be diff equivalent * (again with the exceptions above) to it. */ /* WHITE SPACE */ SKIP : { " " | "\t" | "\n" | "\r" | "\f" | "/*@egen*/" : AFTER_EGEN } SKIP : { < ~[] > { restoreBeginLineCol(); input_stream.backup(1); } : DEFAULT } /* COMMENTS */ MORE : { "//" : IN_SINGLE_LINE_COMMENT | < "/**" ~["/"] > { input_stream.backup(1); } : IN_FORMAL_COMMENT | "/*" : IN_MULTI_LINE_COMMENT | "/*@bgen(jjtree" { saveBeginLineCol(input_stream.getBeginLine(), input_stream.getBeginColumn()); } : IN_MULTI_LINE_COMMENT } SPECIAL_TOKEN : { < SINGLE_LINE_COMMENT : "\n"| "\r"| "\r\n" > : DEFAULT } SPECIAL_TOKEN : { < FORMAL_COMMENT : "*/" > : DEFAULT } SPECIAL_TOKEN : { < MULTI_LINE_COMMENT : "*/" > : DEFAULT } MORE : { < ~[] > } /* JAVA RESERVED WORDS AND LITERALS */ TOKEN : { < ABSTRACT : "abstract" > | < ASSERT : "assert" > | < BOOLEAN : "boolean" > | < BREAK : "break" > | < BYTE : "byte" > | < CASE : "case" > | < CATCH : "catch" > | < CHAR : "char" > | < CLASS : "class" > | < CONST : "const" > | < CONTINUE : "continue" > | < _DEFAULT : "default" > | < DO : "do" > | < DOUBLE : "double" > | < ELSE : "else" > | < ENUM : "enum" > | < EXTENDS : "extends" > | < FALSE : "false" > | < FINAL : "final" > | < FINALLY : "finally" > | < FLOAT : "float" > | < FOR : "for" > | < GOTO : "goto" > | < IF : "if" > | < IMPLEMENTS : "implements" > | < IMPORT : "import" > | < INSTANCEOF : "instanceof" > | < INT : "int" > | < INTERFACE : "interface" > | < LONG : "long" > | < NATIVE : "native" > | < NEW : "new" > | < NULL : "null" > | < PACKAGE : "package" > | < PRIVATE : "private" > | < PROTECTED : "protected" > | < PUBLIC : "public" > | < RETURN : "return" > | < SHORT : "short" > | < STATIC : "static" > | < STRICTFP : "strictfp" > | < SUPER : "super" > | < SWITCH : "switch" > | < SYNCHRONIZED : "synchronized" > | < THIS : "this" > | < THROW : "throw" > | < THROWS : "throws" > | < TRANSIENT : "transient" > | < TRUE : "true" > | < TRY : "try" > | < VOID : "void" > | < VOLATILE : "volatile" > | < WHILE : "while" > } /* JAVA LITERALS */ TOKEN : { < INTEGER_LITERAL : ( ["l", "L"] )?| ( ["l", "L"] )?| ( ["l", "L"] )? > | < #DECIMAL_LITERAL : ["1"-"9"] ( ["0"-"9"] )* > | < #HEX_LITERAL : "0" ["x", "X"] ( ["0"-"9", "a"-"f", "A"-"F"] )+ > | < #OCTAL_LITERAL : "0" ( ["0"-"7"] )* > | < FLOATING_POINT_LITERAL : | > | < #DECIMAL_FLOATING_POINT_LITERAL : ( ["0"-"9"] )+ "." ( ["0"-"9"] )* ( )? ( ["f", "F", "d", "D"] )?| "." ( ["0"-"9"] )+ ( )? ( ["f", "F", "d", "D"] )?| ( ["0"-"9"] )+ ( ["f", "F", "d", "D"] )?| ( ["0"-"9"] )+ ( )? ["f", "F", "d", "D"] > | < #DECIMAL_EXPONENT : ["e", "E"] ( ["+", "-"] )? ( ["0"-"9"] )+ > | < #HEXADECIMAL_FLOATING_POINT_LITERAL : "0" ["x", "X"] ( ["0"-"9", "a"-"f", "A"-"F"] )+ ( "." )? ( ["f", "F", "d", "D"] )?| "0" ["x", "X"] ( ["0"-"9", "a"-"f", "A"-"F"] )* "." ( ["0"-"9", "a"-"f", "A"-"F"] )+ ( ["f", "F", "d", "D"] )? > | < #HEXADECIMAL_EXPONENT : ["p", "P"] ( ["+", "-"] )? ( ["0"-"9"] )+ > | < CHARACTER_LITERAL : "'" ( ( ~["'", "\\", "\n", "\r"] )| ( "\\" ( ["n", "t", "b", "r", "f", "\\", "'", "\""]| ["0"-"7"] ( ["0"-"7"] )?| ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) ) "'" > | < STRING_LITERAL : "\"" ( ( ~["\"", "\\", "\n", "\r"] )| ( "\\" ( ["n", "t", "b", "r", "f", "\\", "'", "\""]| ["0"-"7"] ( ["0"-"7"] )?| ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > } /* SEPARATORS */ TOKEN : { < LPAREN : "(" > | < RPAREN : ")" > | < LBRACE : "{" > | < RBRACE : "}" > | < LBRACKET : "[" > | < RBRACKET : "]" > | < SEMICOLON : ";" > | < COMMA : "," > | < DOT : "." > } /* OPERATORS */ TOKEN : { < ASSIGN : "=" > //| < GT: ">" > | < LT : "<" > | < BANG : "!" > | < TILDE : "~" > | < HOOK : "?" > | < COLON : ":" > | < EQ : "==" > | < LE : "<=" > | < GE : ">=" > | < NE : "!=" > | < SC_OR : "||" > | < SC_AND : "&&" > | < INCR : "++" > | < DECR : "--" > | < PLUS : "+" > | < MINUS : "-" > | < STAR : "*" > | < SLASH : "/" > | < BIT_AND : "&" > | < BIT_OR : "|" > | < XOR : "^" > | < REM : "%" > // | < LSHIFT: "<<" > // | < RSIGNEDSHIFT: ">>" > // | < RUNSIGNEDSHIFT: ">>>" > | < PLUSASSIGN : "+=" > | < MINUSASSIGN : "-=" > | < STARASSIGN : "*=" > | < SLASHASSIGN : "/=" > | < ANDASSIGN : "&=" > | < ORASSIGN : "|=" > | < XORASSIGN : "^=" > | < REMASSIGN : "%=" > // | < LSHIFTASSIGN: "<<=" > // | < RSIGNEDSHIFTASSIGN: ">>=" > // | < RUNSIGNEDSHIFTASSIGN: ">>>=" > } /* >'s need special attention due to generics syntax. */ TOKEN : { < RUNSIGNEDSHIFT : ">>>" > { matchedToken.kind = GT; ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; input_stream.backup(2); matchedToken.image = ">"; } | < RSIGNEDSHIFT : ">>" > { matchedToken.kind = GT; ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; input_stream.backup(1); matchedToken.image = ">"; } | < GT : ">" > } /************************************************ * THE JAVACC GRAMMAR SPECIFICATION STARTS HERE * ************************************************/ // ModMMa: added to test try-expansion_choices-catch-finally syntax AFancyProduction AFancyProduction() : { // --- JTB generated node declarations --- NodeSequence n0 = null; NodeListOptional n1 = new NodeListOptional(); Annotation n2 = null; NodeChoice n3 = null; LabeledStatement n4 = null; AssertStatement n5 = null; Block n6 = null; EmptyStatement n7 = null; NodeSequence n8 = null; StatementExpression n9 = null; NodeToken n10 = null; Token n11 = null; SwitchStatement n12 = null; TryStatement n13 = null; NodeOptional n14 = new NodeOptional(); MarkerAnnotation n15 = null; // INode ls = null; } { try { ( { n0 = new NodeSequence(3); } ( n2 = Annotation() { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { n0.addNode(n1); } ( ( LOOKAHEAD( 2 ) n4 = // ls = LabeledStatement() LabeledStatement() { n3 = new NodeChoice(n4, 0, 7); } | n5 = AssertStatement() { n3 = new NodeChoice(n5, 1, 7); } | n6 = Block(null) { n3 = new NodeChoice(n6, 2, 7); } | n7 = EmptyStatement() { n3 = new NodeChoice(n7, 3, 7); } | { n8 = new NodeSequence(2); } n9 = StatementExpression() { n8.addNode(n9); } n11 = ";" { n10 = JTBToolkit.makeNodeToken(n11); } { n8.addNode(n10); } { n3 = new NodeChoice(n8, 4, 7); } | n12 = SwitchStatement() { n3 = new NodeChoice(n12, 5, 7); } | n13 = TryStatement() { n3 = new NodeChoice(n13, 6, 7); } ) ) { n0.addNode(n3); } [ n15 = MarkerAnnotation() { n14.addNode(n15); } ] { n0.addNode(n14); } ) } catch (Exception fancy_e) { fancy_e = null; } catch (Throwable fancy_t) { fancy_t = null; } finally { String fancy_s = ""; if (fancy_s == " ") fancy_s = null; // if (ls != null) // ls = null; } { return new AFancyProduction(n0); } } // MMa : changed all javacc_input into JavaCCInput to conform to class name convention JavaCCInput JavaCCInput() : { // --- JTB generated node declarations --- JavaCCOptions n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; Identifier n5 = null; NodeToken n6 = null; Token n7 = null; CompilationUnit n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; Identifier n13 = null; NodeToken n14 = null; Token n15 = null; NodeList n16 = new NodeList(); Production n17 = null; // --- user BNFProduction java block --- String id1, id2; initialize(); // MMa : added to JavaCC as called in parser.Main in Javacc 4.2 Options.init(); } { n0 = JavaCCOptions() n2 = "PARSER_BEGIN" { n1 = JTBToolkit.makeNodeToken(n2); } n4 = "(" { n3 = JTBToolkit.makeNodeToken(n4); } n5 = Identifier() { id1 = jtbrt_Identifier; } { addcuname(id1); } n7 = ")" { n6 = JTBToolkit.makeNodeToken(n7); } { processing_cu = true; parser_class_name = id1; } n8 = CompilationUnit() { processing_cu = false; } n10 = "PARSER_END" { n9 = JTBToolkit.makeNodeToken(n10); } n12 = "(" { n11 = JTBToolkit.makeNodeToken(n12); } n13 = Identifier() { id2 = jtbrt_Identifier; } { compare(getToken(0), id1, id2); } n15 = ")" { n14 = JTBToolkit.makeNodeToken(n15); } ( n17 = Production() { n16.addNode(n17); } )+ { n16.nodes.trimToSize(); } { return new JavaCCInput(n0, n1, n3, n5, n6, n8, n9, n11, n13, n14, n16); } } // MMa : changed all javacc_options into JavaCCOptions to conform to class name convention JavaCCOptions JavaCCOptions() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeListOptional n6 = null; OptionBinding n7 = null; NodeToken n8 = null; Token n9 = null; } { [ LOOKAHEAD( { getToken(1).image.equals("options") } ) { n6 = new NodeListOptional(); } { n1 = new NodeSequence(4); } n3 = "options" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n5 = "{" { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } ( n7 = OptionBinding() { n6.addNode(n7); } )* { n6.nodes.trimToSize(); } { n1.addNode(n6); } n9 = "}" { n8 = JTBToolkit.makeNodeToken(n9); } { n1.addNode(n8); } { n0.addNode(n1); } ] { Options.normalize(); } { return new JavaCCOptions(n0); } } // MMa : changed all option_binding into OptionBinding to conform to class name convention OptionBinding OptionBinding() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeChoice n11 = null; IntegerLiteral n12 = null; BooleanLiteral n13 = null; StringLiteral n14 = null; NodeToken n15 = null; Token n16 = null; // --- user BNFProduction java block --- String option_name; int int_val; boolean bool_val; String string_val; Token t = getToken(1); } { ( ( n2 = < IDENTIFIER > { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 4); } | n4 = "LOOKAHEAD" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1, 4); } | n6 = "IGNORE_CASE" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2, 4); } | n8 = "static" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3, 4); } ) ) { option_name = t.image; } n10 = "=" { n9 = JTBToolkit.makeNodeToken(n10); } ( ( n12 = IntegerLiteral() { int_val = jtbrt_IntegerLiteral; } { Options.setInputFileOption(t, getToken(0), option_name, new Integer(int_val)); } { n11 = new NodeChoice(n12, 0, 3); } | n13 = BooleanLiteral() { bool_val = jtbrt_BooleanLiteral; } { Options.setInputFileOption(t, getToken(0), option_name, new Boolean(bool_val)); } { n11 = new NodeChoice(n13, 1, 3); } | n14 = StringLiteral() { string_val = jtbrt_StringLiteral; } { Options.setInputFileOption(t, getToken(0), option_name, string_val); } { n11 = new NodeChoice(n14, 2, 3); } ) ) n16 = ";" { n15 = JTBToolkit.makeNodeToken(n16); } { return new OptionBinding(n0, n9, n11, n15); } } // MMa : changed all production into Production to conform to class name convention Production Production() : { // --- JTB generated node declarations --- NodeChoice n0 = null; JavaCodeProduction n1 = null; RegularExprProduction n2 = null; TokenManagerDecls n3 = null; BNFProduction n4 = null; } { ( LOOKAHEAD( 1 ) n1 = /* * Since JAVACODE is both a JavaCC reserved word and a Java identifier, * we need to give preference to "JavaCodeProduction" over * "BNFProduction". */ JavaCodeProduction() { n0 = new NodeChoice(n1, 0, 4); } | LOOKAHEAD( 1 ) n2 = /* * Since SKIP, TOKEN, etc. are both JavaCC reserved words and Java * identifiers, we need to give preference to "RegularExprProduction" * over "BNFProduction". */ RegularExprProduction() { n0 = new NodeChoice(n2, 1, 4); } | LOOKAHEAD( 1 ) n3 = /* * Since TOKEN_MGR_DECLS is both a JavaCC reserved word and a Java identifier, * we need to give preference to "TokenManagerDecls" over * "BNFProduction". */ TokenManagerDecls() { n0 = new NodeChoice(n3, 2, 4); } | n4 = BNFProduction() { n0 = new NodeChoice(n4, 3, 4); } ) { return new Production(n0); } } // MMa : changed all JavaCodeProduction into JavaCodeProduction_ (JavaCC specific class) // MMa : changed all javacode_production into JavaCodeProduction to conform to class name convention JavaCodeProduction JavaCodeProduction() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; AccessModifier n2 = null; ResultType n3 = null; Identifier n4 = null; FormalParameters n5 = null; NodeOptional n6 = new NodeOptional(); NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; Name n10 = null; NodeListOptional n11 = null; NodeSequence n12 = null; NodeToken n13 = null; Token n14 = null; Name n15 = null; Block n16 = null; // --- user BNFProduction java block --- JavaCodeProduction_ p = new JavaCodeProduction_(); String lhs; Token t = getToken(1); p.setFirstToken(t); List excName; p.setThrowsList(new ArrayList>()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); } { n1 = "JAVACODE" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = AccessModifier(p) n3 = ResultType(p.getReturnTypeTokens()) n4 = Identifier() { lhs = jtbrt_Identifier; } { p.setLhs(lhs); } n5 = FormalParameters(p.getParameterListTokens()) [ { n11 = new NodeListOptional(); } { n7 = new NodeSequence(5); } n9 = "throws" { n8 = JTBToolkit.makeNodeToken(n9); } { n7.addNode(n8); } { excName = new ArrayList(); } n10 = Name(excName) { n7.addNode(n10); } { p.getThrowsList().add(excName); } ( { n12 = new NodeSequence(4); } { excName = new ArrayList(); } n14 = "," { n13 = JTBToolkit.makeNodeToken(n14); } { n12.addNode(n13); } n15 = Name(excName) { n12.addNode(n15); } { p.getThrowsList().add(excName); } { n11.addNode(n12); } )* { n11.nodes.trimToSize(); } { n7.addNode(n11); } { n6.addNode(n7); } ] n16 = Block(p.getCodeTokens()) { p.setLastToken(getToken(0)); addproduction(p); } { return new JavaCodeProduction(n0, n2, n3, n4, n5, n6, n16); } } // MMa : changed all BNFProduction into BNFProduction_ (JavaCC specific class) // MMa : changed all bnf_production into BNFProduction to conform to class name convention BNFProduction BNFProduction() : { // --- JTB generated node declarations --- AccessModifier n0 = null; ResultType n1 = null; Identifier n2 = null; FormalParameters n3 = null; NodeOptional n4 = new NodeOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; Name n8 = null; NodeListOptional n9 = null; NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; Name n13 = null; NodeToken n14 = null; Token n15 = null; Block n16 = null; NodeToken n17 = null; Token n18 = null; ExpansionChoices n19 = null; NodeToken n20 = null; Token n21 = null; // --- user BNFProduction java block --- BNFProduction_ p = new BNFProduction_(); Container c = new Container(); Token t = getToken(1); p.setFirstToken(t); List excName; String lhs; p.setThrowsList(new ArrayList>()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); jumpPatched = false; } { n0 = AccessModifier(p) n1 = ResultType(p.getReturnTypeTokens()) n2 = Identifier() { lhs = jtbrt_Identifier; } { p.setLhs(lhs); } n3 = FormalParameters(p.getParameterListTokens()) [ { n9 = new NodeListOptional(); } { n5 = new NodeSequence(5); } n7 = "throws" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } { excName = new ArrayList(); } n8 = Name(excName) { n5.addNode(n8); } { p.getThrowsList().add(excName); } ( { n10 = new NodeSequence(4); } { excName = new ArrayList(); } n12 = "," { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } n13 = Name(excName) { n10.addNode(n13); } { p.getThrowsList().add(excName); } { n9.addNode(n10); } )* { n9.nodes.trimToSize(); } { n5.addNode(n9); } { n4.addNode(n5); } ] n15 = ":" { n14 = JTBToolkit.makeNodeToken(n15); } n16 = Block(p.getDeclarationTokens()) n18 = "{" { n17 = JTBToolkit.makeNodeToken(n18); } n19 = ExpansionChoices(c) n21 = "}" { n20 = JTBToolkit.makeNodeToken(n21); } { t = n21; } { p.setLastToken(t); p.setJumpPatched(jumpPatched); production_addexpansion(p, (Expansion_)(c.member)); addproduction(p); } { return new BNFProduction(n0, n1, n2, n3, n4, n14, n16, n17, n19, n20); } } AccessModifier AccessModifier(NormalProduction p) : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeChoice n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; // --- user BNFProduction java block --- Token t = null; } { ( ( n3 = "public" { n2 = JTBToolkit.makeNodeToken(n3); } { t = n3; } { n1 = new NodeChoice(n2, 0, 3); } | n5 = "protected" { n4 = JTBToolkit.makeNodeToken(n5); } { t = n5; } { n1 = new NodeChoice(n4, 1, 3); } | n7 = "private" { n6 = JTBToolkit.makeNodeToken(n7); } { t = n7; } { n1 = new NodeChoice(n6, 2, 3); } ) { n0.addNode(n1); } )? { if (t != null) { p.setAccessMod(t.image); } } { return new AccessModifier(n0); } } // MMa : changed all regular_expr_production into RegularExprProduction to conform to class name convention RegularExprProduction RegularExprProduction() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeChoice n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; NodeListOptional n14 = null; NodeSequence n15 = null; NodeToken n16 = null; Token n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; RegExprKind n22 = null; NodeOptional n23 = new NodeOptional(); NodeSequence n24 = null; NodeToken n25 = null; Token n26 = null; NodeToken n27 = null; Token n28 = null; NodeToken n29 = null; Token n30 = null; NodeToken n31 = null; Token n32 = null; NodeToken n33 = null; Token n34 = null; RegExprSpec n35 = null; NodeListOptional n36 = new NodeListOptional(); NodeSequence n37 = null; NodeToken n38 = null; Token n39 = null; RegExprSpec n40 = null; NodeToken n41 = null; Token n42 = null; // --- user BNFProduction java block --- TokenProduction p = new TokenProduction(); List states; Token t = p.firstToken = getToken(1); p.setLine(t.beginLine); p.setColumn(t.beginColumn); } { { // set p.lexStates assuming there is no state spec. // and then override if necessary. p.lexStates = new String[]{ "DEFAULT" }; } [ { n14 = new NodeListOptional(); } ( LOOKAHEAD( 2 ) { n2 = new NodeSequence(4); } n4 = "<" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n6 = "*" { n5 = JTBToolkit.makeNodeToken(n6); } { n2.addNode(n5); } n8 = ">" { n7 = JTBToolkit.makeNodeToken(n8); } { n2.addNode(n7); } { p.lexStates = null; } { n1 = new NodeChoice(n2, 0, 2); } | { n9 = new NodeSequence(7); } n11 = "<" { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } { states = new ArrayList(); } n13 = < IDENTIFIER > { n12 = JTBToolkit.makeNodeToken(n13); } { t = n13; } { n9.addNode(n12); } { states.add(t.image); } ( { n15 = new NodeSequence(3); } n17 = "," { n16 = JTBToolkit.makeNodeToken(n17); } { n15.addNode(n16); } n19 = < IDENTIFIER > { n18 = JTBToolkit.makeNodeToken(n19); } { t = n19; } { n15.addNode(n18); } { states.add(t.image); } { n14.addNode(n15); } )* { n14.nodes.trimToSize(); } { n9.addNode(n14); } n21 = ">" { n20 = JTBToolkit.makeNodeToken(n21); } { n9.addNode(n20); } { p.lexStates = new String[states.size()]; for (int i = 0; // ModMMa : workaround for sf plugin color syntaxing problem // i < states.size(); i != states.size(); i++) { p.lexStates[i] = states.get(i); } } { n1 = new NodeChoice(n9, 1, 2); } ) { n0.addNode(n1); } ] n22 = RegExprKind(p) { if (p.kind != TokenProduction.TOKEN && Options.getUserTokenManager()) { JavaCCErrors.warning(getToken(0), "Regular expression is being treated as if it were a TOKEN since option USER_TOKEN_MANAGER has been set to true."); } } [ { n24 = new NodeSequence(4); } n26 = "[" { n25 = JTBToolkit.makeNodeToken(n26); } { n24.addNode(n25); } n28 = "IGNORE_CASE" { n27 = JTBToolkit.makeNodeToken(n28); } { t = n28; } { n24.addNode(n27); } n30 = "]" { n29 = JTBToolkit.makeNodeToken(n30); } { n24.addNode(n29); } { p.ignoreCase = true; if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring \"IGNORE_CASE\" specification since option USER_TOKEN_MANAGER has been set to true."); } } { n23.addNode(n24); } ] n32 = ":" { n31 = JTBToolkit.makeNodeToken(n32); } n34 = "{" { n33 = JTBToolkit.makeNodeToken(n34); } n35 = RegExprSpec(p) ( { n37 = new NodeSequence(2); } n39 = "|" { n38 = JTBToolkit.makeNodeToken(n39); } { n37.addNode(n38); } n40 = RegExprSpec(p) { n37.addNode(n40); } { n36.addNode(n37); } )* { n36.nodes.trimToSize(); } n42 = "}" { n41 = JTBToolkit.makeNodeToken(n42); } { t = n42; } { p.lastToken = t; addregexpr(p); } { return new RegularExprProduction(n0, n22, n23, n31, n33, n35, n36, n41); } } // MMa : changed all token_manager_decls into TokenManagerDecls to conform to class name convention TokenManagerDecls TokenManagerDecls() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; ClassOrInterfaceBody n4 = null; // --- user BNFProduction java block --- List decls = new ArrayList(); Token t; } { n1 = "TOKEN_MGR_DECLS" { n0 = JTBToolkit.makeNodeToken(n1); } { t = n1; } n3 = ":" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = ClassOrInterfaceBody(false, decls) { add_token_manager_decls(t, decls); } { return new TokenManagerDecls(n0, n2, n4); } } // MMa : changed all regexpr_kind into RegExprKind to conform to class name convention RegExprKind RegExprKind(TokenProduction p) : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; } { ( n2 = "TOKEN" { n1 = JTBToolkit.makeNodeToken(n2); } { p.kind = TokenProduction.TOKEN; } { n0 = new NodeChoice(n1, 0, 4); } | n4 = "SPECIAL_TOKEN" { n3 = JTBToolkit.makeNodeToken(n4); } { p.kind = TokenProduction.SPECIAL; } { n0 = new NodeChoice(n3, 1, 4); } | n6 = "SKIP" { n5 = JTBToolkit.makeNodeToken(n6); } { p.kind = TokenProduction.SKIP; } { n0 = new NodeChoice(n5, 2, 4); } | n8 = "MORE" { n7 = JTBToolkit.makeNodeToken(n8); } { p.kind = TokenProduction.MORE; } { n0 = new NodeChoice(n7, 3, 4); } ) { return new RegExprKind(n0); } } // MMa : changed all RegExprSpec into RegExprSpec_ (JavaCC specific class) // MMa : changed all regexpr_spec into RegExprSpec to conform to class name convention RegExprSpec RegExprSpec(TokenProduction p) : { // --- JTB generated node declarations --- RegularExpression n0 = null; NodeOptional n1 = new NodeOptional(); Block n2 = null; NodeOptional n3 = new NodeOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; // --- user BNFProduction java block --- Container c = new Container(); Action act = new Action(); Token t = null; RegExprSpec_ res = new RegExprSpec_(); } { n0 = RegularExpression(c) { res.rexp = (RegularExpression_)c.member; res.rexp.tpContext = p; } [ { t = getToken(1); } n2 = Block(act.getActionTokens()) { if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring action in regular expression specification since option USER_TOKEN_MANAGER has been set to true."); } if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Actions are not permitted on private (#) regular expressions."); } } { n1.addNode(n2); } ] [ { n4 = new NodeSequence(3); } n6 = ":" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8 = < IDENTIFIER > { n7 = JTBToolkit.makeNodeToken(n8); } { t = n8; } { n4.addNode(n7); } { res.nextState = t.image; if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Lexical state changes are not permitted after private (#) regular expressions."); } } { n3.addNode(n4); } ] { res.act = act; res.nsTok = t; p.respecs.add(res); } { return new RegExprSpec(n0, n1, n3); } } // MMa : changed all expansion_choices into ExpansionChoices to conform to class name convention ExpansionChoices ExpansionChoices(Container c1) : { // --- JTB generated node declarations --- Expansion n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expansion n5 = null; // --- user BNFProduction java block --- boolean morethanone = false; Choice ch = new Choice(); Container c2 = new Container(); } { n0 = Expansion(c1) ( { n2 = new NodeSequence(3); } n4 = "|" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Expansion(c2) { n2.addNode(n5); } { if (morethanone) { ch.getChoices().add((Expansion_)c2.member); ((Expansion_)c2.member).parent = ch; } else { morethanone = true; ch = new Choice((Expansion_)c1.member); ((Expansion_)c1.member).parent = ch; ch.getChoices().add((Expansion_)c2.member); ((Expansion_)c2.member).parent = ch; } } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { if (morethanone) { c1.member = ch; } } { return new ExpansionChoices(n0, n1); } } // MMa : changed all Expansion into Expansion_ (JavaCC specific class) // MMa : changed all expansion into Expansion to conform to class name convention Expansion Expansion(Container c1) : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; LocalLookahead n6 = null; NodeToken n7 = null; Token n8 = null; NodeList n9 = new NodeList(); ExpansionUnit n10 = null; // --- user BNFProduction java block --- Sequence seq = new Sequence(); Container c2 = new Container(); Lookahead la = new Lookahead(); Token t = getToken(1); seq.setLine(t.beginLine); seq.setColumn(t.beginColumn); la.setLine(t.beginLine); la.setColumn(t.beginColumn); } { { la.setAmount(Options.getLookahead()); la.setLaExpansion(null); la.setExplicit(false); } ( LOOKAHEAD( 1 ) { n1 = new NodeSequence(5); } n3 = "LOOKAHEAD" { n2 = JTBToolkit.makeNodeToken(n3); } { t = n3; } { n1.addNode(n2); } n5 = "(" { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } n6 = LocalLookahead() { la = jtbrt_LocalLookahead; } { n1.addNode(n6); } n8 = ")" { n7 = JTBToolkit.makeNodeToken(n8); } { n1.addNode(n7); } { if (inLocalLA != 0 && la.getAmount() != 0) { JavaCCErrors.warning(t, "Only semantic lookahead specifications within other lookahead specifications is considered. Syntactic lookahead is ignored."); } } { n0.addNode(n1); } )? { seq.units.add(la); } ( LOOKAHEAD( 0, { notTailOfExpansionUnit() } ) n10 = ExpansionUnit(c2) { seq.units.add((Expansion_)c2.member); ((Expansion_)c2.member).parent = seq; ((Expansion_)c2.member).ordinal = seq.units.size() - 1; } { n9.addNode(n10); } )+ { n9.nodes.trimToSize(); } { if (la.getLaExpansion() == null) { la.setLaExpansion(seq); } c1.member = seq; } { return new Expansion(n0, n9); } } // MMa : changed all local_lookahead into LocalLookahead to conform to class name convention LocalLookahead LocalLookahead() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); IntegerLiteral n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); ExpansionChoices n6 = null; NodeOptional n7 = new NodeOptional(); NodeToken n8 = null; Token n9 = null; NodeOptional n10 = new NodeOptional(); NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; // --- user BNFProduction java block --- Lookahead la = new Lookahead(); la.setExplicit(true); Token t = getToken(1); la.setLine(t.beginLine); la.setColumn(t.beginColumn); la.setLaExpansion(null); Container c = new Container(); boolean commaAtEnd = false, emptyLA = true; int laAmount; inLocalLA++; } { [ /* * The lookahead of 1 is to turn off the warning message that lets * us know that an expansion choice can also start with an integer * literal because a primary expression can do the same. But we * know that this is what we want. */ LOOKAHEAD( 1 ) n1 = IntegerLiteral() { laAmount = jtbrt_IntegerLiteral; } { emptyLA = false; la.setAmount(laAmount); } { n0.addNode(n1); } ] [ LOOKAHEAD( 0, { !emptyLA && (getToken(1).kind != RPAREN) } ) n4 = "," { n3 = JTBToolkit.makeNodeToken(n4); } { commaAtEnd = true; } { n2.addNode(n3); } ] [ LOOKAHEAD( 0, { getToken(1).kind != RPAREN && getToken(1).kind != LBRACE } ) n6 = ExpansionChoices(c) { emptyLA = false; commaAtEnd = false; la.setLaExpansion((Expansion_)c.member); } { n5.addNode(n6); } ] [ LOOKAHEAD( 0, { !emptyLA && !commaAtEnd && (getToken(1).kind != RPAREN) } ) n9 = "," { n8 = JTBToolkit.makeNodeToken(n9); } { commaAtEnd = true; } { n7.addNode(n8); } ] [ LOOKAHEAD( 0, { emptyLA || commaAtEnd } ) { n11 = new NodeSequence(4); } n13 = "{" { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } n14 = Expression(la.getActionTokens()) { n11.addNode(n14); } n16 = "}" { n15 = JTBToolkit.makeNodeToken(n16); } { n11.addNode(n15); } { if (emptyLA) { la.setAmount(0); } } { n10.addNode(n11); } ] { inLocalLA--; jtbrt_LocalLookahead = la; } { return new LocalLookahead(n0, n2, n5, n7, n10); } } // MMa : changed all expansion_unit into ExpansionUnit to conform to class name convention ExpansionUnit ExpansionUnit(Container c) : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; LocalLookahead n6 = null; NodeToken n7 = null; Token n8 = null; Block n9 = null; NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; ExpansionChoices n13 = null; NodeToken n14 = null; Token n15 = null; ExpansionUnitInTCF n16 = null; NodeSequence n17 = null; NodeOptional n18 = new NodeOptional(); NodeSequence n19 = null; PrimaryExpression n20 = null; NodeToken n21 = null; Token n22 = null; NodeChoice n23 = null; NodeSequence n24 = null; Identifier n25 = null; Arguments n26 = null; NodeSequence n27 = null; RegularExpression n28 = null; NodeOptional n29 = new NodeOptional(); NodeSequence n30 = null; NodeToken n31 = null; Token n32 = null; NodeToken n33 = null; Token n34 = null; NodeSequence n35 = null; NodeToken n36 = null; Token n37 = null; ExpansionChoices n38 = null; NodeToken n39 = null; Token n40 = null; NodeOptional n41 = new NodeOptional(); NodeChoice n42 = null; NodeToken n43 = null; Token n44 = null; NodeToken n45 = null; Token n46 = null; NodeToken n47 = null; Token n48 = null; // --- user BNFProduction java block --- String name; List lhsTokens = new ArrayList(); NonTerminal nt; Action act; Token t; Lookahead la; } { ( LOOKAHEAD( 1 ) { n1 = new NodeSequence(5); } n3 = "LOOKAHEAD" { n2 = JTBToolkit.makeNodeToken(n3); } { /* * We give this priority over primary expressions which use LOOKAHEAD as the * name of its identifier. */ t = n3; } { n1.addNode(n2); } n5 = "(" { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } n6 = LocalLookahead() { la = jtbrt_LocalLookahead; } { n1.addNode(n6); } n8 = ")" { n7 = JTBToolkit.makeNodeToken(n8); } { n1.addNode(n7); } { // Now set the la_expansion field of la with a dummy expansion (we use EOF). la.setLaExpansion(new REndOfFile()); // Create a singleton choice with an empty action. Choice ch = new Choice(t); Sequence seq = new Sequence(t, la); la.parent = seq; la.ordinal = 0; act = new Action(); act.setLine(t.beginLine); act.setColumn(t.beginColumn); seq.units.add(act); act.parent = seq; act.ordinal = 1; ch.getChoices().add(seq); seq.parent = ch; seq.ordinal = 0; if (la.getAmount() != 0) { if (la.getActionTokens().size() != 0) { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. Only semantic lookahead will be considered here."); } else { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. This will be ignored."); } } c.member = ch; } { n0 = new NodeChoice(n1, 0, 6); } | { act = new Action(); t = getToken(1); act.setLine(t.beginLine); act.setColumn(t.beginColumn); inAction = true; } n9 = Block(act.getActionTokens()) { inAction = false; if (inLocalLA != 0) { JavaCCErrors.warning(t, "Action within lookahead specification will be ignored."); } c.member = act; } { n0 = new NodeChoice(n9, 1, 6); } | { n10 = new NodeSequence(4); } n12 = "[" { n11 = JTBToolkit.makeNodeToken(n12); } { t = n12; } { n10.addNode(n11); } n13 = ExpansionChoices(c) { n10.addNode(n13); } n15 = "]" { n14 = JTBToolkit.makeNodeToken(n15); } { n10.addNode(n14); } { c.member = new ZeroOrOne(t, (Expansion_)c.member); } { n0 = new NodeChoice(n10, 2, 6); } // MMa : replaced by new production ExpansionUnitInTCF // | // { // Container expch = new Container(); // List> types = new ArrayList>(); // List ids = new ArrayList(); // List> catchblks = new ArrayList>(); // List finallyblk = null; // List vec = new ArrayList(); // Token t0; // } // t0 = "try" "{" ExpansionChoices(expch) "}" // ( // "catch" "(" Name(vec) t = < IDENTIFIER > ")" // { // types.add(vec); // ids.add(t); // vec = new ArrayList(); // inAction = true; // } // Block(vec) // { // inAction = false; // catchblks.add(vec); // vec = new ArrayList(); // } // )* // [ // { // inAction = true; // } // "finally" Block(vec) // { // inAction = false; // finallyblk = vec; // } // ] // { // makeTryBlock(t0, c, expch, types, ids, catchblks, finallyblk); // } | n16 = ExpansionUnitInTCF(c) { n0 = new NodeChoice(n16, 3, 6); } | LOOKAHEAD( Identifier() | StringLiteral() | "<" | PrimaryExpression() "=" ) { n17 = new NodeSequence(2); } [ LOOKAHEAD( PrimaryExpression() "=" ) { n19 = new NodeSequence(5); } { Token first = getToken(1); } n20 = PrimaryExpression() { n19.addNode(n20); } { Token last = getToken(0); } n22 = "=" { n21 = JTBToolkit.makeNodeToken(n22); } { n19.addNode(n21); } { t = first; while (true) { lhsTokens.add(t); if (t == last) break; t = t.next; } } { n18.addNode(n19); } ] { n17.addNode(n18); } ( ( LOOKAHEAD( Identifier() "(" ) { n24 = new NodeSequence(4); } { nt = new NonTerminal(); t = getToken(1); nt.setLine(t.beginLine); nt.setColumn(t.beginColumn); nt.setLhsTokens(lhsTokens); } n25 = Identifier() { name = jtbrt_Identifier; } { n24.addNode(n25); } n26 = Arguments(nt.getArgumentTokens()) { n24.addNode(n26); } { nt.setName(name); c.member = nt; } { n23 = new NodeChoice(n24, 0, 2); } | { n27 = new NodeSequence(3); } n28 = RegularExpression(c) { n27.addNode(n28); } { ((RegularExpression_)(c.member)).lhsTokens = lhsTokens; add_inline_regexpr((RegularExpression_)(c.member)); } [ { n30 = new NodeSequence(3); } n32 = "." { n31 = JTBToolkit.makeNodeToken(n32); } { n30.addNode(n31); } n34 = < IDENTIFIER > { n33 = JTBToolkit.makeNodeToken(n34); } { t = n34; } { n30.addNode(n33); } { ((RegularExpression_)(c.member)).rhsToken = t; } { n29.addNode(n30); } ] { n27.addNode(n29); } { n23 = new NodeChoice(n27, 1, 2); } ) ) { n17.addNode(n23); } { n0 = new NodeChoice(n17, 4, 6); } | { n35 = new NodeSequence(4); } n37 = "(" { n36 = JTBToolkit.makeNodeToken(n37); } { t = n37; } { n35.addNode(n36); } n38 = ExpansionChoices(c) { n35.addNode(n38); } n40 = ")" { n39 = JTBToolkit.makeNodeToken(n40); } { n35.addNode(n39); } ( ( n44 = "+" { n43 = JTBToolkit.makeNodeToken(n44); } { c.member = new OneOrMore(t, (Expansion_)c.member); } { n42 = new NodeChoice(n43, 0, 3); } | n46 = "*" { n45 = JTBToolkit.makeNodeToken(n46); } { c.member = new ZeroOrMore(t, (Expansion_)c.member); } { n42 = new NodeChoice(n45, 1, 3); } | n48 = "?" { n47 = JTBToolkit.makeNodeToken(n48); } { c.member = new ZeroOrOne(t, (Expansion_)c.member); } { n42 = new NodeChoice(n47, 2, 3); } ) { n41.addNode(n42); } )? { n35.addNode(n41); } { n0 = new NodeChoice(n35, 5, 6); } ) { return new ExpansionUnit(n0); } } // MMa : added to create a node ExpansionUnitInTCF ExpansionUnitInTCF(Container c) : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; ExpansionChoices n4 = null; NodeToken n5 = null; Token n6 = null; NodeListOptional n7 = new NodeListOptional(); NodeSequence n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; Name n13 = null; NodeToken n14 = null; Token n15 = null; NodeToken n16 = null; Token n17 = null; Block n18 = null; NodeOptional n19 = new NodeOptional(); NodeSequence n20 = null; NodeToken n21 = null; Token n22 = null; Block n23 = null; // --- user BNFProduction java block --- Token t; } { { Container expch = new Container(); List> types = new ArrayList>(); List ids = new ArrayList(); List> catchblks = new ArrayList>(); List finallyblk = null; List vec = new ArrayList(); Token t0; } n1 = "try" { n0 = JTBToolkit.makeNodeToken(n1); } { t0 = n1; } n3 = "{" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = ExpansionChoices(expch) n6 = "}" { n5 = JTBToolkit.makeNodeToken(n6); } ( { n8 = new NodeSequence(8); } n10 = "catch" { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n12 = "(" { n11 = JTBToolkit.makeNodeToken(n12); } { n8.addNode(n11); } n13 = Name(vec) { n8.addNode(n13); } n15 = < IDENTIFIER > { n14 = JTBToolkit.makeNodeToken(n15); } { t = n15; } { n8.addNode(n14); } n17 = ")" { n16 = JTBToolkit.makeNodeToken(n17); } { n8.addNode(n16); } { types.add(vec); ids.add(t); vec = new ArrayList(); inAction = true; } n18 = Block(vec) { n8.addNode(n18); } { inAction = false; catchblks.add(vec); vec = new ArrayList(); } { n7.addNode(n8); } )* { n7.nodes.trimToSize(); } [ { n20 = new NodeSequence(4); } { inAction = true; } n22 = "finally" { n21 = JTBToolkit.makeNodeToken(n22); } { n20.addNode(n21); } n23 = Block(vec) { n20.addNode(n23); } { inAction = false; finallyblk = vec; } { n19.addNode(n20); } ] { makeTryBlock(t0, c, expch, types, ids, catchblks, finallyblk); } { return new ExpansionUnitInTCF(n0, n2, n4, n5, n7, n19); } } // MMa : changed all RegularExpression into RegularExpression_ (JavaCC specific class) // MMa : changed all regular_expression into RegularExpression to conform to class name convention RegularExpression RegularExpression(Container c) : { // --- JTB generated node declarations --- NodeChoice n0 = null; StringLiteral n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; NodeOptional n7 = null; NodeToken n8 = null; Token n9 = null; Identifier n10 = null; NodeToken n11 = null; Token n12 = null; ComplexRegularExpressionChoices n13 = null; NodeToken n14 = null; Token n15 = null; NodeSequence n16 = null; NodeToken n17 = null; Token n18 = null; Identifier n19 = null; NodeToken n20 = null; Token n21 = null; NodeSequence n22 = null; NodeToken n23 = null; Token n24 = null; NodeToken n25 = null; Token n26 = null; NodeToken n27 = null; Token n28 = null; // --- user BNFProduction java block --- REndOfFile ef; String image; boolean private_rexp = false; Token t = getToken(1); } { ( n1 = StringLiteral() { image = jtbrt_StringLiteral; } { c.member = new RStringLiteral(t, image); } { n0 = new NodeChoice(n1, 0, 4); } | LOOKAHEAD( 3 ) { n2 = new NodeSequence(6); } { image = ""; } n4 = { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } [ { n7 = new NodeOptional(); } { n6 = new NodeSequence(3); } [ n9 = "#" { n8 = JTBToolkit.makeNodeToken(n9); } { private_rexp = true; } { n7.addNode(n8); } ] { n6.addNode(n7); } n10 = Identifier() { image = jtbrt_Identifier; } { n6.addNode(n10); } n12 = ":" { n11 = JTBToolkit.makeNodeToken(n12); } { n6.addNode(n11); } { n5.addNode(n6); } ] { n2.addNode(n5); } n13 = ComplexRegularExpressionChoices(c) { n2.addNode(n13); } n15 = "> { n14 = JTBToolkit.makeNodeToken(n15); } { n2.addNode(n14); } { RegularExpression_ re; if (c.member instanceof RJustName) { RSequence seq = new RSequence(); seq.units.add((RegularExpression_)c.member); re = seq; } else { re = (RegularExpression_)c.member; } re.label = image; re.private_rexp = private_rexp; re.setLine(t.beginLine); re.setColumn(t.beginColumn); c.member = re; } { n0 = new NodeChoice(n2, 1, 4); } | LOOKAHEAD( 2 ) { n16 = new NodeSequence(4); } n18 = "<" { n17 = JTBToolkit.makeNodeToken(n18); } { n16.addNode(n17); } n19 = Identifier() { image = jtbrt_Identifier; } { n16.addNode(n19); } n21 = ">" { n20 = JTBToolkit.makeNodeToken(n21); } { n16.addNode(n20); } { c.member = new RJustName(t, image); } { n0 = new NodeChoice(n16, 2, 4); } | { n22 = new NodeSequence(4); } n24 = "<" { n23 = JTBToolkit.makeNodeToken(n24); } { n22.addNode(n23); } n26 = "EOF" { n25 = JTBToolkit.makeNodeToken(n26); } { n22.addNode(n25); } n28 = ">" { n27 = JTBToolkit.makeNodeToken(n28); } { n22.addNode(n27); } { ef = new REndOfFile(); ef.setLine(t.beginLine); ef.setColumn(t.beginColumn); ef.ordinal = 0; c.member = ef; } { n0 = new NodeChoice(n22, 3, 4); } ) { return new RegularExpression(n0); } } // MMa : changed all complex_regular_expression_choices into ComplexRegularExpressionChoices to conform to class name convention ComplexRegularExpressionChoices ComplexRegularExpressionChoices(Container c1) : { // --- JTB generated node declarations --- ComplexRegularExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ComplexRegularExpression n5 = null; // --- user BNFProduction java block --- boolean morethanone = false; RChoice ch = new RChoice(); Container c2 = new Container(); } { n0 = ComplexRegularExpression(c1) ( { n2 = new NodeSequence(3); } n4 = "|" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = ComplexRegularExpression(c2) { n2.addNode(n5); } { if (morethanone) { ch.getChoices().add((RegularExpression_)c2.member); } else { morethanone = true; ch = new RChoice(); ch.setLine(((RegularExpression_)c1.member).getLine()); ch.setColumn(((RegularExpression_)c1.member).getColumn()); ch.getChoices().add((RegularExpression_)c1.member); ch.getChoices().add((RegularExpression_)c2.member); } } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { if (morethanone) { c1.member = ch; } } { return new ComplexRegularExpressionChoices(n0, n1); } } // MMa : changed all complex_regular_expression into ComplexRegularExpression to conform to class name convention ComplexRegularExpression ComplexRegularExpression(Container c1) : { // --- JTB generated node declarations --- NodeList n0 = new NodeList(); ComplexRegularExpressionUnit n1 = null; // --- user BNFProduction java block --- int count = 0; RSequence seq = new RSequence(); Container c2 = new Container(); } { ( n1 = ComplexRegularExpressionUnit(c2) { count++; if (count == 1) { c1.member = c2.member; // if count does not go beyond 1, we are done. } else if (count == 2) { // more than 1, so create a sequence. seq = new RSequence(); seq.setLine(((RegularExpression_)c1.member).getLine()); seq.setColumn(((RegularExpression_)c1.member).getColumn()); seq.units.add((RegularExpression_)c1.member); seq.units.add((RegularExpression_)c2.member); } else { seq.units.add((RegularExpression_)c2.member); } } { n0.addNode(n1); } )+ { n0.nodes.trimToSize(); } { if (count > 1) { c1.member = seq; } } { return new ComplexRegularExpression(n0); } } // MMa : changed all complex_regular_expression_unit into ComplexRegularExpressionUnit to conform to class name convention ComplexRegularExpressionUnit ComplexRegularExpressionUnit(Container c) : { // --- JTB generated node declarations --- NodeChoice n0 = null; StringLiteral n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Identifier n5 = null; NodeToken n6 = null; Token n7 = null; CharacterList n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; ComplexRegularExpressionChoices n12 = null; NodeToken n13 = null; Token n14 = null; NodeOptional n15 = new NodeOptional(); NodeChoice n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeSequence n23 = null; NodeToken n24 = null; Token n25 = null; IntegerLiteral n26 = null; NodeOptional n27 = null; NodeSequence n28 = null; NodeToken n29 = null; Token n30 = null; NodeOptional n31 = null; IntegerLiteral n32 = null; NodeToken n33 = null; Token n34 = null; // --- user BNFProduction java block --- String image; Token t = getToken(1); int r1 = 0, r2 = -1; boolean hasMax = false; } { ( n1 = StringLiteral() { image = jtbrt_StringLiteral; } { c.member = new RStringLiteral(t, image); } { n0 = new NodeChoice(n1, 0, 4); } | { n2 = new NodeSequence(4); } n4 = "<" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Identifier() { image = jtbrt_Identifier; } { n2.addNode(n5); } n7 = ">" { n6 = JTBToolkit.makeNodeToken(n7); } { n2.addNode(n6); } { c.member = new RJustName(t, image); } { n0 = new NodeChoice(n2, 1, 4); } | n8 = CharacterList(c) { n0 = new NodeChoice(n8, 2, 4); } | { n9 = new NodeSequence(4); } n11 = "(" { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } n12 = ComplexRegularExpressionChoices(c) { n9.addNode(n12); } n14 = ")" { n13 = JTBToolkit.makeNodeToken(n14); } { n9.addNode(n13); } ( { n27 = new NodeOptional(); } ( n18 = "+" { n17 = JTBToolkit.makeNodeToken(n18); } { c.member = new ROneOrMore(t, (RegularExpression_)c.member); } { n16 = new NodeChoice(n17, 0, 4); } | n20 = "*" { n19 = JTBToolkit.makeNodeToken(n20); } { c.member = new RZeroOrMore(t, (RegularExpression_)c.member); } { n16 = new NodeChoice(n19, 1, 4); } | n22 = "?" { n21 = JTBToolkit.makeNodeToken(n22); } { RZeroOrOne zorexp = new RZeroOrOne(); zorexp.setLine(t.beginLine); zorexp.setColumn(t.beginColumn); zorexp.regexpr = (RegularExpression_)c.member; c.member = zorexp; } { n16 = new NodeChoice(n21, 2, 4); } | { n23 = new NodeSequence(5); } n25 = "{" { n24 = JTBToolkit.makeNodeToken(n25); } { n23.addNode(n24); } n26 = IntegerLiteral() { r1 = jtbrt_IntegerLiteral; } { n23.addNode(n26); } [ { n31 = new NodeOptional(); } { n28 = new NodeSequence(3); } n30 = "," { n29 = JTBToolkit.makeNodeToken(n30); } { n28.addNode(n29); } { hasMax = true; } [ n32 = IntegerLiteral() { r2 = jtbrt_IntegerLiteral; } { n31.addNode(n32); } ] { n28.addNode(n31); } { n27.addNode(n28); } ] { n23.addNode(n27); } n34 = "}" { n33 = JTBToolkit.makeNodeToken(n34); } { n23.addNode(n33); } { RRepetitionRange rrrexp = new RRepetitionRange(); rrrexp.setLine(t.beginLine); rrrexp.setColumn(t.beginColumn); rrrexp.min = r1; rrrexp.max = r2; rrrexp.hasMax = hasMax; rrrexp.regexpr = (RegularExpression_)c.member; c.member = rrrexp; } { n16 = new NodeChoice(n23, 3, 4); } ) { n15.addNode(n16); } )? { n9.addNode(n15); } { n0 = new NodeChoice(n9, 3, 4); } ) { return new ComplexRegularExpressionUnit(n0); } } // MMa : changed all character_list into CharacterList to conform to class name convention CharacterList CharacterList(Container c1) : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; CharacterDescriptor n7 = null; NodeListOptional n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; CharacterDescriptor n12 = null; NodeToken n13 = null; Token n14 = null; // --- user BNFProduction java block --- RCharacterList chlist = new RCharacterList(); Token t = getToken(1); chlist.setLine(t.beginLine); chlist.setColumn(t.beginColumn); Container c2 = new Container(); } { [ n2 = "~" { n1 = JTBToolkit.makeNodeToken(n2); } { chlist.negated_list = true; } { n0.addNode(n1); } ] n4 = "[" { n3 = JTBToolkit.makeNodeToken(n4); } [ { n8 = new NodeListOptional(); } { n6 = new NodeSequence(3); } n7 = CharacterDescriptor(c2) { n6.addNode(n7); } { chlist.descriptors.add(c2.member); } ( { n9 = new NodeSequence(3); } n11 = "," { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } n12 = CharacterDescriptor(c2) { n9.addNode(n12); } { chlist.descriptors.add(c2.member); } { n8.addNode(n9); } )* { n8.nodes.trimToSize(); } { n6.addNode(n8); } { n5.addNode(n6); } ] n14 = "]" { n13 = JTBToolkit.makeNodeToken(n14); } { c1.member = chlist; } { return new CharacterList(n0, n3, n5, n13); } } // MMa : changed all character_descriptor into CharacterDescriptor to conform to class name convention CharacterDescriptor CharacterDescriptor(Container c) : { // --- JTB generated node declarations --- StringLiteral n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; StringLiteral n5 = null; // --- user BNFProduction java block --- char c1, c2 = ' '; // unnecessary initialization to make Java compiler happy! boolean isrange = false; String imageL, imageR; Token t = getToken(1); } { n0 = StringLiteral() { imageL = jtbrt_StringLiteral; } { c1 = character_descriptor_assign(getToken(0), imageL); } [ { n2 = new NodeSequence(3); } n4 = "-" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = StringLiteral() { imageR = jtbrt_StringLiteral; } { n2.addNode(n5); } { isrange = true; c2 = character_descriptor_assign(getToken(0), imageR, imageL); } { n1.addNode(n2); } ] { if (isrange) { CharacterRange cr = new CharacterRange(); cr.setLine(t.beginLine); cr.setColumn(t.beginColumn); cr.setLeft(c1); cr.setRight(c2); c.member = cr; } else { SingleCharacter sc = new SingleCharacter(); sc.setLine(t.beginLine); sc.setColumn(t.beginColumn); sc.ch = c1; c.member = sc; } } { return new CharacterDescriptor(n0, n1); } } // MMa : changed all identifier into Identifier to conform to class name convention Identifier Identifier() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; // --- user BNFProduction java block --- Token t = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } { t = n1; } { jtbrt_Identifier = t.image; } { return new Identifier(n0); } } /********************************************** * THE JAVA GRAMMAR SPECIFICATION STARTS HERE * **********************************************/ /* * The Java grammar is modified to use sequences of tokens * for the missing tokens - those that include "<<" and ">>". */ /* * The following production defines Java identifiers - it * includes the reserved words of JavaCC also. */ JavaIdentifier JavaIdentifier() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeToken n23 = null; Token n24 = null; } { ( ( n2 = < IDENTIFIER > { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 12); } | n4 = "LOOKAHEAD" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1, 12); } | n6 = "IGNORE_CASE" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2, 12); } | n8 = "PARSER_BEGIN" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3, 12); } | n10 = "PARSER_END" { n9 = JTBToolkit.makeNodeToken(n10); } { n0 = new NodeChoice(n9, 4, 12); } | n12 = "JAVACODE" { n11 = JTBToolkit.makeNodeToken(n12); } { n0 = new NodeChoice(n11, 5, 12); } | n14 = "TOKEN" { n13 = JTBToolkit.makeNodeToken(n14); } { n0 = new NodeChoice(n13, 6, 12); } | n16 = "SPECIAL_TOKEN" { n15 = JTBToolkit.makeNodeToken(n16); } { n0 = new NodeChoice(n15, 7, 12); } | n18 = "MORE" { n17 = JTBToolkit.makeNodeToken(n18); } { n0 = new NodeChoice(n17, 8, 12); } | n20 = "SKIP" { n19 = JTBToolkit.makeNodeToken(n20); } { n0 = new NodeChoice(n19, 9, 12); } | n22 = "TOKEN_MGR_DECLS" { n21 = JTBToolkit.makeNodeToken(n22); } { n0 = new NodeChoice(n21, 10, 12); } | n24 = "EOF" { n23 = JTBToolkit.makeNodeToken(n24); } { n0 = new NodeChoice(n23, 11, 12); } ) ) { Token retval = getToken(0); retval.kind = IDENTIFIER; jtbrt_JavaIdentifier = retval; } { return new JavaIdentifier(n0); } } /* * Program structuring syntax follows. */ CompilationUnit CompilationUnit() : /* * The is deleted since the compilation unit is embedded * within grammar code. */ { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); PackageDeclaration n1 = null; NodeListOptional n2 = new NodeListOptional(); ImportDeclaration n3 = null; NodeListOptional n4 = new NodeListOptional(); TypeDeclaration n5 = null; // --- user BNFProduction java block --- set_initial_cu_token(getToken(1)); } { [ LOOKAHEAD( ( Annotation() )* "package" ) n1 = PackageDeclaration() { n0.addNode(n1); } ] ( n3 = ImportDeclaration() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } ( n5 = TypeDeclaration() { n4.addNode(n5); } )* { n4.nodes.trimToSize(); } { insertionpointerrors(getToken(1)); } { return new CompilationUnit(n0, n2, n4); } } PackageDeclaration PackageDeclaration() : { // --- JTB generated node declarations --- NodeListOptional n0 = new NodeListOptional(); Annotation n1 = null; NodeToken n2 = null; Token n3 = null; Name n4 = null; NodeToken n5 = null; Token n6 = null; } { // MMa : fixed grammar // Modifiers() "package" Name(null) ";" ( n1 = Annotation() { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n3 = "package" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Name(null) n6 = ";" { n5 = JTBToolkit.makeNodeToken(n6); } { return new PackageDeclaration(n0, n2, n4, n5); } } ImportDeclaration ImportDeclaration() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; Name n5 = null; NodeOptional n6 = new NodeOptional(); NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; } { n1 = "import" { n0 = JTBToolkit.makeNodeToken(n1); } [ n4 = "static" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } ] n5 = Name(null) [ { n7 = new NodeSequence(2); } n9 = "." { n8 = JTBToolkit.makeNodeToken(n9); } { n7.addNode(n8); } n11 = "*" { n10 = JTBToolkit.makeNodeToken(n11); } { n7.addNode(n10); } { n6.addNode(n7); } ] n13 = ";" { n12 = JTBToolkit.makeNodeToken(n13); } { return new ImportDeclaration(n0, n2, n5, n6, n12); } } /* * Modifiers. We match all modifiers in a single rule to reduce the chances of * syntax errors for simple modifier mistakes. It will also enable us to give * better error messages. */ Modifiers Modifiers() : { // --- JTB generated node declarations --- NodeListOptional n0 = new NodeListOptional(); NodeChoice n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; NodeToken n14 = null; Token n15 = null; NodeToken n16 = null; Token n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; Annotation n24 = null; // --- user BNFProduction java block --- int modifiers = 0; } { ( LOOKAHEAD( 2 ) ( ( n3 = "public" { n2 = JTBToolkit.makeNodeToken(n3); } { modifiers |= ModifierSet.M_PUBLIC; } { n1 = new NodeChoice(n2, 0, 12); } | n5 = "static" { n4 = JTBToolkit.makeNodeToken(n5); } { modifiers |= ModifierSet.M_STATIC; } { n1 = new NodeChoice(n4, 1, 12); } | n7 = "protected" { n6 = JTBToolkit.makeNodeToken(n7); } { modifiers |= ModifierSet.M_PROTECTED; } { n1 = new NodeChoice(n6, 2, 12); } | n9 = "private" { n8 = JTBToolkit.makeNodeToken(n9); } { modifiers |= ModifierSet.M_PRIVATE; } { n1 = new NodeChoice(n8, 3, 12); } | n11 = "final" { n10 = JTBToolkit.makeNodeToken(n11); } { modifiers |= ModifierSet.M_FINAL; } { n1 = new NodeChoice(n10, 4, 12); } | n13 = "abstract" { n12 = JTBToolkit.makeNodeToken(n13); } { modifiers |= ModifierSet.M_ABSTRACT; } { n1 = new NodeChoice(n12, 5, 12); } | n15 = "synchronized" { n14 = JTBToolkit.makeNodeToken(n15); } { modifiers |= ModifierSet.M_SYNCHRONIZED; } { n1 = new NodeChoice(n14, 6, 12); } | n17 = "native" { n16 = JTBToolkit.makeNodeToken(n17); } { modifiers |= ModifierSet.M_NATIVE; } { n1 = new NodeChoice(n16, 7, 12); } | n19 = "transient" { n18 = JTBToolkit.makeNodeToken(n19); } { modifiers |= ModifierSet.M_TRANSIENT; } { n1 = new NodeChoice(n18, 8, 12); } | n21 = "volatile" { n20 = JTBToolkit.makeNodeToken(n21); } { modifiers |= ModifierSet.M_VOLATILE; } { n1 = new NodeChoice(n20, 9, 12); } | n23 = "strictfp" { n22 = JTBToolkit.makeNodeToken(n23); } { modifiers |= ModifierSet.M_STRICTFP; } { n1 = new NodeChoice(n22, 10, 12); } | n24 = Annotation() { n1 = new NodeChoice(n24, 11, 12); } ) ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } { jtbrt_Modifiers = modifiers; } { return new Modifiers(n0); } } /* * Declaration syntax follows. */ TypeDeclaration TypeDeclaration() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeSequence n3 = null; Modifiers n4 = null; NodeChoice n5 = null; ClassOrInterfaceDeclaration n6 = null; EnumDeclaration n7 = null; AnnotationTypeDeclaration n8 = null; } { ( n2 = ";" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 2); } | { n3 = new NodeSequence(2); } n4 = Modifiers() { n3.addNode(n4); } ( ( n6 = ClassOrInterfaceDeclaration() { n5 = new NodeChoice(n6, 0, 3); } | n7 = EnumDeclaration() { n5 = new NodeChoice(n7, 1, 3); } | n8 = AnnotationTypeDeclaration() { n5 = new NodeChoice(n8, 2, 3); } ) ) { n3.addNode(n5); } { n0 = new NodeChoice(n3, 1, 2); } ) { return new TypeDeclaration(n0); } } ClassOrInterfaceDeclaration ClassOrInterfaceDeclaration() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeOptional n7 = new NodeOptional(); TypeParameters n8 = null; NodeOptional n9 = new NodeOptional(); ExtendsList n10 = null; NodeOptional n11 = new NodeOptional(); ImplementsList n12 = null; ClassOrInterfaceBody n13 = null; // --- user BNFProduction java block --- boolean isInterface = false; class_nesting++; Token t; boolean is_parser_class = false; } { ( ( n2 = "class" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 2); } | n4 = "interface" { n3 = JTBToolkit.makeNodeToken(n4); } { isInterface = true; } { n0 = new NodeChoice(n3, 1, 2); } ) ) n6 = < IDENTIFIER > { n5 = JTBToolkit.makeNodeToken(n6); } { t = n6; } [ n8 = TypeParameters() { n7.addNode(n8); } ] [ n10 = ExtendsList(isInterface) { n9.addNode(n10); } ] [ n12 = ImplementsList(isInterface) { n11.addNode(n12); } ] { if (t.image.equals(parser_class_name) && class_nesting == 1 && processing_cu) { is_parser_class = true; setinsertionpoint(getToken(1), 1); } } n13 = ClassOrInterfaceBody(isInterface, null) { if (is_parser_class) { setinsertionpoint(getToken(0), 2); } class_nesting--; } { return new ClassOrInterfaceDeclaration(n0, n5, n7, n9, n11, n13); } } ExtendsList ExtendsList(boolean isInterface) : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; // --- user BNFProduction java block --- boolean extendsMoreThanOne = false; } { n1 = "extends" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = ClassOrInterfaceType() ( { n4 = new NodeSequence(3); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = ClassOrInterfaceType() { n4.addNode(n7); } { extendsMoreThanOne = true; } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { if (extendsMoreThanOne && !isInterface) throw new ParseException("A class cannot extend more than one other class"); } { return new ExtendsList(n0, n2, n3); } } ImplementsList ImplementsList(boolean isInterface) : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; } { n1 = "implements" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = ClassOrInterfaceType() ( { n4 = new NodeSequence(2); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = ClassOrInterfaceType() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { if (isInterface) throw new ParseException("An interface cannot implement other interfaces"); } { return new ImplementsList(n0, n2, n3); } } EnumDeclaration EnumDeclaration() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeOptional n4 = new NodeOptional(); ImplementsList n5 = null; EnumBody n6 = null; } { n1 = "enum" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = < IDENTIFIER > { n2 = JTBToolkit.makeNodeToken(n3); } [ n5 = ImplementsList(false) { n4.addNode(n5); } ] n6 = EnumBody() { return new EnumDeclaration(n0, n2, n4, n6); } } EnumBody EnumBody() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; EnumConstant n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; EnumConstant n9 = null; NodeOptional n10 = new NodeOptional(); NodeToken n11 = null; Token n12 = null; NodeOptional n13 = new NodeOptional(); NodeSequence n14 = null; NodeToken n15 = null; Token n16 = null; NodeListOptional n17 = null; ClassOrInterfaceBodyDeclaration n18 = null; NodeToken n19 = null; Token n20 = null; } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } [ { n5 = new NodeListOptional(); } { n3 = new NodeSequence(2); } n4 = EnumConstant() { n3.addNode(n4); } ( LOOKAHEAD( 2 ) { n6 = new NodeSequence(2); } n8 = "," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = EnumConstant() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { n3.addNode(n5); } { n2.addNode(n3); } ] [ n12 = "," { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } ] [ { n17 = new NodeListOptional(); } { n14 = new NodeSequence(2); } n16 = ";" { n15 = JTBToolkit.makeNodeToken(n16); } { n14.addNode(n15); } ( n18 = ClassOrInterfaceBodyDeclaration(false) { n17.addNode(n18); } )* { n17.nodes.trimToSize(); } { n14.addNode(n17); } { n13.addNode(n14); } ] n20 = "}" { n19 = JTBToolkit.makeNodeToken(n20); } { return new EnumBody(n0, n2, n10, n13, n19); } } EnumConstant EnumConstant() : { // --- JTB generated node declarations --- Modifiers n0 = null; NodeToken n1 = null; Token n2 = null; NodeOptional n3 = new NodeOptional(); Arguments n4 = null; NodeOptional n5 = new NodeOptional(); ClassOrInterfaceBody n6 = null; } { n0 = Modifiers() n2 = < IDENTIFIER > { n1 = JTBToolkit.makeNodeToken(n2); } [ n4 = Arguments(null) { n3.addNode(n4); } ] [ n6 = ClassOrInterfaceBody(false, null) { n5.addNode(n6); } ] { return new EnumConstant(n0, n1, n3, n5); } } TypeParameters TypeParameters() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeParameter n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; TypeParameter n7 = null; NodeToken n8 = null; Token n9 = null; } { n1 = "<" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = TypeParameter() ( { n4 = new NodeSequence(2); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = TypeParameter() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } n9 = ">" { n8 = JTBToolkit.makeNodeToken(n9); } { return new TypeParameters(n0, n2, n3, n8); } } TypeParameter TypeParameter() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); TypeBound n3 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } [ n3 = TypeBound() { n2.addNode(n3); } ] { return new TypeParameter(n0, n2); } } TypeBound TypeBound() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; } { n1 = "extends" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = ClassOrInterfaceType() ( { n4 = new NodeSequence(2); } n6 = "&" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = ClassOrInterfaceType() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { return new TypeBound(n0, n2, n3); } } ClassOrInterfaceBody ClassOrInterfaceBody(boolean isInterface, List tokens) : /* * Parsing this fills "tokens" with all tokens of the block * excluding the braces at each end. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); ClassOrInterfaceBodyDeclaration n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } { first = getToken(1); } ( n3 = ClassOrInterfaceBodyDeclaration(isInterface) { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } { last = getToken(0); } n5 = "}" { n4 = JTBToolkit.makeNodeToken(n5); } { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } { return new ClassOrInterfaceBody(n0, n2, n4); } } ClassOrInterfaceBodyDeclaration ClassOrInterfaceBodyDeclaration(boolean isInterface) : { // --- JTB generated node declarations --- NodeChoice n0 = null; Initializer n1 = null; NodeSequence n2 = null; Modifiers n3 = null; NodeChoice n4 = null; ClassOrInterfaceDeclaration n5 = null; EnumDeclaration n6 = null; ConstructorDeclaration n7 = null; FieldDeclaration n8 = null; MethodDeclaration n9 = null; NodeToken n10 = null; Token n11 = null; } { ( LOOKAHEAD( 2 ) n1 = Initializer() { if (isInterface) throw new ParseException("An interface cannot have initializers"); } { n0 = new NodeChoice(n1, 0, 3); } | { n2 = new NodeSequence(2); } n3 = Modifiers() { n2.addNode(n3); } // Just get all the modifiers out of the way. If you want to do // more checks, pass the modifiers down to the member ( ( n5 = ClassOrInterfaceDeclaration() { n4 = new NodeChoice(n5, 0, 5); } | n6 = EnumDeclaration() { n4 = new NodeChoice(n6, 1, 5); } | LOOKAHEAD( [ TypeParameters() ] < IDENTIFIER > "(" ) n7 = ConstructorDeclaration() { n4 = new NodeChoice(n7, 2, 5); } | LOOKAHEAD( Type() < IDENTIFIER > ( "[" "]" )* ( "," | "=" | ";" ) ) n8 = FieldDeclaration() { n4 = new NodeChoice(n8, 3, 5); } | n9 = MethodDeclaration() { n4 = new NodeChoice(n9, 4, 5); } ) ) { n2.addNode(n4); } { n0 = new NodeChoice(n2, 1, 3); } | n11 = ";" { n10 = JTBToolkit.makeNodeToken(n11); } { n0 = new NodeChoice(n10, 2, 3); } ) { return new ClassOrInterfaceBodyDeclaration(n0); } } FieldDeclaration FieldDeclaration() : { // --- JTB generated node declarations --- Type n0 = null; VariableDeclarator n1 = null; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; VariableDeclarator n6 = null; NodeToken n7 = null; Token n8 = null; } { n0 = // Modifiers are already matched in the caller Type() n1 = VariableDeclarator() ( { n3 = new NodeSequence(2); } n5 = "," { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n6 = VariableDeclarator() { n3.addNode(n6); } { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } n8 = ";" { n7 = JTBToolkit.makeNodeToken(n8); } { return new FieldDeclaration(n0, n1, n2, n7); } } VariableDeclarator VariableDeclarator() : { // --- JTB generated node declarations --- VariableDeclaratorId n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; VariableInitializer n5 = null; } { n0 = VariableDeclaratorId() [ { n2 = new NodeSequence(2); } n4 = "=" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = VariableInitializer() { n2.addNode(n5); } { n1.addNode(n2); } ] { return new VariableDeclarator(n0, n1); } } VariableDeclaratorId VariableDeclaratorId() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } ( { n3 = new NodeSequence(2); } n5 = "[" { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n7 = "]" { n6 = JTBToolkit.makeNodeToken(n7); } { n3.addNode(n6); } { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } { return new VariableDeclaratorId(n0, n2); } } VariableInitializer VariableInitializer() : { // --- JTB generated node declarations --- NodeChoice n0 = null; ArrayInitializer n1 = null; Expression n2 = null; } { ( n1 = ArrayInitializer() { n0 = new NodeChoice(n1, 0, 2); } | n2 = Expression(null) { n0 = new NodeChoice(n2, 1, 2); } ) { return new VariableInitializer(n0); } } ArrayInitializer ArrayInitializer() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; VariableInitializer n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; VariableInitializer n9 = null; NodeOptional n10 = new NodeOptional(); NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } [ { n5 = new NodeListOptional(); } { n3 = new NodeSequence(2); } n4 = VariableInitializer() { n3.addNode(n4); } ( LOOKAHEAD( 2 ) { n6 = new NodeSequence(2); } n8 = "," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = VariableInitializer() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { n3.addNode(n5); } { n2.addNode(n3); } ] [ n12 = "," { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } ] n14 = "}" { n13 = JTBToolkit.makeNodeToken(n14); } { return new ArrayInitializer(n0, n2, n10, n13); } } MethodDeclaration MethodDeclaration() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); TypeParameters n1 = null; ResultType n2 = null; MethodDeclarator n3 = null; NodeOptional n4 = new NodeOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; NameList n8 = null; NodeChoice n9 = null; Block n10 = null; NodeToken n11 = null; Token n12 = null; } { // Modifiers already matched in the caller! [ n1 = TypeParameters() { n0.addNode(n1); } ] n2 = ResultType(null) n3 = MethodDeclarator() [ { n5 = new NodeSequence(2); } n7 = "throws" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8 = NameList() { n5.addNode(n8); } { n4.addNode(n5); } ] ( ( n10 = Block(null) { n9 = new NodeChoice(n10, 0, 2); } | n12 = ";" { n11 = JTBToolkit.makeNodeToken(n12); } { n9 = new NodeChoice(n11, 1, 2); } ) ) { return new MethodDeclaration(n0, n2, n3, n4, n9); } } MethodDeclarator MethodDeclarator() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; FormalParameters n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } n2 = FormalParameters(null) ( { n4 = new NodeSequence(2); } n6 = "[" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8 = "]" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { return new MethodDeclarator(n0, n2, n3); } } FormalParameters FormalParameters(List tokens) : /* * Parsing this fills "tokens" with all tokens of the formal * parameters excluding the parentheses at each end. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; FormalParameter n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; FormalParameter n9 = null; NodeToken n10 = null; Token n11 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); } { n1 = "(" { n0 = JTBToolkit.makeNodeToken(n1); } { first = getToken(1); } [ { n5 = new NodeListOptional(); } { n3 = new NodeSequence(2); } n4 = FormalParameter() { n3.addNode(n4); } ( { n6 = new NodeSequence(2); } n8 = "," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = FormalParameter() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { n3.addNode(n5); } { n2.addNode(n3); } ] { last = getToken(0); } n11 = ")" { n10 = JTBToolkit.makeNodeToken(n11); } { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } { return new FormalParameters(n0, n2, n10); } } FormalParameter FormalParameter() : { // --- JTB generated node declarations --- Modifiers n0 = null; Type n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; VariableDeclaratorId n5 = null; } { n0 = Modifiers() n1 = Type() [ n4 = "..." { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } ] n5 = VariableDeclaratorId() { return new FormalParameter(n0, n1, n2, n5); } } ConstructorDeclaration ConstructorDeclaration() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); TypeParameters n1 = null; NodeToken n2 = null; Token n3 = null; FormalParameters n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; NameList n9 = null; NodeToken n10 = null; Token n11 = null; NodeOptional n12 = new NodeOptional(); ExplicitConstructorInvocation n13 = null; NodeListOptional n14 = new NodeListOptional(); BlockStatement n15 = null; NodeToken n16 = null; Token n17 = null; } { [ n1 = TypeParameters() { n0.addNode(n1); } ] n3 = // Modifiers matched in the caller < IDENTIFIER > { n2 = JTBToolkit.makeNodeToken(n3); } n4 = FormalParameters(null) [ { n6 = new NodeSequence(2); } n8 = "throws" { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = NameList() { n6.addNode(n9); } { n5.addNode(n6); } ] n11 = "{" { n10 = JTBToolkit.makeNodeToken(n11); } [ LOOKAHEAD( ExplicitConstructorInvocation() ) n13 = ExplicitConstructorInvocation() { n12.addNode(n13); } ] ( n15 = BlockStatement() { n14.addNode(n15); } )* { n14.nodes.trimToSize(); } n17 = "}" { n16 = JTBToolkit.makeNodeToken(n17); } { return new ConstructorDeclaration(n0, n2, n4, n5, n10, n12, n14, n16); } } ExplicitConstructorInvocation ExplicitConstructorInvocation() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Arguments n4 = null; NodeToken n5 = null; Token n6 = null; NodeSequence n7 = null; NodeOptional n8 = new NodeOptional(); NodeSequence n9 = null; PrimaryExpression n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; Arguments n15 = null; NodeToken n16 = null; Token n17 = null; } { ( LOOKAHEAD( "this" Arguments(null) ";" ) { n1 = new NodeSequence(3); } n3 = "this" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = Arguments(null) { n1.addNode(n4); } n6 = ";" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } { n0 = new NodeChoice(n1, 0, 2); } | { n7 = new NodeSequence(4); } [ LOOKAHEAD( 2 ) { n9 = new NodeSequence(2); } n10 = PrimaryExpression() { n9.addNode(n10); } n12 = "." { n11 = JTBToolkit.makeNodeToken(n12); } { n9.addNode(n11); } { n8.addNode(n9); } ] { n7.addNode(n8); } n14 = "super" { n13 = JTBToolkit.makeNodeToken(n14); } { n7.addNode(n13); } n15 = Arguments(null) { n7.addNode(n15); } n17 = ";" { n16 = JTBToolkit.makeNodeToken(n17); } { n7.addNode(n16); } { n0 = new NodeChoice(n7, 1, 2); } ) { return new ExplicitConstructorInvocation(n0); } } Initializer Initializer() : { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeToken n1 = null; Token n2 = null; Block n3 = null; } { [ n2 = "static" { n1 = JTBToolkit.makeNodeToken(n2); } { n0.addNode(n1); } ] n3 = Block(null) { return new Initializer(n0, n3); } } /* * Type, name and expression syntax follows. */ Type Type() : { // --- JTB generated node declarations --- NodeChoice n0 = null; ReferenceType n1 = null; PrimitiveType n2 = null; } { ( LOOKAHEAD( 2 ) n1 = ReferenceType() { n0 = new NodeChoice(n1, 0, 2); } | n2 = PrimitiveType() { n0 = new NodeChoice(n2, 1, 2); } ) { return new Type(n0); } } ReferenceType ReferenceType() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; PrimitiveType n2 = null; NodeList n3 = new NodeList(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeSequence n9 = null; ClassOrInterfaceType n10 = null; NodeListOptional n11 = new NodeListOptional(); NodeSequence n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; } { ( { n1 = new NodeSequence(2); } n2 = PrimitiveType() { n1.addNode(n2); } ( LOOKAHEAD( 2 ) { n4 = new NodeSequence(2); } n6 = "[" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8 = "]" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )+ { n3.nodes.trimToSize(); } { n1.addNode(n3); } { n0 = new NodeChoice(n1, 0, 2); } | { n9 = new NodeSequence(2); } n10 = ClassOrInterfaceType() { n9.addNode(n10); } ( LOOKAHEAD( 2 ) { n12 = new NodeSequence(2); } n14 = "[" { n13 = JTBToolkit.makeNodeToken(n14); } { n12.addNode(n13); } n16 = "]" { n15 = JTBToolkit.makeNodeToken(n16); } { n12.addNode(n15); } { n11.addNode(n12); } )* { n11.nodes.trimToSize(); } { n9.addNode(n11); } { n0 = new NodeChoice(n9, 1, 2); } ) { return new ReferenceType(n0); } } ClassOrInterfaceType ClassOrInterfaceType() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); TypeArguments n3 = null; NodeListOptional n4 = new NodeListOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeOptional n10 = null; TypeArguments n11 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } [ LOOKAHEAD( 2 ) n3 = TypeArguments() { n2.addNode(n3); } ] ( LOOKAHEAD( 2 ) { n10 = new NodeOptional(); } { n5 = new NodeSequence(3); } n7 = "." { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n9 = < IDENTIFIER > { n8 = JTBToolkit.makeNodeToken(n9); } { n5.addNode(n8); } [ LOOKAHEAD( 2 ) n11 = TypeArguments() { n10.addNode(n11); } ] { n5.addNode(n10); } { n4.addNode(n5); } )* { n4.nodes.trimToSize(); } { return new ClassOrInterfaceType(n0, n2, n4); } } TypeArguments TypeArguments() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeArgument n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; TypeArgument n7 = null; NodeToken n8 = null; Token n9 = null; } { n1 = "<" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = TypeArgument() ( { n4 = new NodeSequence(2); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = TypeArgument() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } n9 = ">" { n8 = JTBToolkit.makeNodeToken(n9); } { return new TypeArguments(n0, n2, n3, n8); } } TypeArgument TypeArgument() : { // --- JTB generated node declarations --- NodeChoice n0 = null; ReferenceType n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); WildcardBounds n6 = null; } { ( n1 = ReferenceType() { n0 = new NodeChoice(n1, 0, 2); } | { n2 = new NodeSequence(2); } n4 = "?" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } [ n6 = WildcardBounds() { n5.addNode(n6); } ] { n2.addNode(n5); } { n0 = new NodeChoice(n2, 1, 2); } ) { return new TypeArgument(n0); } } WildcardBounds WildcardBounds() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; ReferenceType n4 = null; NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; ReferenceType n8 = null; } { ( { n1 = new NodeSequence(2); } n3 = "extends" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = ReferenceType() { n1.addNode(n4); } { n0 = new NodeChoice(n1, 0, 2); } | { n5 = new NodeSequence(2); } n7 = "super" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8 = ReferenceType() { n5.addNode(n8); } { n0 = new NodeChoice(n5, 1, 2); } ) { return new WildcardBounds(n0); } } PrimitiveType PrimitiveType() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; } { ( n2 = "boolean" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 8); } | n4 = "char" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1, 8); } | n6 = "byte" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2, 8); } | n8 = "short" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3, 8); } | n10 = "int" { n9 = JTBToolkit.makeNodeToken(n10); } { n0 = new NodeChoice(n9, 4, 8); } | n12 = "long" { n11 = JTBToolkit.makeNodeToken(n12); } { n0 = new NodeChoice(n11, 5, 8); } | n14 = "float" { n13 = JTBToolkit.makeNodeToken(n14); } { n0 = new NodeChoice(n13, 6, 8); } | n16 = "double" { n15 = JTBToolkit.makeNodeToken(n16); } { n0 = new NodeChoice(n15, 7, 8); } ) { return new PrimitiveType(n0); } } ResultType ResultType(List tokens) : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; Type n3 = null; // --- user BNFProduction java block --- Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); } { ( ( n2 = "void" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 2); } | n3 = Type() { n0 = new NodeChoice(n3, 1, 2); } ) ) { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } { return new ResultType(n0); } } Name Name(List tokens) : /* * A lookahead of 2 is required below since "Name" can be followed * by a ".*" when used in the context of an "ImportDeclaration". */ { // --- JTB generated node declarations --- JavaIdentifier n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; JavaIdentifier n5 = null; // --- user BNFProduction java block --- if (tokens == null) tokens = new ArrayList(); Token first = getToken(1); } { n0 = JavaIdentifier() ( LOOKAHEAD( 2 ) { n2 = new NodeSequence(2); } n4 = "." { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = JavaIdentifier() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } { return new Name(n0, n1); } } NameList NameList() : { // --- JTB generated node declarations --- Name n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Name n5 = null; } { n0 = Name(null) ( { n2 = new NodeSequence(2); } n4 = "," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Name(null) { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new NameList(n0, n1); } } /* * Expression syntax follows. */ Expression Expression(List tokens) : /* * This expansion has been written this way instead of: * Assignment() | ConditionalExpression() * for performance reasons. * However, it is a weakening of the grammar for it allows the LHS of * assignments to be any conditional expression whereas it can only be * a primary expression. Consider adding a semantic predicate to work * around this. */ { // --- JTB generated node declarations --- ConditionalExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; AssignmentOperator n3 = null; Expression n4 = null; // --- user BNFProduction java block --- Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); } { n0 = ConditionalExpression() [ LOOKAHEAD( 2 ) { n2 = new NodeSequence(2); } n3 = AssignmentOperator() { n2.addNode(n3); } n4 = Expression(null) { n2.addNode(n4); } { n1.addNode(n2); } ] { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } { return new Expression(n0, n1); } } AssignmentOperator AssignmentOperator() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeToken n23 = null; Token n24 = null; } { ( n2 = "=" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 12); } | n4 = "*=" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1, 12); } | n6 = "/=" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2, 12); } | n8 = "%=" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3, 12); } | n10 = "+=" { n9 = JTBToolkit.makeNodeToken(n10); } { n0 = new NodeChoice(n9, 4, 12); } | n12 = "-=" { n11 = JTBToolkit.makeNodeToken(n12); } { n0 = new NodeChoice(n11, 5, 12); } | n14 = "<<=" { n13 = JTBToolkit.makeNodeToken(n14); } { n0 = new NodeChoice(n13, 6, 12); } | n16 = ">>=" { n15 = JTBToolkit.makeNodeToken(n16); } { n0 = new NodeChoice(n15, 7, 12); } | n18 = ">>>=" { n17 = JTBToolkit.makeNodeToken(n18); } { n0 = new NodeChoice(n17, 8, 12); } | n20 = "&=" { n19 = JTBToolkit.makeNodeToken(n20); } { n0 = new NodeChoice(n19, 9, 12); } | n22 = "^=" { n21 = JTBToolkit.makeNodeToken(n22); } { n0 = new NodeChoice(n21, 10, 12); } | n24 = "|=" { n23 = JTBToolkit.makeNodeToken(n24); } { n0 = new NodeChoice(n23, 11, 12); } ) { return new AssignmentOperator(n0); } } ConditionalExpression ConditionalExpression() : { // --- JTB generated node declarations --- ConditionalOrExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expression n5 = null; NodeToken n6 = null; Token n7 = null; Expression n8 = null; } { n0 = ConditionalOrExpression() [ { n2 = new NodeSequence(4); } n4 = "?" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Expression(null) { n2.addNode(n5); } n7 = ":" { n6 = JTBToolkit.makeNodeToken(n7); } { n2.addNode(n6); } n8 = Expression(null) { n2.addNode(n8); } { n1.addNode(n2); } ] { return new ConditionalExpression(n0, n1); } } ConditionalOrExpression ConditionalOrExpression() : { // --- JTB generated node declarations --- ConditionalAndExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ConditionalAndExpression n5 = null; } { n0 = ConditionalAndExpression() ( { n2 = new NodeSequence(2); } n4 = "||" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = ConditionalAndExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ConditionalOrExpression(n0, n1); } } ConditionalAndExpression ConditionalAndExpression() : { // --- JTB generated node declarations --- InclusiveOrExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; InclusiveOrExpression n5 = null; } { n0 = InclusiveOrExpression() ( { n2 = new NodeSequence(2); } n4 = "&&" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = InclusiveOrExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ConditionalAndExpression(n0, n1); } } InclusiveOrExpression InclusiveOrExpression() : { // --- JTB generated node declarations --- ExclusiveOrExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ExclusiveOrExpression n5 = null; } { n0 = ExclusiveOrExpression() ( { n2 = new NodeSequence(2); } n4 = "|" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = ExclusiveOrExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new InclusiveOrExpression(n0, n1); } } ExclusiveOrExpression ExclusiveOrExpression() : { // --- JTB generated node declarations --- AndExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; AndExpression n5 = null; } { n0 = AndExpression() ( { n2 = new NodeSequence(2); } n4 = "^" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = AndExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ExclusiveOrExpression(n0, n1); } } AndExpression AndExpression() : { // --- JTB generated node declarations --- EqualityExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; EqualityExpression n5 = null; } { n0 = EqualityExpression() ( { n2 = new NodeSequence(2); } n4 = "&" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = EqualityExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new AndExpression(n0, n1); } } EqualityExpression EqualityExpression() : { // --- JTB generated node declarations --- InstanceOfExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; InstanceOfExpression n8 = null; } { n0 = InstanceOfExpression() ( { n2 = new NodeSequence(2); } ( ( n5 = "==" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0, 2); } | n7 = "!=" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1, 2); } ) ) { n2.addNode(n3); } n8 = InstanceOfExpression() { n2.addNode(n8); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new EqualityExpression(n0, n1); } } InstanceOfExpression InstanceOfExpression() : { // --- JTB generated node declarations --- RelationalExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Type n5 = null; } { n0 = RelationalExpression() [ { n2 = new NodeSequence(2); } n4 = "instanceof" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Type() { n2.addNode(n5); } { n1.addNode(n2); } ] { return new InstanceOfExpression(n0, n1); } } RelationalExpression RelationalExpression() : { // --- JTB generated node declarations --- ShiftExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; ShiftExpression n12 = null; } { n0 = ShiftExpression() ( { n2 = new NodeSequence(2); } ( ( n5 = "<" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0, 4); } | n7 = ">" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1, 4); } | n9 = "<=" { n8 = JTBToolkit.makeNodeToken(n9); } { n3 = new NodeChoice(n8, 2, 4); } | n11 = ">=" { n10 = JTBToolkit.makeNodeToken(n11); } { n3 = new NodeChoice(n10, 3, 4); } ) ) { n2.addNode(n3); } n12 = ShiftExpression() { n2.addNode(n12); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new RelationalExpression(n0, n1); } } ShiftExpression ShiftExpression() : { // --- JTB generated node declarations --- AdditiveExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; RSIGNEDSHIFT n6 = null; RUNSIGNEDSHIFT n7 = null; AdditiveExpression n8 = null; } { n0 = AdditiveExpression() ( { n2 = new NodeSequence(2); } ( ( n5 = "<<" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0, 3); } | n6 = RSIGNEDSHIFT() { n3 = new NodeChoice(n6, 1, 3); } | n7 = RUNSIGNEDSHIFT() { n3 = new NodeChoice(n7, 2, 3); } ) ) { n2.addNode(n3); } n8 = AdditiveExpression() { n2.addNode(n8); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ShiftExpression(n0, n1); } } AdditiveExpression AdditiveExpression() : { // --- JTB generated node declarations --- MultiplicativeExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; MultiplicativeExpression n8 = null; } { n0 = MultiplicativeExpression() ( { n2 = new NodeSequence(2); } ( ( n5 = "+" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0, 2); } | n7 = "-" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1, 2); } ) ) { n2.addNode(n3); } n8 = MultiplicativeExpression() { n2.addNode(n8); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new AdditiveExpression(n0, n1); } } MultiplicativeExpression MultiplicativeExpression() : { // --- JTB generated node declarations --- UnaryExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; UnaryExpression n10 = null; } { n0 = UnaryExpression() ( { n2 = new NodeSequence(2); } ( ( n5 = "*" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0, 3); } | n7 = "/" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1, 3); } | n9 = "%" { n8 = JTBToolkit.makeNodeToken(n9); } { n3 = new NodeChoice(n8, 2, 3); } ) ) { n2.addNode(n3); } n10 = UnaryExpression() { n2.addNode(n10); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new MultiplicativeExpression(n0, n1); } } UnaryExpression UnaryExpression() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; PreIncrementExpression n8 = null; PreDecrementExpression n9 = null; UnaryExpressionNotPlusMinus n10 = null; } { ( { n1 = new NodeSequence(2); } ( ( n4 = "+" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0, 2); } | n6 = "-" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1, 2); } ) ) { n1.addNode(n2); } n7 = UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0, 4); } | n8 = PreIncrementExpression() { n0 = new NodeChoice(n8, 1, 4); } | n9 = PreDecrementExpression() { n0 = new NodeChoice(n9, 2, 4); } | n10 = UnaryExpressionNotPlusMinus() { n0 = new NodeChoice(n10, 3, 4); } ) { return new UnaryExpression(n0); } } PreIncrementExpression PreIncrementExpression() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; PrimaryExpression n2 = null; } { n1 = "++" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = PrimaryExpression() { return new PreIncrementExpression(n0, n2); } } PreDecrementExpression PreDecrementExpression() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; PrimaryExpression n2 = null; } { n1 = "--" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = PrimaryExpression() { return new PreDecrementExpression(n0, n2); } } UnaryExpressionNotPlusMinus UnaryExpressionNotPlusMinus() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; CastExpression n8 = null; PostfixExpression n9 = null; } { ( { n1 = new NodeSequence(2); } ( ( n4 = "~" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0, 2); } | n6 = "!" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1, 2); } ) ) { n1.addNode(n2); } n7 = UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0, 3); } | LOOKAHEAD( CastLookahead() ) n8 = CastExpression() { n0 = new NodeChoice(n8, 1, 3); } | n9 = PostfixExpression() { n0 = new NodeChoice(n9, 2, 3); } ) { return new UnaryExpressionNotPlusMinus(n0); } } // This production is to determine lookahead only. The LOOKAHEAD specifications // below are not used, but they are there just to indicate that we know about // this. CastLookahead CastLookahead() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; PrimitiveType n4 = null; NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; Type n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeSequence n13 = null; NodeToken n14 = null; Token n15 = null; Type n16 = null; NodeToken n17 = null; Token n18 = null; NodeChoice n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; NodeToken n24 = null; Token n25 = null; NodeToken n26 = null; Token n27 = null; NodeToken n28 = null; Token n29 = null; NodeToken n30 = null; Token n31 = null; NodeToken n32 = null; Token n33 = null; Literal n34 = null; } { ( LOOKAHEAD( 2 ) { n1 = new NodeSequence(2); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = PrimitiveType() { n1.addNode(n4); } { n0 = new NodeChoice(n1, 0, 3); } | LOOKAHEAD( "(" Type() "[" ) { n5 = new NodeSequence(4); } n7 = "(" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8 = Type() { n5.addNode(n8); } n10 = "[" { n9 = JTBToolkit.makeNodeToken(n10); } { n5.addNode(n9); } n12 = "]" { n11 = JTBToolkit.makeNodeToken(n12); } { n5.addNode(n11); } { n0 = new NodeChoice(n5, 1, 3); } | { n13 = new NodeSequence(4); } n15 = "(" { n14 = JTBToolkit.makeNodeToken(n15); } { n13.addNode(n14); } n16 = Type() { n13.addNode(n16); } n18 = ")" { n17 = JTBToolkit.makeNodeToken(n18); } { n13.addNode(n17); } ( ( n21 = "~" { n20 = JTBToolkit.makeNodeToken(n21); } { n19 = new NodeChoice(n20, 0, 8); } | n23 = "!" { n22 = JTBToolkit.makeNodeToken(n23); } { n19 = new NodeChoice(n22, 1, 8); } | n25 = "(" { n24 = JTBToolkit.makeNodeToken(n25); } { n19 = new NodeChoice(n24, 2, 8); } | n27 = < IDENTIFIER > { n26 = JTBToolkit.makeNodeToken(n27); } { n19 = new NodeChoice(n26, 3, 8); } | n29 = "this" { n28 = JTBToolkit.makeNodeToken(n29); } { n19 = new NodeChoice(n28, 4, 8); } | n31 = "super" { n30 = JTBToolkit.makeNodeToken(n31); } { n19 = new NodeChoice(n30, 5, 8); } | n33 = "new" { n32 = JTBToolkit.makeNodeToken(n33); } { n19 = new NodeChoice(n32, 6, 8); } | n34 = Literal() { n19 = new NodeChoice(n34, 7, 8); } ) ) { n13.addNode(n19); } { n0 = new NodeChoice(n13, 2, 3); } ) { return new CastLookahead(n0); } } PostfixExpression PostfixExpression() : { // --- JTB generated node declarations --- PrimaryExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; } { n0 = PrimaryExpression() [ ( n4 = "++" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0, 2); } | n6 = "--" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1, 2); } ) { n1.addNode(n2); } ] { return new PostfixExpression(n0, n1); } } CastExpression CastExpression() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Type n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; NodeSequence n8 = null; NodeToken n9 = null; Token n10 = null; Type n11 = null; NodeToken n12 = null; Token n13 = null; UnaryExpressionNotPlusMinus n14 = null; } { ( LOOKAHEAD( "(" PrimitiveType() ) { n1 = new NodeSequence(4); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = Type() { n1.addNode(n4); } n6 = ")" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } n7 = UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0, 2); } | { n8 = new NodeSequence(4); } n10 = "(" { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n11 = Type() { n8.addNode(n11); } n13 = ")" { n12 = JTBToolkit.makeNodeToken(n13); } { n8.addNode(n12); } n14 = UnaryExpressionNotPlusMinus() { n8.addNode(n14); } { n0 = new NodeChoice(n8, 1, 2); } ) { return new CastExpression(n0); } } PrimaryExpression PrimaryExpression() : { // --- JTB generated node declarations --- PrimaryPrefix n0 = null; NodeListOptional n1 = new NodeListOptional(); PrimarySuffix n2 = null; } { n0 = PrimaryPrefix() ( LOOKAHEAD( 2 ) n2 = PrimarySuffix() { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new PrimaryExpression(n0, n1); } } MemberSelector MemberSelector() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeArguments n2 = null; NodeToken n3 = null; Token n4 = null; } { n1 = "." { n0 = JTBToolkit.makeNodeToken(n1); } n2 = TypeArguments() n4 = < IDENTIFIER > { n3 = JTBToolkit.makeNodeToken(n4); } { return new MemberSelector(n0, n2, n3); } } PrimaryPrefix PrimaryPrefix() : { // --- JTB generated node declarations --- NodeChoice n0 = null; Literal n1 = null; NodeToken n2 = null; Token n3 = null; NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; AllocationExpression n17 = null; NodeSequence n18 = null; ResultType n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; Name n24 = null; } { ( n1 = Literal() { n0 = new NodeChoice(n1, 0, 7); } | n3 = "this" { n2 = JTBToolkit.makeNodeToken(n3); } { n0 = new NodeChoice(n2, 1, 7); } | { n4 = new NodeSequence(3); } n6 = "super" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8 = "." { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } n10 = < IDENTIFIER > { n9 = JTBToolkit.makeNodeToken(n10); } { n4.addNode(n9); } { n0 = new NodeChoice(n4, 2, 7); } | { n11 = new NodeSequence(3); } n13 = "(" { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } n14 = Expression(null) { n11.addNode(n14); } n16 = ")" { n15 = JTBToolkit.makeNodeToken(n16); } { n11.addNode(n15); } { n0 = new NodeChoice(n11, 3, 7); } | n17 = AllocationExpression() { n0 = new NodeChoice(n17, 4, 7); } | LOOKAHEAD( ResultType(null) "." "class" ) { n18 = new NodeSequence(3); } n19 = ResultType(null) { n18.addNode(n19); } n21 = "." { n20 = JTBToolkit.makeNodeToken(n21); } { n18.addNode(n20); } n23 = "class" { n22 = JTBToolkit.makeNodeToken(n23); } { n18.addNode(n22); } { n0 = new NodeChoice(n18, 5, 7); } | n24 = Name(null) { n0 = new NodeChoice(n24, 6, 7); } ) { return new PrimaryPrefix(n0); } } PrimarySuffix PrimarySuffix() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; AllocationExpression n9 = null; MemberSelector n10 = null; NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; NodeSequence n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; Arguments n22 = null; } { ( LOOKAHEAD( 2 ) { n1 = new NodeSequence(2); } n3 = "." { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n5 = "this" { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } { n0 = new NodeChoice(n1, 0, 6); } | LOOKAHEAD( 2 ) { n6 = new NodeSequence(2); } n8 = "." { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = AllocationExpression() { n6.addNode(n9); } { n0 = new NodeChoice(n6, 1, 6); } | LOOKAHEAD( 3 ) n10 = MemberSelector() { n0 = new NodeChoice(n10, 2, 6); } | { n11 = new NodeSequence(3); } n13 = "[" { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } n14 = Expression(null) { n11.addNode(n14); } n16 = "]" { n15 = JTBToolkit.makeNodeToken(n16); } { n11.addNode(n15); } { n0 = new NodeChoice(n11, 3, 6); } | { n17 = new NodeSequence(2); } n19 = "." { n18 = JTBToolkit.makeNodeToken(n19); } { n17.addNode(n18); } n21 = < IDENTIFIER > { n20 = JTBToolkit.makeNodeToken(n21); } { n17.addNode(n20); } { n0 = new NodeChoice(n17, 4, 6); } | n22 = Arguments(null) { n0 = new NodeChoice(n22, 5, 6); } ) { return new PrimarySuffix(n0); } } Literal Literal() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; BooleanLiteral n9 = null; NullLiteral n10 = null; } { ( n2 = < INTEGER_LITERAL > { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0, 6); } | n4 = < FLOATING_POINT_LITERAL > { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1, 6); } | n6 = < CHARACTER_LITERAL > { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2, 6); } | n8 = < STRING_LITERAL > { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3, 6); } | n9 = BooleanLiteral() { n0 = new NodeChoice(n9, 4, 6); } | n10 = NullLiteral() { n0 = new NodeChoice(n10, 5, 6); } ) { return new Literal(n0); } } IntegerLiteral IntegerLiteral() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; } { n1 = < INTEGER_LITERAL > { n0 = JTBToolkit.makeNodeToken(n1); } { try { jtbrt_IntegerLiteral = Integer.parseInt(token.image); } catch (NumberFormatException e) { throw new Error(); } } { return new IntegerLiteral(n0); } } BooleanLiteral BooleanLiteral() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; } { ( n2 = "true" { n1 = JTBToolkit.makeNodeToken(n2); } { jtbrt_BooleanLiteral = true; } { n0 = new NodeChoice(n1, 0, 2); } | n4 = "false" { n3 = JTBToolkit.makeNodeToken(n4); } { jtbrt_BooleanLiteral = false; } { n0 = new NodeChoice(n3, 1, 2); } ) { return new BooleanLiteral(n0); } } StringLiteral StringLiteral() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; // --- user BNFProduction java block --- Token t; } { n1 = < STRING_LITERAL > { n0 = JTBToolkit.makeNodeToken(n1); } { t = n1; } { jtbrt_StringLiteral = remove_escapes_and_quotes(t, t.image); } { return new StringLiteral(n0); } } NullLiteral NullLiteral() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; } { n1 = "null" { n0 = JTBToolkit.makeNodeToken(n1); } { return new NullLiteral(n0); } } Arguments Arguments(List tokens) : /* * Parsing this fills "tokens" with all tokens of the arguments * excluding the parentheses at each end. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); ArgumentList n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); } { n1 = "(" { n0 = JTBToolkit.makeNodeToken(n1); } { first = getToken(1); } [ n3 = ArgumentList() { n2.addNode(n3); } ] { last = getToken(0); } n5 = ")" { n4 = JTBToolkit.makeNodeToken(n5); } { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } { return new Arguments(n0, n2, n4); } } ArgumentList ArgumentList() : { // --- JTB generated node declarations --- Expression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expression n5 = null; } { n0 = Expression(null) ( { n2 = new NodeSequence(2); } n4 = "," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = Expression(null) { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ArgumentList(n0, n1); } } AllocationExpression AllocationExpression() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; PrimitiveType n4 = null; ArrayDimsAndInits n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; ClassOrInterfaceType n9 = null; NodeOptional n10 = new NodeOptional(); TypeArguments n11 = null; NodeChoice n12 = null; ArrayDimsAndInits n13 = null; NodeSequence n14 = null; Arguments n15 = null; NodeOptional n16 = new NodeOptional(); ClassOrInterfaceBody n17 = null; } { ( LOOKAHEAD( 2 ) { n1 = new NodeSequence(3); } n3 = "new" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = PrimitiveType() { n1.addNode(n4); } n5 = ArrayDimsAndInits() { n1.addNode(n5); } { n0 = new NodeChoice(n1, 0, 2); } | { n6 = new NodeSequence(4); } n8 = "new" { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9 = ClassOrInterfaceType() { n6.addNode(n9); } [ n11 = TypeArguments() { n10.addNode(n11); } ] { n6.addNode(n10); } ( ( n13 = ArrayDimsAndInits() { n12 = new NodeChoice(n13, 0, 2); } | { n14 = new NodeSequence(2); } n15 = Arguments(null) { n14.addNode(n15); } [ n17 = ClassOrInterfaceBody(false, null) { n16.addNode(n17); } ] { n14.addNode(n16); } { n12 = new NodeChoice(n14, 1, 2); } ) ) { n6.addNode(n12); } { n0 = new NodeChoice(n6, 1, 2); } ) { return new AllocationExpression(n0); } } /* * The third LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */ ArrayDimsAndInits ArrayDimsAndInits() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeList n2 = new NodeList(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; Expression n6 = null; NodeToken n7 = null; Token n8 = null; NodeListOptional n9 = new NodeListOptional(); NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeSequence n15 = null; NodeList n16 = new NodeList(); NodeSequence n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; ArrayInitializer n22 = null; } { ( LOOKAHEAD( 2 ) { n1 = new NodeSequence(2); } ( LOOKAHEAD( 2 ) { n3 = new NodeSequence(3); } n5 = "[" { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n6 = Expression(null) { n3.addNode(n6); } n8 = "]" { n7 = JTBToolkit.makeNodeToken(n8); } { n3.addNode(n7); } { n2.addNode(n3); } )+ { n2.nodes.trimToSize(); } { n1.addNode(n2); } ( LOOKAHEAD( 2 ) { n10 = new NodeSequence(2); } n12 = "[" { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } n14 = "]" { n13 = JTBToolkit.makeNodeToken(n14); } { n10.addNode(n13); } { n9.addNode(n10); } )* { n9.nodes.trimToSize(); } { n1.addNode(n9); } { n0 = new NodeChoice(n1, 0, 2); } | { n15 = new NodeSequence(2); } ( { n17 = new NodeSequence(2); } n19 = "[" { n18 = JTBToolkit.makeNodeToken(n19); } { n17.addNode(n18); } n21 = "]" { n20 = JTBToolkit.makeNodeToken(n21); } { n17.addNode(n20); } { n16.addNode(n17); } )+ { n16.nodes.trimToSize(); } { n15.addNode(n16); } n22 = ArrayInitializer() { n15.addNode(n22); } { n0 = new NodeChoice(n15, 1, 2); } ) { return new ArrayDimsAndInits(n0); } } /* * Statement syntax follows. */ Statement Statement() : { // --- JTB generated node declarations --- NodeChoice n0 = null; LabeledStatement n1 = null; AssertStatement n2 = null; Block n3 = null; EmptyStatement n4 = null; NodeSequence n5 = null; StatementExpression n6 = null; NodeToken n7 = null; Token n8 = null; SwitchStatement n9 = null; IfStatement n10 = null; WhileStatement n11 = null; DoStatement n12 = null; ForStatement n13 = null; BreakStatement n14 = null; ContinueStatement n15 = null; ReturnStatement n16 = null; ThrowStatement n17 = null; SynchronizedStatement n18 = null; TryStatement n19 = null; } { ( LOOKAHEAD( 2 ) n1 = LabeledStatement() { n0 = new NodeChoice(n1, 0, 16); } | n2 = AssertStatement() { n0 = new NodeChoice(n2, 1, 16); } | n3 = Block(null) { n0 = new NodeChoice(n3, 2, 16); } | n4 = EmptyStatement() { n0 = new NodeChoice(n4, 3, 16); } | { n5 = new NodeSequence(2); } n6 = StatementExpression() { n5.addNode(n6); } n8 = ";" { n7 = JTBToolkit.makeNodeToken(n8); } { n5.addNode(n7); } { n0 = new NodeChoice(n5, 4, 16); } | n9 = SwitchStatement() { n0 = new NodeChoice(n9, 5, 16); } | n10 = IfStatement() { n0 = new NodeChoice(n10, 6, 16); } | n11 = WhileStatement() { n0 = new NodeChoice(n11, 7, 16); } | n12 = DoStatement() { n0 = new NodeChoice(n12, 8, 16); } | n13 = ForStatement() { n0 = new NodeChoice(n13, 9, 16); } | n14 = BreakStatement() { n0 = new NodeChoice(n14, 10, 16); } | n15 = ContinueStatement() { n0 = new NodeChoice(n15, 11, 16); } | n16 = ReturnStatement() { n0 = new NodeChoice(n16, 12, 16); } | n17 = ThrowStatement() { n0 = new NodeChoice(n17, 13, 16); } | n18 = SynchronizedStatement() { n0 = new NodeChoice(n18, 14, 16); } | n19 = TryStatement() { n0 = new NodeChoice(n19, 15, 16); } ) { return new Statement(n0); } } AssertStatement AssertStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Expression n2 = null; NodeOptional n3 = new NodeOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; Expression n7 = null; NodeToken n8 = null; Token n9 = null; } { n1 = "assert" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Expression(null) [ { n4 = new NodeSequence(2); } n6 = ":" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = Expression(null) { n4.addNode(n7); } { n3.addNode(n4); } ] n9 = ";" { n8 = JTBToolkit.makeNodeToken(n9); } { return new AssertStatement(n0, n2, n3, n8); } } LabeledStatement LabeledStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Statement n4 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } n3 = ":" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Statement() { return new LabeledStatement(n0, n2, n4); } } Block Block(List tokens) : /* * Parsing this fills "tokens" with all tokens of the block * excluding the braces at each end. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); BlockStatement n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } { first = getToken(1); } ( n3 = BlockStatement() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } { last = getToken(0); } n5 = "}" { n4 = JTBToolkit.makeNodeToken(n5); } { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } { return new Block(n0, n2, n4); } } BlockStatement BlockStatement() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; LocalVariableDeclaration n2 = null; NodeToken n3 = null; Token n4 = null; Statement n5 = null; ClassOrInterfaceDeclaration n6 = null; } { ( LOOKAHEAD( Modifiers() Type() < IDENTIFIER > ) { n1 = new NodeSequence(2); } n2 = LocalVariableDeclaration() { n1.addNode(n2); } n4 = ";" { n3 = JTBToolkit.makeNodeToken(n4); } { n1.addNode(n3); } { n0 = new NodeChoice(n1, 0, 3); } | n5 = Statement() { n0 = new NodeChoice(n5, 1, 3); } | n6 = ClassOrInterfaceDeclaration() { n0 = new NodeChoice(n6, 2, 3); } ) { return new BlockStatement(n0); } } LocalVariableDeclaration LocalVariableDeclaration() : { // --- JTB generated node declarations --- Modifiers n0 = null; Type n1 = null; VariableDeclarator n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; VariableDeclarator n7 = null; } { n0 = Modifiers() n1 = Type() n2 = VariableDeclarator() ( { n4 = new NodeSequence(2); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = VariableDeclarator() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { return new LocalVariableDeclaration(n0, n1, n2, n3); } } EmptyStatement EmptyStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; } { n1 = ";" { n0 = JTBToolkit.makeNodeToken(n1); } { return new EmptyStatement(n0); } } StatementExpression StatementExpression() : /* * The last expansion of this production accepts more than the legal * Java expansions for StatementExpression. This expansion does not * use PostfixExpression for performance reasons. */ { // --- JTB generated node declarations --- NodeChoice n0 = null; PreIncrementExpression n1 = null; PreDecrementExpression n2 = null; NodeSequence n3 = null; PrimaryExpression n4 = null; NodeOptional n5 = new NodeOptional(); NodeChoice n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeSequence n11 = null; AssignmentOperator n12 = null; Expression n13 = null; } { ( n1 = PreIncrementExpression() { n0 = new NodeChoice(n1, 0, 3); } | n2 = PreDecrementExpression() { n0 = new NodeChoice(n2, 1, 3); } | { n3 = new NodeSequence(2); } n4 = PrimaryExpression() { n3.addNode(n4); } [ ( n8 = "++" { n7 = JTBToolkit.makeNodeToken(n8); } { n6 = new NodeChoice(n7, 0, 3); } | n10 = "--" { n9 = JTBToolkit.makeNodeToken(n10); } { n6 = new NodeChoice(n9, 1, 3); } | { n11 = new NodeSequence(2); } n12 = AssignmentOperator() { n11.addNode(n12); } n13 = Expression(null) { n11.addNode(n13); } { n6 = new NodeChoice(n11, 2, 3); } ) { n5.addNode(n6); } ] { n3.addNode(n5); } { n0 = new NodeChoice(n3, 2, 3); } ) { return new StatementExpression(n0); } } SwitchStatement SwitchStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeListOptional n9 = new NodeListOptional(); NodeSequence n10 = null; SwitchLabel n11 = null; NodeListOptional n12 = null; BlockStatement n13 = null; NodeToken n14 = null; Token n15 = null; } { n1 = "switch" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Expression(null) n6 = ")" { n5 = JTBToolkit.makeNodeToken(n6); } n8 = "{" { n7 = JTBToolkit.makeNodeToken(n8); } ( { n12 = new NodeListOptional(); } { n10 = new NodeSequence(2); } n11 = SwitchLabel() { n10.addNode(n11); } ( n13 = BlockStatement() { n12.addNode(n13); } )* { n12.nodes.trimToSize(); } { n10.addNode(n12); } { n9.addNode(n10); } )* { n9.nodes.trimToSize(); } n15 = "}" { n14 = JTBToolkit.makeNodeToken(n15); } { return new SwitchStatement(n0, n2, n4, n5, n7, n9, n14); } } SwitchLabel SwitchLabel() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; } { ( { n1 = new NodeSequence(3); } n3 = "case" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4 = Expression(null) { n1.addNode(n4); } n6 = ":" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } { n0 = new NodeChoice(n1, 0, 2); } | { n7 = new NodeSequence(2); } n9 = "default" { n8 = JTBToolkit.makeNodeToken(n9); } { n7.addNode(n8); } n11 = ":" { n10 = JTBToolkit.makeNodeToken(n11); } { n7.addNode(n10); } { n0 = new NodeChoice(n7, 1, 2); } ) { return new SwitchLabel(n0); } } IfStatement IfStatement() : /* * The disambiguating algorithm of JavaCC automatically binds dangling * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Statement n7 = null; NodeOptional n8 = new NodeOptional(); NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; Statement n12 = null; } { n1 = "if" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Expression(null) n6 = ")" { n5 = JTBToolkit.makeNodeToken(n6); } n7 = Statement() [ LOOKAHEAD( 1 ) { n9 = new NodeSequence(2); } n11 = "else" { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } n12 = Statement() { n9.addNode(n12); } { n8.addNode(n9); } ] { return new IfStatement(n0, n2, n4, n5, n7, n8); } } WhileStatement WhileStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Statement n7 = null; } { n1 = "while" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Expression(null) n6 = ")" { n5 = JTBToolkit.makeNodeToken(n6); } n7 = Statement() { return new WhileStatement(n0, n2, n4, n5, n7); } } DoStatement DoStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Statement n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; Expression n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; } { n1 = "do" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Statement() n4 = "while" { n3 = JTBToolkit.makeNodeToken(n4); } n6 = "(" { n5 = JTBToolkit.makeNodeToken(n6); } n7 = Expression(null) n9 = ")" { n8 = JTBToolkit.makeNodeToken(n9); } n11 = ";" { n10 = JTBToolkit.makeNodeToken(n11); } { return new DoStatement(n0, n2, n3, n5, n7, n8, n10); } } ForStatement ForStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeChoice n4 = null; NodeSequence n5 = null; Modifiers n6 = null; Type n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; Expression n12 = null; NodeSequence n13 = null; NodeOptional n14 = new NodeOptional(); ForInit n15 = null; NodeToken n16 = null; Token n17 = null; NodeOptional n18 = new NodeOptional(); Expression n19 = null; NodeToken n20 = null; Token n21 = null; NodeOptional n22 = new NodeOptional(); ForUpdate n23 = null; NodeToken n24 = null; Token n25 = null; Statement n26 = null; } { n1 = "for" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } ( ( LOOKAHEAD( Modifiers() Type() < IDENTIFIER > ":" ) { n5 = new NodeSequence(5); } n6 = Modifiers() { n5.addNode(n6); } n7 = Type() { n5.addNode(n7); } n9 = < IDENTIFIER > { n8 = JTBToolkit.makeNodeToken(n9); } { n5.addNode(n8); } n11 = ":" { n10 = JTBToolkit.makeNodeToken(n11); } { n5.addNode(n10); } n12 = Expression(null) { n5.addNode(n12); } { n4 = new NodeChoice(n5, 0, 2); } | { n13 = new NodeSequence(5); } [ n15 = ForInit() { n14.addNode(n15); } ] { n13.addNode(n14); } n17 = ";" { n16 = JTBToolkit.makeNodeToken(n17); } { n13.addNode(n16); } [ n19 = Expression(null) { n18.addNode(n19); } ] { n13.addNode(n18); } n21 = ";" { n20 = JTBToolkit.makeNodeToken(n21); } { n13.addNode(n20); } [ n23 = ForUpdate() { n22.addNode(n23); } ] { n13.addNode(n22); } { n4 = new NodeChoice(n13, 1, 2); } ) ) n25 = ")" { n24 = JTBToolkit.makeNodeToken(n25); } n26 = Statement() { return new ForStatement(n0, n2, n4, n24, n26); } } ForInit ForInit() : { // --- JTB generated node declarations --- NodeChoice n0 = null; LocalVariableDeclaration n1 = null; StatementExpressionList n2 = null; } { ( LOOKAHEAD( Modifiers() Type() < IDENTIFIER > ) n1 = LocalVariableDeclaration() { n0 = new NodeChoice(n1, 0, 2); } | n2 = StatementExpressionList() { n0 = new NodeChoice(n2, 1, 2); } ) { return new ForInit(n0); } } StatementExpressionList StatementExpressionList() : { // --- JTB generated node declarations --- StatementExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; StatementExpression n5 = null; } { n0 = StatementExpression() ( { n2 = new NodeSequence(2); } n4 = "," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = StatementExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new StatementExpressionList(n0, n1); } } ForUpdate ForUpdate() : { // --- JTB generated node declarations --- StatementExpressionList n0 = null; } { n0 = StatementExpressionList() { return new ForUpdate(n0); } } BreakStatement BreakStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; } { n1 = "break" { n0 = JTBToolkit.makeNodeToken(n1); } [ n4 = < IDENTIFIER > { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } ] n6 = ";" { n5 = JTBToolkit.makeNodeToken(n6); } { return new BreakStatement(n0, n2, n5); } } ContinueStatement ContinueStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; } { n1 = "continue" { n0 = JTBToolkit.makeNodeToken(n1); } [ n4 = < IDENTIFIER > { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } ] n6 = ";" { n5 = JTBToolkit.makeNodeToken(n6); } { return new ContinueStatement(n0, n2, n5); } } ReturnStatement ReturnStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); Expression n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token t; } { n1 = "return" { n0 = JTBToolkit.makeNodeToken(n1); } { t = n1; } { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) return"; jumpPatched = true; } } [ n3 = Expression(null) { n2.addNode(n3); } ] n5 = ";" { n4 = JTBToolkit.makeNodeToken(n5); } { t = n5; } { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } } { return new ReturnStatement(n0, n2, n4); } } ThrowStatement ThrowStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Expression n2 = null; NodeToken n3 = null; Token n4 = null; // --- user BNFProduction java block --- Token t; } { n1 = "throw" { n0 = JTBToolkit.makeNodeToken(n1); } { t = n1; } { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) throw"; jumpPatched = true; } } n2 = Expression(null) n4 = ";" { n3 = JTBToolkit.makeNodeToken(n4); } { t = n4; } { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } } { return new ThrowStatement(n0, n2, n3); } } SynchronizedStatement SynchronizedStatement() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Block n7 = null; } { n1 = "synchronized" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "(" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = Expression(null) n6 = ")" { n5 = JTBToolkit.makeNodeToken(n6); } n7 = Block(null) { return new SynchronizedStatement(n0, n2, n4, n5, n7); } } TryStatement TryStatement() : /* * Semantic check required here to make sure that at least one * finally/catch is present. */ { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Block n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; FormalParameter n9 = null; NodeToken n10 = null; Token n11 = null; Block n12 = null; NodeOptional n13 = new NodeOptional(); NodeSequence n14 = null; NodeToken n15 = null; Token n16 = null; Block n17 = null; } { n1 = "try" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Block(null) ( { n4 = new NodeSequence(5); } n6 = "catch" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8 = "(" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } n9 = FormalParameter() { n4.addNode(n9); } n11 = ")" { n10 = JTBToolkit.makeNodeToken(n11); } { n4.addNode(n10); } n12 = Block(null) { n4.addNode(n12); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } [ { n14 = new NodeSequence(2); } n16 = "finally" { n15 = JTBToolkit.makeNodeToken(n16); } { n14.addNode(n15); } n17 = Block(null) { n14.addNode(n17); } { n13.addNode(n14); } ] { return new TryStatement(n0, n2, n3, n13); } } /* We use productions to match >>>, >> and > so that we can keep the * type declaration syntax with generics clean */ RUNSIGNEDSHIFT RUNSIGNEDSHIFT() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; } { LOOKAHEAD( { getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT } ) n1 = ">" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = ">" { n2 = JTBToolkit.makeNodeToken(n3); } n5 = ">" { n4 = JTBToolkit.makeNodeToken(n5); } { return new RUNSIGNEDSHIFT(n0, n2, n4); } } RSIGNEDSHIFT RSIGNEDSHIFT() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; } { LOOKAHEAD( { getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT } ) n1 = ">" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = ">" { n2 = JTBToolkit.makeNodeToken(n3); } { return new RSIGNEDSHIFT(n0, n2); } } /* Annotation syntax follows. */ Annotation Annotation() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NormalAnnotation n1 = null; SingleMemberAnnotation n2 = null; MarkerAnnotation n3 = null; } { ( LOOKAHEAD( "@" Name(null) "(" < IDENTIFIER > "=" | ")" ) n1 = NormalAnnotation() { n0 = new NodeChoice(n1, 0, 3); } | LOOKAHEAD( "@" Name(null) "(" ) n2 = SingleMemberAnnotation() { n0 = new NodeChoice(n2, 1, 3); } | n3 = MarkerAnnotation() { n0 = new NodeChoice(n3, 2, 3); } ) { return new Annotation(n0); } } NormalAnnotation NormalAnnotation() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); MemberValuePairs n6 = null; NodeToken n7 = null; Token n8 = null; } { n1 = "@" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Name(null) n4 = "(" { n3 = JTBToolkit.makeNodeToken(n4); } [ n6 = MemberValuePairs() { n5.addNode(n6); } ] n8 = ")" { n7 = JTBToolkit.makeNodeToken(n8); } { return new NormalAnnotation(n0, n2, n3, n5, n7); } } MarkerAnnotation MarkerAnnotation() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; } { n1 = "@" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Name(null) { return new MarkerAnnotation(n0, n2); } } SingleMemberAnnotation SingleMemberAnnotation() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; NodeToken n3 = null; Token n4 = null; MemberValue n5 = null; NodeToken n6 = null; Token n7 = null; } { n1 = "@" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = Name(null) n4 = "(" { n3 = JTBToolkit.makeNodeToken(n4); } n5 = MemberValue() n7 = ")" { n6 = JTBToolkit.makeNodeToken(n7); } { return new SingleMemberAnnotation(n0, n2, n3, n5, n6); } } MemberValuePairs MemberValuePairs() : { // --- JTB generated node declarations --- MemberValuePair n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; MemberValuePair n5 = null; } { n0 = MemberValuePair() ( { n2 = new NodeSequence(2); } n4 = "," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5 = MemberValuePair() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new MemberValuePairs(n0, n1); } } MemberValuePair MemberValuePair() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; MemberValue n4 = null; } { n1 = < IDENTIFIER > { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "=" { n2 = JTBToolkit.makeNodeToken(n3); } n4 = MemberValue() { return new MemberValuePair(n0, n2, n4); } } MemberValue MemberValue() : { // --- JTB generated node declarations --- NodeChoice n0 = null; Annotation n1 = null; MemberValueArrayInitializer n2 = null; ConditionalExpression n3 = null; } { ( n1 = Annotation() { n0 = new NodeChoice(n1, 0, 3); } | n2 = MemberValueArrayInitializer() { n0 = new NodeChoice(n2, 1, 3); } | n3 = ConditionalExpression() { n0 = new NodeChoice(n3, 2, 3); } ) { return new MemberValue(n0); } } MemberValueArrayInitializer MemberValueArrayInitializer() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; MemberValue n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; MemberValue n7 = null; NodeOptional n8 = new NodeOptional(); NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = MemberValue() ( LOOKAHEAD( 2 ) { n4 = new NodeSequence(2); } n6 = "," { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n7 = MemberValue() { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } [ n10 = "," { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } ] n12 = "}" { n11 = JTBToolkit.makeNodeToken(n12); } { return new MemberValueArrayInitializer(n0, n2, n3, n8, n11); } } /* Annotation Types. */ AnnotationTypeDeclaration AnnotationTypeDeclaration() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; AnnotationTypeBody n6 = null; } { n1 = "@" { n0 = JTBToolkit.makeNodeToken(n1); } n3 = "interface" { n2 = JTBToolkit.makeNodeToken(n3); } n5 = < IDENTIFIER > { n4 = JTBToolkit.makeNodeToken(n5); } n6 = AnnotationTypeBody() { return new AnnotationTypeDeclaration(n0, n2, n4, n6); } } AnnotationTypeBody AnnotationTypeBody() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); AnnotationTypeMemberDeclaration n3 = null; NodeToken n4 = null; Token n5 = null; } { n1 = "{" { n0 = JTBToolkit.makeNodeToken(n1); } ( n3 = AnnotationTypeMemberDeclaration() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } n5 = "}" { n4 = JTBToolkit.makeNodeToken(n5); } { return new AnnotationTypeBody(n0, n2, n4); } } AnnotationTypeMemberDeclaration AnnotationTypeMemberDeclaration() : { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; Modifiers n2 = null; NodeChoice n3 = null; NodeSequence n4 = null; Type n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeOptional n12 = new NodeOptional(); DefaultValue n13 = null; NodeToken n14 = null; Token n15 = null; ClassOrInterfaceDeclaration n16 = null; EnumDeclaration n17 = null; AnnotationTypeDeclaration n18 = null; FieldDeclaration n19 = null; NodeToken n20 = null; Token n21 = null; } { ( { n1 = new NodeSequence(2); } n2 = Modifiers() { n1.addNode(n2); } ( ( LOOKAHEAD( Type() < IDENTIFIER > "(" ) { n4 = new NodeSequence(6); } n5 = Type() { n4.addNode(n5); } n7 = < IDENTIFIER > { n6 = JTBToolkit.makeNodeToken(n7); } { n4.addNode(n6); } n9 = "(" { n8 = JTBToolkit.makeNodeToken(n9); } { n4.addNode(n8); } n11 = ")" { n10 = JTBToolkit.makeNodeToken(n11); } { n4.addNode(n10); } [ n13 = DefaultValue() { n12.addNode(n13); } ] { n4.addNode(n12); } n15 = ";" { n14 = JTBToolkit.makeNodeToken(n15); } { n4.addNode(n14); } { n3 = new NodeChoice(n4, 0, 5); } | n16 = ClassOrInterfaceDeclaration() { n3 = new NodeChoice(n16, 1, 5); } | n17 = EnumDeclaration() { n3 = new NodeChoice(n17, 2, 5); } | n18 = AnnotationTypeDeclaration() { n3 = new NodeChoice(n18, 3, 5); } | n19 = FieldDeclaration() { n3 = new NodeChoice(n19, 4, 5); } ) ) { n1.addNode(n3); } { n0 = new NodeChoice(n1, 0, 2); } | n21 = ";" { n20 = JTBToolkit.makeNodeToken(n21); } { n0 = new NodeChoice(n20, 1, 2); } ) { return new AnnotationTypeMemberDeclaration(n0); } } DefaultValue DefaultValue() : { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; MemberValue n2 = null; } { n1 = "default" { n0 = JTBToolkit.makeNodeToken(n1); } n2 = MemberValue() { return new DefaultValue(n0, n2); } } /* IDENTIFIERS */ TOKEN : { < IDENTIFIER : ( )* > | < #LETTER : [// all chars for which Character.isIdentifierStart is true "$", "A"-"Z", "_", "a"-"z", "\u00a2"-"\u00a5", "\u00aa", "\u00b5", "\u00ba", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u021f", "\u0222"-"\u0233", "\u0250"-"\u02ad", "\u02b0"-"\u02b8", "\u02bb"-"\u02c1", "\u02d0"-"\u02d1", "\u02e0"-"\u02e4", "\u02ee", "\u037a", "\u0386", "\u0388"-"\u038a", "\u038c", "\u038e"-"\u03a1", "\u03a3"-"\u03ce", "\u03d0"-"\u03d7", "\u03da"-"\u03f3", "\u0400"-"\u0481", "\u048c"-"\u04c4", "\u04c7"-"\u04c8", "\u04cb"-"\u04cc", "\u04d0"-"\u04f5", "\u04f8"-"\u04f9", "\u0531"-"\u0556", "\u0559", "\u0561"-"\u0587", "\u05d0"-"\u05ea", "\u05f0"-"\u05f2", "\u0621"-"\u063a", "\u0640"-"\u064a", "\u0671"-"\u06d3", "\u06d5", "\u06e5"-"\u06e6", "\u06fa"-"\u06fc", "\u0710", "\u0712"-"\u072c", "\u0780"-"\u07a5", "\u0905"-"\u0939", "\u093d", "\u0950", "\u0958"-"\u0961", "\u0985"-"\u098c", "\u098f"-"\u0990", "\u0993"-"\u09a8", "\u09aa"-"\u09b0", "\u09b2", "\u09b6"-"\u09b9", "\u09dc"-"\u09dd", "\u09df"-"\u09e1", "\u09f0"-"\u09f3", "\u0a05"-"\u0a0a", "\u0a0f"-"\u0a10", "\u0a13"-"\u0a28", "\u0a2a"-"\u0a30", "\u0a32"-"\u0a33", "\u0a35"-"\u0a36", "\u0a38"-"\u0a39", "\u0a59"-"\u0a5c", "\u0a5e", "\u0a72"-"\u0a74", "\u0a85"-"\u0a8b", "\u0a8d", "\u0a8f"-"\u0a91", "\u0a93"-"\u0aa8", "\u0aaa"-"\u0ab0", "\u0ab2"-"\u0ab3", "\u0ab5"-"\u0ab9", "\u0abd", "\u0ad0", "\u0ae0", "\u0b05"-"\u0b0c", "\u0b0f"-"\u0b10", "\u0b13"-"\u0b28", "\u0b2a"-"\u0b30", "\u0b32"-"\u0b33", "\u0b36"-"\u0b39", "\u0b3d", "\u0b5c"-"\u0b5d", "\u0b5f"-"\u0b61", "\u0b85"-"\u0b8a", "\u0b8e"-"\u0b90", "\u0b92"-"\u0b95", "\u0b99"-"\u0b9a", "\u0b9c", "\u0b9e"-"\u0b9f", "\u0ba3"-"\u0ba4", "\u0ba8"-"\u0baa", "\u0bae"-"\u0bb5", "\u0bb7"-"\u0bb9", "\u0c05"-"\u0c0c", "\u0c0e"-"\u0c10", "\u0c12"-"\u0c28", "\u0c2a"-"\u0c33", "\u0c35"-"\u0c39", "\u0c60"-"\u0c61", "\u0c85"-"\u0c8c", "\u0c8e"-"\u0c90", "\u0c92"-"\u0ca8", "\u0caa"-"\u0cb3", "\u0cb5"-"\u0cb9", "\u0cde", "\u0ce0"-"\u0ce1", "\u0d05"-"\u0d0c", "\u0d0e"-"\u0d10", "\u0d12"-"\u0d28", "\u0d2a"-"\u0d39", "\u0d60"-"\u0d61", "\u0d85"-"\u0d96", "\u0d9a"-"\u0db1", "\u0db3"-"\u0dbb", "\u0dbd", "\u0dc0"-"\u0dc6", "\u0e01"-"\u0e30", "\u0e32"-"\u0e33", "\u0e3f"-"\u0e46", "\u0e81"-"\u0e82", "\u0e84", "\u0e87"-"\u0e88", "\u0e8a", "\u0e8d", "\u0e94"-"\u0e97", "\u0e99"-"\u0e9f", "\u0ea1"-"\u0ea3", "\u0ea5", "\u0ea7", "\u0eaa"-"\u0eab", "\u0ead"-"\u0eb0", "\u0eb2"-"\u0eb3", "\u0ebd", "\u0ec0"-"\u0ec4", "\u0ec6", "\u0edc"-"\u0edd", "\u0f00", "\u0f40"-"\u0f47", "\u0f49"-"\u0f6a", "\u0f88"-"\u0f8b", "\u1000"-"\u1021", "\u1023"-"\u1027", "\u1029"-"\u102a", "\u1050"-"\u1055", "\u10a0"-"\u10c5", "\u10d0"-"\u10f6", "\u1100"-"\u1159", "\u115f"-"\u11a2", "\u11a8"-"\u11f9", "\u1200"-"\u1206", "\u1208"-"\u1246", "\u1248", "\u124a"-"\u124d", "\u1250"-"\u1256", "\u1258", "\u125a"-"\u125d", "\u1260"-"\u1286", "\u1288", "\u128a"-"\u128d", "\u1290"-"\u12ae", "\u12b0", "\u12b2"-"\u12b5", "\u12b8"-"\u12be", "\u12c0", "\u12c2"-"\u12c5", "\u12c8"-"\u12ce", "\u12d0"-"\u12d6", "\u12d8"-"\u12ee", "\u12f0"-"\u130e", "\u1310", "\u1312"-"\u1315", "\u1318"-"\u131e", "\u1320"-"\u1346", "\u1348"-"\u135a", "\u13a0"-"\u13f4", "\u1401"-"\u166c", "\u166f"-"\u1676", "\u1681"-"\u169a", "\u16a0"-"\u16ea", "\u1780"-"\u17b3", "\u17db", "\u1820"-"\u1877", "\u1880"-"\u18a8", "\u1e00"-"\u1e9b", "\u1ea0"-"\u1ef9", "\u1f00"-"\u1f15", "\u1f18"-"\u1f1d", "\u1f20"-"\u1f45", "\u1f48"-"\u1f4d", "\u1f50"-"\u1f57", "\u1f59", "\u1f5b", "\u1f5d", "\u1f5f"-"\u1f7d", "\u1f80"-"\u1fb4", "\u1fb6"-"\u1fbc", "\u1fbe", "\u1fc2"-"\u1fc4", "\u1fc6"-"\u1fcc", "\u1fd0"-"\u1fd3", "\u1fd6"-"\u1fdb", "\u1fe0"-"\u1fec", "\u1ff2"-"\u1ff4", "\u1ff6"-"\u1ffc", "\u203f"-"\u2040", "\u207f", "\u20a0"-"\u20af", "\u2102", "\u2107", "\u210a"-"\u2113", "\u2115", "\u2119"-"\u211d", "\u2124", "\u2126", "\u2128", "\u212a"-"\u212d", "\u212f"-"\u2131", "\u2133"-"\u2139", "\u2160"-"\u2183", "\u3005"-"\u3007", "\u3021"-"\u3029", "\u3031"-"\u3035", "\u3038"-"\u303a", "\u3041"-"\u3094", "\u309d"-"\u309e", "\u30a1"-"\u30fe", "\u3105"-"\u312c", "\u3131"-"\u318e", "\u31a0"-"\u31b7", "\u3400"-"\u4db5", "\u4e00"-"\u9fa5", "\ua000"-"\ua48c", "\uac00"-"\ud7a3", "\uf900"-"\ufa2d", "\ufb00"-"\ufb06", "\ufb13"-"\ufb17", "\ufb1d", "\ufb1f"-"\ufb28", "\ufb2a"-"\ufb36", "\ufb38"-"\ufb3c", "\ufb3e", "\ufb40"-"\ufb41", "\ufb43"-"\ufb44", "\ufb46"-"\ufbb1", "\ufbd3"-"\ufd3d", "\ufd50"-"\ufd8f", "\ufd92"-"\ufdc7", "\ufdf0"-"\ufdfb", "\ufe33"-"\ufe34", "\ufe4d"-"\ufe4f", "\ufe69", "\ufe70"-"\ufe72", "\ufe74", "\ufe76"-"\ufefc", "\uff04", "\uff21"-"\uff3a", "\uff3f", "\uff41"-"\uff5a", "\uff65"-"\uffbe", "\uffc2"-"\uffc7", "\uffca"-"\uffcf", "\uffd2"-"\uffd7", "\uffda"-"\uffdc", "\uffe0"-"\uffe1", "\uffe5"-"\uffe6"] > | < #PART_LETTER : [// all chars for which Character.isIdentifierPart is true "\u0000"-"\u0008", "\u000e"-"\u001b", "$", "0"-"9", "A"-"Z", "_", "a"-"z", "\u007f"-"\u009f", "\u00a2"-"\u00a5", "\u00aa", "\u00b5", "\u00ba", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u021f", "\u0222"-"\u0233", "\u0250"-"\u02ad", "\u02b0"-"\u02b8", "\u02bb"-"\u02c1", "\u02d0"-"\u02d1", "\u02e0"-"\u02e4", "\u02ee", "\u0300"-"\u034e", "\u0360"-"\u0362", "\u037a", "\u0386", "\u0388"-"\u038a", "\u038c", "\u038e"-"\u03a1", "\u03a3"-"\u03ce", "\u03d0"-"\u03d7", "\u03da"-"\u03f3", "\u0400"-"\u0481", "\u0483"-"\u0486", "\u048c"-"\u04c4", "\u04c7"-"\u04c8", "\u04cb"-"\u04cc", "\u04d0"-"\u04f5", "\u04f8"-"\u04f9", "\u0531"-"\u0556", "\u0559", "\u0561"-"\u0587", "\u0591"-"\u05a1", "\u05a3"-"\u05b9", "\u05bb"-"\u05bd", "\u05bf", "\u05c1"-"\u05c2", "\u05c4", "\u05d0"-"\u05ea", "\u05f0"-"\u05f2", "\u0621"-"\u063a", "\u0640"-"\u0655", "\u0660"-"\u0669", "\u0670"-"\u06d3", "\u06d5"-"\u06dc", "\u06df"-"\u06e8", "\u06ea"-"\u06ed", "\u06f0"-"\u06fc", "\u070f"-"\u072c", "\u0730"-"\u074a", "\u0780"-"\u07b0", "\u0901"-"\u0903", "\u0905"-"\u0939", "\u093c"-"\u094d", "\u0950"-"\u0954", "\u0958"-"\u0963", "\u0966"-"\u096f", "\u0981"-"\u0983", "\u0985"-"\u098c", "\u098f"-"\u0990", "\u0993"-"\u09a8", "\u09aa"-"\u09b0", "\u09b2", "\u09b6"-"\u09b9", "\u09bc", "\u09be"-"\u09c4", "\u09c7"-"\u09c8", "\u09cb"-"\u09cd", "\u09d7", "\u09dc"-"\u09dd", "\u09df"-"\u09e3", "\u09e6"-"\u09f3", "\u0a02", "\u0a05"-"\u0a0a", "\u0a0f"-"\u0a10", "\u0a13"-"\u0a28", "\u0a2a"-"\u0a30", "\u0a32"-"\u0a33", "\u0a35"-"\u0a36", "\u0a38"-"\u0a39", "\u0a3c", "\u0a3e"-"\u0a42", "\u0a47"-"\u0a48", "\u0a4b"-"\u0a4d", "\u0a59"-"\u0a5c", "\u0a5e", "\u0a66"-"\u0a74", "\u0a81"-"\u0a83", "\u0a85"-"\u0a8b", "\u0a8d", "\u0a8f"-"\u0a91", "\u0a93"-"\u0aa8", "\u0aaa"-"\u0ab0", "\u0ab2"-"\u0ab3", "\u0ab5"-"\u0ab9", "\u0abc"-"\u0ac5", "\u0ac7"-"\u0ac9", "\u0acb"-"\u0acd", "\u0ad0", "\u0ae0", "\u0ae6"-"\u0aef", "\u0b01"-"\u0b03", "\u0b05"-"\u0b0c", "\u0b0f"-"\u0b10", "\u0b13"-"\u0b28", "\u0b2a"-"\u0b30", "\u0b32"-"\u0b33", "\u0b36"-"\u0b39", "\u0b3c"-"\u0b43", "\u0b47"-"\u0b48", "\u0b4b"-"\u0b4d", "\u0b56"-"\u0b57", "\u0b5c"-"\u0b5d", "\u0b5f"-"\u0b61", "\u0b66"-"\u0b6f", "\u0b82"-"\u0b83", "\u0b85"-"\u0b8a", "\u0b8e"-"\u0b90", "\u0b92"-"\u0b95", "\u0b99"-"\u0b9a", "\u0b9c", "\u0b9e"-"\u0b9f", "\u0ba3"-"\u0ba4", "\u0ba8"-"\u0baa", "\u0bae"-"\u0bb5", "\u0bb7"-"\u0bb9", "\u0bbe"-"\u0bc2", "\u0bc6"-"\u0bc8", "\u0bca"-"\u0bcd", "\u0bd7", "\u0be7"-"\u0bef", "\u0c01"-"\u0c03", "\u0c05"-"\u0c0c", "\u0c0e"-"\u0c10", "\u0c12"-"\u0c28", "\u0c2a"-"\u0c33", "\u0c35"-"\u0c39", "\u0c3e"-"\u0c44", "\u0c46"-"\u0c48", "\u0c4a"-"\u0c4d", "\u0c55"-"\u0c56", "\u0c60"-"\u0c61", "\u0c66"-"\u0c6f", "\u0c82"-"\u0c83", "\u0c85"-"\u0c8c", "\u0c8e"-"\u0c90", "\u0c92"-"\u0ca8", "\u0caa"-"\u0cb3", "\u0cb5"-"\u0cb9", "\u0cbe"-"\u0cc4", "\u0cc6"-"\u0cc8", "\u0cca"-"\u0ccd", "\u0cd5"-"\u0cd6", "\u0cde", "\u0ce0"-"\u0ce1", "\u0ce6"-"\u0cef", "\u0d02"-"\u0d03", "\u0d05"-"\u0d0c", "\u0d0e"-"\u0d10", "\u0d12"-"\u0d28", "\u0d2a"-"\u0d39", "\u0d3e"-"\u0d43", "\u0d46"-"\u0d48", "\u0d4a"-"\u0d4d", "\u0d57", "\u0d60"-"\u0d61", "\u0d66"-"\u0d6f", "\u0d82"-"\u0d83", "\u0d85"-"\u0d96", "\u0d9a"-"\u0db1", "\u0db3"-"\u0dbb", "\u0dbd", "\u0dc0"-"\u0dc6", "\u0dca", "\u0dcf"-"\u0dd4", "\u0dd6", "\u0dd8"-"\u0ddf", "\u0df2"-"\u0df3", "\u0e01"-"\u0e3a", "\u0e3f"-"\u0e4e", "\u0e50"-"\u0e59", "\u0e81"-"\u0e82", "\u0e84", "\u0e87"-"\u0e88", "\u0e8a", "\u0e8d", "\u0e94"-"\u0e97", "\u0e99"-"\u0e9f", "\u0ea1"-"\u0ea3", "\u0ea5", "\u0ea7", "\u0eaa"-"\u0eab", "\u0ead"-"\u0eb9", "\u0ebb"-"\u0ebd", "\u0ec0"-"\u0ec4", "\u0ec6", "\u0ec8"-"\u0ecd", "\u0ed0"-"\u0ed9", "\u0edc"-"\u0edd", "\u0f00", "\u0f18"-"\u0f19", "\u0f20"-"\u0f29", "\u0f35", "\u0f37", "\u0f39", "\u0f3e"-"\u0f47", "\u0f49"-"\u0f6a", "\u0f71"-"\u0f84", "\u0f86"-"\u0f8b", "\u0f90"-"\u0f97", "\u0f99"-"\u0fbc", "\u0fc6", "\u1000"-"\u1021", "\u1023"-"\u1027", "\u1029"-"\u102a", "\u102c"-"\u1032", "\u1036"-"\u1039", "\u1040"-"\u1049", "\u1050"-"\u1059", "\u10a0"-"\u10c5", "\u10d0"-"\u10f6", "\u1100"-"\u1159", "\u115f"-"\u11a2", "\u11a8"-"\u11f9", "\u1200"-"\u1206", "\u1208"-"\u1246", "\u1248", "\u124a"-"\u124d", "\u1250"-"\u1256", "\u1258", "\u125a"-"\u125d", "\u1260"-"\u1286", "\u1288", "\u128a"-"\u128d", "\u1290"-"\u12ae", "\u12b0", "\u12b2"-"\u12b5", "\u12b8"-"\u12be", "\u12c0", "\u12c2"-"\u12c5", "\u12c8"-"\u12ce", "\u12d0"-"\u12d6", "\u12d8"-"\u12ee", "\u12f0"-"\u130e", "\u1310", "\u1312"-"\u1315", "\u1318"-"\u131e", "\u1320"-"\u1346", "\u1348"-"\u135a", "\u1369"-"\u1371", "\u13a0"-"\u13f4", "\u1401"-"\u166c", "\u166f"-"\u1676", "\u1681"-"\u169a", "\u16a0"-"\u16ea", "\u1780"-"\u17d3", "\u17db", "\u17e0"-"\u17e9", "\u180b"-"\u180e", "\u1810"-"\u1819", "\u1820"-"\u1877", "\u1880"-"\u18a9", "\u1e00"-"\u1e9b", "\u1ea0"-"\u1ef9", "\u1f00"-"\u1f15", "\u1f18"-"\u1f1d", "\u1f20"-"\u1f45", "\u1f48"-"\u1f4d", "\u1f50"-"\u1f57", "\u1f59", "\u1f5b", "\u1f5d", "\u1f5f"-"\u1f7d", "\u1f80"-"\u1fb4", "\u1fb6"-"\u1fbc", "\u1fbe", "\u1fc2"-"\u1fc4", "\u1fc6"-"\u1fcc", "\u1fd0"-"\u1fd3", "\u1fd6"-"\u1fdb", "\u1fe0"-"\u1fec", "\u1ff2"-"\u1ff4", "\u1ff6"-"\u1ffc", "\u200c"-"\u200f", "\u202a"-"\u202e", "\u203f"-"\u2040", "\u206a"-"\u206f", "\u207f", "\u20a0"-"\u20af", "\u20d0"-"\u20dc", "\u20e1", "\u2102", "\u2107", "\u210a"-"\u2113", "\u2115", "\u2119"-"\u211d", "\u2124", "\u2126", "\u2128", "\u212a"-"\u212d", "\u212f"-"\u2131", "\u2133"-"\u2139", "\u2160"-"\u2183", "\u3005"-"\u3007", "\u3021"-"\u302f", "\u3031"-"\u3035", "\u3038"-"\u303a", "\u3041"-"\u3094", "\u3099"-"\u309a", "\u309d"-"\u309e", "\u30a1"-"\u30fe", "\u3105"-"\u312c", "\u3131"-"\u318e", "\u31a0"-"\u31b7", "\u3400"-"\u4db5", "\u4e00"-"\u9fa5", "\ua000"-"\ua48c", "\uac00"-"\ud7a3", "\uf900"-"\ufa2d", "\ufb00"-"\ufb06", "\ufb13"-"\ufb17", "\ufb1d"-"\ufb28", "\ufb2a"-"\ufb36", "\ufb38"-"\ufb3c", "\ufb3e", "\ufb40"-"\ufb41", "\ufb43"-"\ufb44", "\ufb46"-"\ufbb1", "\ufbd3"-"\ufd3d", "\ufd50"-"\ufd8f", "\ufd92"-"\ufdc7", "\ufdf0"-"\ufdfb", "\ufe20"-"\ufe23", "\ufe33"-"\ufe34", "\ufe4d"-"\ufe4f", "\ufe69", "\ufe70"-"\ufe72", "\ufe74", "\ufe76"-"\ufefc", "\ufeff", "\uff04", "\uff10"-"\uff19", "\uff21"-"\uff3a", "\uff3f", "\uff41"-"\uff5a", "\uff65"-"\uffbe", "\uffc2"-"\uffc7", "\uffca"-"\uffcf", "\uffd2"-"\uffd7", "\uffda"-"\uffdc", "\uffe0"-"\uffe1", "\uffe5"-"\uffe6", "\ufff9"-"\ufffb"] > } jtb-1.4.4/EDU/purdue/jtb/utils/0000755000175000017500000000000011420623644015761 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/utils/Token.java.save0000644000175000017500000001104411360636742020647 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.2.s.m */ /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package EDU.purdue.jtb.parser; /** * Describes the input token stream. * ModMMa : updated for GTToken */ public class Token implements java.io.Serializable { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** The line number of the first character of this Token. */ public int beginLine; /** The column number of the first character of this Token. */ public int beginColumn; /** The line number of the last character of this Token. */ public int endLine; /** The column number of the last character of this Token. */ public int endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * An optional attribute value of the Token. * Tokens which are not used as syntactic sugar will often contain * meaningful values that will be used later on by the compiler or * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. */ public Object getValue() { return null; } /** * No-argument constructor */ public Token() { /* empty */ } /** * Constructs a new token for the specified Image. */ public Token(int ki) { this(ki, null); } /** * Constructs a new token for the specified Image and Kind. */ public Token(int ki, String im) { kind = ki; image = im; } /** * Returns the image. */ @Override public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simply add something like : * * case MyParserConstants.ID : return new IDToken(ofKind, image); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind, String image) { switch(ofKind) { default : return new Token(ofKind, image); case JTBParserConstants.RUNSIGNEDSHIFT: case JTBParserConstants.RSIGNEDSHIFT: case JTBParserConstants.GT: return new GTToken(ofKind, image); } } public static final Token newToken(int ofKind) { return newToken(ofKind, null); } /** * Greater than Token. */ public static class GTToken extends Token { public GTToken(int ki, String im) { super(ki, im); } int realKind = JTBParserConstants.GT; } } /* JavaCC - OriginalChecksum=6121002dddb7374c22bf7aa2e798f51a (do not edit this line) */ jtb-1.4.4/EDU/purdue/jtb/utils/JavaFileGenerator.java0000644000175000017500000002453411360636742022172 0ustar cavedoncavedon/* Copyright (c) 2008, Paul Cager. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.utils; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; /** * Generates boiler-plate files from templates.
* Only very basic template processing is supplied - if we need something more sophisticated I * suggest we use a third-party library. * * @author paulcager * @since 4.2 * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class JavaFileGenerator { /** * @param tn the name of the template. E.g. "/templates/Token.template". * @param opt the processing options in force, such as "STATIC=yes" */ public JavaFileGenerator(final String tn, final Map opt) { templateName = tn; options = opt; } /** The template file name */ private final String templateName; /** The options map */ private final Map options; /** The current line */ private String currentLine; /** * Generate the output file. * * @param out the PrintWriter to output into * @throws IOException if the template file name is invalid */ public void generate(final PrintWriter out) throws IOException { final InputStream is = getClass().getResourceAsStream(templateName); if (is == null) throw new IOException("Invalid template name: " + templateName); final BufferedReader in = new BufferedReader(new InputStreamReader(is)); process(in, out, false); } /** * Returns the internal current line if not null, otherwise reads a new line, assigns it to the * internal current line, and returns it. * * @param in the BufferedReader to read from * @return the current line * @throws IOException if any IO exception occurs */ private String peekLine(final BufferedReader in) throws IOException { if (currentLine == null) currentLine = in.readLine(); return currentLine; } /** * Reads a new line if the internal current line is not null, sets the internal current line to * null, and returns the internal current line if not null or the new line read if null. * * @param in the BufferedReader to read from * @return the current line * @throws IOException if any IO exception occurs */ private String getLine(final BufferedReader in) throws IOException { final String line = currentLine; currentLine = null; if (line == null) in.readLine(); return line; } /** * Evaluates whether a given condition maps to true or false. * * @param condition the condition (as a String) * @return true or false */ private boolean evaluate(final String condition) { final String cond = condition.trim(); final Object obj = options.get(cond); if (obj == null) { return cond.equalsIgnoreCase("true") || cond.equalsIgnoreCase("yes"); } if (obj instanceof Boolean) { return ((Boolean) obj).booleanValue(); } else if (obj instanceof String) { final String string = ((String) obj).trim(); return string.length() > 0 && !string.equalsIgnoreCase("false") && !string.equalsIgnoreCase("no"); } return false; } /** * Substitutes a template string with the corresponding text. * * @param text the template string * @return the substituted text * @throws IOException if any exception occurs */ private String substitute(final String text) throws IOException { int startPos; // find the start of template string if ((startPos = text.indexOf("${")) == -1) { return text; } // find the matching "}" int braceDepth = 1; int endPos = startPos + 2; while (endPos < text.length() && braceDepth > 0) { if (text.charAt(endPos) == '{') braceDepth++; else if (text.charAt(endPos) == '}') braceDepth--; endPos++; } if (braceDepth != 0) throw new IOException("Mismatched \"{}\" in template string: " + text); final String variableExpression = text.substring(startPos + 2, endPos - 1); // Find the end of the variable name String value = null; for (int i = 0; i < variableExpression.length(); i++) { final char ch = variableExpression.charAt(i); if (ch == ':' && i < variableExpression.length() - 1 && variableExpression.charAt(i + 1) == '-') { value = substituteWithDefault(variableExpression.substring(0, i), variableExpression.substring(i + 2)); break; } else if (ch == '?') { value = substituteWithConditional(variableExpression.substring(0, i), variableExpression.substring(i + 1)); break; } else if (ch != '_' && !Character.isJavaIdentifierPart(ch)) { throw new IOException("Invalid variable in " + text); } } if (value == null) { value = substituteWithDefault(variableExpression, ""); } return text.substring(0, startPos) + value + text.substring(endPos); } /** * Substitutes a template string with the corresponding conditional text :
* if the template evaluates to true, it will substituted with the values substring up to the ':',
* if the template evaluates to false, it will substituted with the values substring after the * ':'.
* * @param variableName the text to be substituted * @param values a pair of substituting strings separated by a ':' * @return the substituted text * @throws IOException if any exception occurs */ private String substituteWithConditional(final String variableName, final String values) throws IOException { // Split values into true and false values. final int pos = values.indexOf(':'); if (pos == -1) throw new IOException("No ':' separator in " + values); if (evaluate(variableName)) return substitute(values.substring(0, pos)); else return substitute(values.substring(pos + 1)); } /** * Substitutes a given text with the corresponding option, or with a given default value if the * option is not present or empty. * * @param variableName the text to be substituted * @param defaultValue the default value * @return the substituted text * @throws IOException if any exception occurs */ private String substituteWithDefault(final String variableName, final String defaultValue) throws IOException { final Object obj = options.get(variableName.trim()); if (obj == null || obj.toString().length() == 0) return substitute(defaultValue); return obj.toString(); } /** * Writes a text, substituting templates parts if necessary. * * @param out the PrintWriter to write to * @param text the text to write * @throws IOException if any exception occurs */ private void write(final PrintWriter out, final String text) throws IOException { String txt = text; while (txt.indexOf("${") != -1) { txt = substitute(txt); } out.println(txt); } /** * @param in the BufferedReader to read from * @param out the PrintWriter to write to * @param ignoring true if line must not be outputted, false otherwise * @throws IOException if any exception occurs */ private void process(final BufferedReader in, final PrintWriter out, final boolean ignoring) throws IOException { // out.println("*** process ignore=" + ignoring + " : " + peekLine(in)); while (peekLine(in) != null) { if (peekLine(in).trim().startsWith("#if")) { String line = getLine(in).trim(); final boolean condition = evaluate(line.substring(3).trim()); process(in, out, ignoring || !condition); if (peekLine(in) != null && peekLine(in).trim().startsWith("#else")) { getLine(in); // Discard the #else line process(in, out, ignoring || condition); } line = getLine(in); if (line == null) throw new IOException("Missing \"#fi\""); if (!line.trim().startsWith("#fi")) throw new IOException("Expected \"#fi\", got: " + line); } else if (peekLine(in).trim().startsWith("#")) { break; } else { final String line = getLine(in); if (!ignoring) write(out, line); } } out.flush(); } /** * Test main method. * * @param args command line arguments * @throws Exception if any exception occur */ public static void main(final String[] args) throws Exception { final Map map = new HashMap(); map.put("falseArg", Boolean.FALSE); map.put("trueArg", Boolean.TRUE); map.put("stringValue", "someString"); new JavaFileGenerator(args[0], map).generate(new PrintWriter(args[1])); } } jtb-1.4.4/EDU/purdue/jtb/jtbgram.jj-1.3.20000644000175000017500000005744111360636752017255 0ustar cavedoncavedon /** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /** * JTB 1.3.x is a derivation of JTB 1.2.1 which has the following * license: **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ // // Java Tree Builder (JTB) Grammar // // Converted from the JavaCC 0.6 grammar in the documentation. // Appended to the Java1.1.jj grammar provided in JavaCC. // // AUTHOR: Kevin Tao, taokr@cs.purdue.edu // // This grammar is basically the JavaCC grammar, adapted from the // documentation. A few changes have been made to fix possible bugs in the // grammar. // /***************************************************************************/ /** * * Copyright (C) 1996, 1997 Sun Microsystems Inc. * * Use of this file and the system it is part of is constrained by the * file COPYRIGHT in the root directory of this system. You may, however, * make any modifications you wish to this file. * * Java files generated by running JavaCC on this file (or modified versions * of this file) may be used in exactly the same manner as Java files * generated from any grammar developed by you. * * Author: Sriram Sankar * Date: 3/5/97 * * This file contains a Java grammar and actions that implement a front-end. * */ options { JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(JTBParser) package EDU.purdue.jtb.parser; import EDU.purdue.jtb.misc.UnicodeConverter; public class JTBParser { } PARSER_END(JTBParser) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } SPECIAL_TOKEN : /* COMMENTS */ { | | } TOKEN : /* RESERVED WORDS AND LITERALS */ { < ABSTRACT: "abstract" > | < BOOLEAN: "boolean" > | < BREAK: "break" > | < BYTE: "byte" > | < CASE: "case" > | < CATCH: "catch" > | < CHAR: "char" > | < CLASS: "class" > | < CONST: "const" > | < CONTINUE: "continue" > | < _DEFAULT: "default" > | < DO: "do" > | < DOUBLE: "double" > | < ELSE: "else" > | < EXTENDS: "extends" > | < FALSE: "false" > | < FINAL: "final" > | < FINALLY: "finally" > | < FLOAT: "float" > | < FOR: "for" > | < GOTO: "goto" > | < IF: "if" > | < IMPLEMENTS: "implements" > | < IMPORT: "import" > | < INSTANCEOF: "instanceof" > | < INT: "int" > | < INTERFACE: "interface" > | < LONG: "long" > | < NATIVE: "native" > | < NEW: "new" > | < NULL: "null" > | < PACKAGE: "package"> | < PRIVATE: "private" > | < PROTECTED: "protected" > | < PUBLIC: "public" > | < RETURN: "return" > | < SHORT: "short" > | < STATIC: "static" > | < SUPER: "super" > | < SWITCH: "switch" > | < SYNCHRONIZED: "synchronized" > | < THIS: "this" > | < THROW: "throw" > | < THROWS: "throws" > | < TRANSIENT: "transient" > | < TRUE: "true" > | < TRY: "try" > | < VOID: "void" > | < VOLATILE: "volatile" > | < WHILE: "while" > } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > | < FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])? | "." (["0"-"9"])+ ()? (["f","F","d","D"])? | (["0"-"9"])+ (["f","F","d","D"])? | (["0"-"9"])+ ()? ["f","F","d","D"] > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < CHARACTER_LITERAL: "'" ( (~["'","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) ) "'" > { // Code to convert a unicode character back into escape sequence matchedToken.image = UnicodeConverter.convertString(image.toString()); } | < STRING_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > { // Code to convert a unicode character back into escape sequence matchedToken.image = UnicodeConverter.convertString(image.toString()); } } TOKEN : /* IDENTIFIERS */ { //**DEFFERED until after JAVACC keywords // < IDENTIFIER: (|)* > //| < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } TOKEN : /* SEPARATORS */ { < LPAREN: "(" > | < RPAREN: ")" > | < LBRACE: "{" > | < RBRACE: "}" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < SEMICOLON: ";" > | < COMMA: "," > | < DOT: "." > } TOKEN : /* OPERATORS */ { < ASSIGN: "=" > | < GT: ">" > | < LT: "<" > | < BANG: "!" > | < TILDE: "~" > | < HOOK: "?" > | < COLON: ":" > | < EQ: "==" > | < LE: "<=" > | < GE: ">=" > | < NE: "!=" > | < SC_OR: "||" > | < SC_AND: "&&" > | < INCR: "++" > | < DECR: "--" > | < PLUS: "+" > | < MINUS: "-" > | < STAR: "*" > | < SLASH: "/" > | < BIT_AND: "&" > | < BIT_OR: "|" > | < XOR: "^" > | < REM: "%" > | < LSHIFT: "<<" > | < RSIGNEDSHIFT: ">>" > | < RUNSIGNEDSHIFT: ">>>" > | < PLUSASSIGN: "+=" > | < MINUSASSIGN: "-=" > | < STARASSIGN: "*=" > | < SLASHASSIGN: "/=" > | < ANDASSIGN: "&=" > | < ORASSIGN: "|=" > | < XORASSIGN: "^=" > | < REMASSIGN: "%=" > | < LSHIFTASSIGN: "<<=" > | < RSIGNEDSHIFTASSIGN: ">>=" > | < RUNSIGNEDSHIFTASSIGN: ">>>=" > } /***************************************** * THE JAVA LANGUAGE GRAMMAR STARTS HERE * *****************************************/ /* * Program structuring syntax follows. */ void CompilationUnit() : {} { [ PackageDeclaration() ] ( ImportDeclaration() )* ( TypeDeclaration() )* // /******removed for javacc } void PackageDeclaration() : {} { "package" Name() ";" } void ImportDeclaration() : {} { "import" Name() [ "." "*" ] ";" } void TypeDeclaration() : {} { LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" ) ClassDeclaration() | InterfaceDeclaration() | ";" } /* * Declaration syntax follows. */ void ClassDeclaration() : {} { ( "abstract" | "final" | "public" )* UnmodifiedClassDeclaration() } void UnmodifiedClassDeclaration() : {} { "class" [ "extends" Name() ] [ "implements" NameList() ] ClassBody() } void ClassBody() : {} { "{" ( ClassBodyDeclaration() )* "}" } void NestedClassDeclaration() : {} { ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* UnmodifiedClassDeclaration() } void ClassBodyDeclaration() : {} { LOOKAHEAD(2) Initializer() | LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class" ) NestedClassDeclaration() | LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface" ) NestedInterfaceDeclaration() | LOOKAHEAD( [ "public" | "protected" | "private" ] Name() "(" ) ConstructorDeclaration() | LOOKAHEAD( MethodDeclarationLookahead() ) MethodDeclaration() | FieldDeclaration() } // This production is to determine lookahead only. void MethodDeclarationLookahead() : {} { ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )* ResultType() "(" } void InterfaceDeclaration() : {} { ( "abstract" | "public" )* UnmodifiedInterfaceDeclaration() } void NestedInterfaceDeclaration() : {} { ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* UnmodifiedInterfaceDeclaration() } void UnmodifiedInterfaceDeclaration() : {} { "interface" [ "extends" NameList() ] "{" ( InterfaceMemberDeclaration() )* "}" } void InterfaceMemberDeclaration() : {} { LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class" ) NestedClassDeclaration() | LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface" ) NestedInterfaceDeclaration() | LOOKAHEAD( MethodDeclarationLookahead() ) MethodDeclaration() | FieldDeclaration() } void FieldDeclaration() : {} { ( "public" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )* Type() VariableDeclarator() ( "," VariableDeclarator() )* ";" } void VariableDeclarator() : {} { VariableDeclaratorId() [ "=" VariableInitializer() ] } void VariableDeclaratorId() : {} { ( "[" "]" )* } void VariableInitializer() : {} { ArrayInitializer() | Expression() } void ArrayInitializer() : {} { "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}" } void MethodDeclaration() : {} { ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )* ResultType() MethodDeclarator() [ "throws" NameList() ] ( Block() | ";" ) } void MethodDeclarator() : {} { FormalParameters() ( "[" "]" )* } void FormalParameters() : {} { "(" [ FormalParameter() ( "," FormalParameter() )* ] ")" } void FormalParameter() : {} { [ "final" ] Type() VariableDeclaratorId() } void ConstructorDeclaration() : {} { [ "public" | "protected" | "private" ] FormalParameters() [ "throws" NameList() ] "{" [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}" } void ExplicitConstructorInvocation() : {} { LOOKAHEAD("this" Arguments() ";") "this" Arguments() ";" | [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";" } void Initializer() : {} { [ "static" ] Block() } /* * Type, name and expression syntax follows. */ void Type() : {} { ( PrimitiveType() | Name() ) ( "[" "]" )* } void PrimitiveType() : {} { "boolean" | "char" | "byte" | "short" | "int" | "long" | "float" | "double" } void ResultType() : {} { "void" | Type() } void Name() : /* * A lookahead of 2 is required below since "Name" can be followed * by a ".*" when used in the context of an "ImportDeclaration". */ {} { ( LOOKAHEAD(2) "." )* } void NameList() : {} { Name() ( "," Name() )* } /* * Expression syntax follows. */ void Expression() : {} { LOOKAHEAD( PrimaryExpression() AssignmentOperator() ) Assignment() | ConditionalExpression() } void Assignment() : {} { PrimaryExpression() AssignmentOperator() Expression() } void AssignmentOperator() : {} { "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" } void ConditionalExpression() : {} { ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ] } void ConditionalOrExpression() : {} { ConditionalAndExpression() ( "||" ConditionalAndExpression() )* } void ConditionalAndExpression() : {} { InclusiveOrExpression() ( "&&" InclusiveOrExpression() )* } void InclusiveOrExpression() : {} { ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )* } void ExclusiveOrExpression() : {} { AndExpression() ( "^" AndExpression() )* } void AndExpression() : {} { EqualityExpression() ( "&" EqualityExpression() )* } void EqualityExpression() : {} { InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )* } void InstanceOfExpression() : {} { RelationalExpression() [ "instanceof" Type() ] } void RelationalExpression() : {} { ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )* } void ShiftExpression() : {} { AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )* } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { ( "+" | "-" ) UnaryExpression() | PreIncrementExpression() | PreDecrementExpression() | UnaryExpressionNotPlusMinus() } void PreIncrementExpression() : {} { "++" PrimaryExpression() } void PreDecrementExpression() : {} { "--" PrimaryExpression() } void UnaryExpressionNotPlusMinus() : {} { ( "~" | "!" ) UnaryExpression() | LOOKAHEAD( CastLookahead() ) CastExpression() | PostfixExpression() } // This production is to determine lookahead only. The LOOKAHEAD specifications // below are not used, but they are there just to indicate that we know about // this. void CastLookahead() : {} { LOOKAHEAD(2) "(" PrimitiveType() | LOOKAHEAD("(" Name() "[") "(" Name() "[" "]" | "(" Name() ")" ( "~" | "!" | "(" | | "this" | "super" | "new" | Literal() ) } void PostfixExpression() : {} { PrimaryExpression() [ "++" | "--" ] } void CastExpression() : {} { LOOKAHEAD("(" PrimitiveType()) "(" Type() ")" UnaryExpression() | LOOKAHEAD("(" Name()) "(" Type() ")" UnaryExpressionNotPlusMinus() } void PrimaryExpression() : {} { PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )* } void PrimaryPrefix() : {} { Literal() | Name() | "this" | "super" "." | "(" Expression() ")" | AllocationExpression() } void PrimarySuffix() : {} { LOOKAHEAD(2) "." "this" | LOOKAHEAD(2) "." "class" | LOOKAHEAD(2) "." AllocationExpression() | "[" Expression() "]" | "." | Arguments() } void Literal() : {} { | | | | BooleanLiteral() | NullLiteral() } void BooleanLiteral() : {} { "true" | "false" } void NullLiteral() : {} { "null" } void Arguments() : {} { "(" [ ArgumentList() ] ")" } void ArgumentList() : {} { Expression() ( "," Expression() )* } void AllocationExpression() : {} { LOOKAHEAD(2) "new" PrimitiveType() ArrayDimensions() [ ArrayInitializer() ] | "new" Name() ( ArrayDimensions() [ ArrayInitializer() ] | Arguments() [ ClassBody() ] ) } /* * The second LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */ void ArrayDimensions() : {} { ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* } /* * Statement syntax follows. */ void Statement() : {} { LOOKAHEAD(2) LabeledStatement() | Block() | EmptyStatement() | StatementExpression() ";" | SwitchStatement() | IfStatement() | WhileStatement() | DoStatement() | ForStatement() | BreakStatement() | ContinueStatement() | ReturnStatement() | ThrowStatement() | SynchronizedStatement() | TryStatement() } void LabeledStatement() : {} { ":" Statement() } void Block() : {} { "{" ( BlockStatement() )* "}" } void BlockStatement() : {} { LOOKAHEAD([ "final" ] Type() ) LocalVariableDeclaration() ";" | Statement() | UnmodifiedClassDeclaration() } void LocalVariableDeclaration() : {} { [ "final" ] Type() VariableDeclarator() ( "," VariableDeclarator() )* } void EmptyStatement() : {} { ";" } void StatementExpression() : /* * The last expansion of this production accepts more than the legal * Java expansions for StatementExpression. */ {} { PreIncrementExpression() | PreDecrementExpression() | LOOKAHEAD( PrimaryExpression() AssignmentOperator() ) Assignment() | PostfixExpression() } void SwitchStatement() : {} { "switch" "(" Expression() ")" "{" ( SwitchLabel() ( BlockStatement() )* )* "}" } void SwitchLabel() : {} { "case" Expression() ":" | "default" ":" } void IfStatement() : /* * The disambiguating algorithm of JavaCC automatically binds dangling * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */ {} { "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ] } void WhileStatement() : {} { "while" "(" Expression() ")" Statement() } void DoStatement() : {} { "do" Statement() "while" "(" Expression() ")" ";" } void ForStatement() : {} { "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement() } void ForInit() : {} { LOOKAHEAD( [ "final" ] Type() ) LocalVariableDeclaration() | StatementExpressionList() } void StatementExpressionList() : {} { StatementExpression() ( "," StatementExpression() )* } void ForUpdate() : {} { StatementExpressionList() } void BreakStatement() : {} { "break" [ ] ";" } void ContinueStatement() : {} { "continue" [ ] ";" } void ReturnStatement() : {} { "return" [ Expression() ] ";" } void ThrowStatement() : {} { "throw" Expression() ";" } void SynchronizedStatement() : {} { "synchronized" "(" Expression() ")" Block() } void TryStatement() : /* * Semantic check required here to make sure that at least one * finally/catch is present. */ {} { "try" Block() ( "catch" "(" FormalParameter() ")" Block() )* [ "finally" Block() ] } /*************************************************************************** * JavaCC tokens start here ***************************************************************************/ TOKEN : // Reserved words { | | | | | | | | | | | } TOKEN : // Moved here from Java grammar { < IDENTIFIER: (|)* > } TOKEN : { } /*************************************************************************** * JavaCC grammar starts here ***************************************************************************/ void JavaCCInput() : {} { JavaCCOptions() CompilationUnit() ( Production() )* } void JavaCCOptions() : {} { [ ( OptionBinding() )* ] } void OptionBinding() : {} { /* Changed for JTB 1.1 LOOKAHEAD(3) | BooleanLiteral() */ ( | | | ) ( | BooleanLiteral() | ) } void Production() : {} { JavaCodeProduction() | RegularExprProduction() | BNFProduction() | TokenManagerDecls() } void JavaCodeProduction() : {} { ResultType() FormalParameters() // this already has parens in it Block() } void BNFProduction() : {} { ResultType() FormalParameters() "{" (BlockStatement())* "}" ExpansionChoices() } void RegularExprProduction() : {} { [ LexicalStateList() ] RegExprKind() [ ] RegExprSpec() ( RegExprSpec() )* } void TokenManagerDecls() : {} { ClassBody() } void LexicalStateList() : {} { LOOKAHEAD(2) | ( )* } void RegExprKind() : {} { | | | } void RegExprSpec() : {} { RegularExpression() [ Block() ] [ ] } void ExpansionChoices() : {} { Expansion() ( Expansion() )* } void Expansion() : {} { ( LOOKAHEAD(ExpansionUnit()) ExpansionUnit() )* } void ExpansionUnit() : {} { LocalLookahead() | Block() | LOOKAHEAD(3) ExpansionChoices() [ | | ] | ExpansionChoices() | [ LOOKAHEAD(2000000000) PrimaryExpression() ] ExpansionUnitTerm() } void ExpansionUnitTerm() : {} { RegularExpression() | Arguments() } void LocalLookahead() : {} { [ LOOKAHEAD(2) ] [ LOOKAHEAD(2) ] ExpansionChoices() [ ] [ Expression() ] } void RegularExpression() : {} { | LOOKAHEAD(3) [ [ ] ] ComplexRegularExpressionChoices() | LOOKAHEAD(2) | } void ComplexRegularExpressionChoices() : {} { ComplexRegularExpression() ( ComplexRegularExpression() )* } void ComplexRegularExpression() : {} { ( ComplexRegularExpressionUnit() )* } void ComplexRegularExpressionUnit() : {} { | | CharacterList() | ComplexRegularExpressionChoices() [ | | ] } void CharacterList() : {} { [ ] [ CharacterDescriptor() ( CharacterDescriptor() )* ] } void CharacterDescriptor() : {} { [ ] } jtb-1.4.4/EDU/purdue/jtb/LICENSE0000644000175000017500000000304411360636752015636 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ jtb-1.4.4/EDU/purdue/jtb/misc/0000755000175000017500000000000011420623644015554 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/misc/UnicodeConverter.java0000644000175000017500000001420211360636750021701 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class UnicodeConverter contains some methods to convert unicode chars into their escape sequence * form (provided by James Huang from the JavaCC mailing list). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class UnicodeConverter { /** * Prints on System.out a string, converting its non ASCII characters in their Unicode * representation. * * @param s a String to print */ public static void printout(final String s) { System.out.print(convertString(s)); } /** * Tells whether a character is an ASCII character or not.
* ASCII characters are between 0x20 and 0x7e included, or tab, new line, carriage return. * * * @param c a character * @return true if ASCII, false otherwise */ public static boolean isASCII(final char c) { return (c >= 32 && c <= 126) || (c == '\r') || (c == '\n') || (c == '\t'); } /** * Converts an hexadecimal value into a character. * * @param hex the hexadecimal value * @return the corresponding character */ public static char hexToChar(final int hex) { if (hex < 10) return (char) (hex + '0'); else return (char) (hex - 10 + 'a'); } /** * Converts a character in its Unicode representation. * * @param c a character * @return the converted character array */ public static char[] unicodeToString(final char c) { final char[] ca = { '\\', 'u', '\0', '\0', '\0', '\0' }; ca[2] = hexToChar((c >> 12) & 0x0f); ca[3] = hexToChar((c >> 8) & 0x0f); ca[4] = hexToChar((c >> 4) & 0x0f); ca[5] = hexToChar(c & 0x0f); return ca; } /** * Converts a string by replacing non ASCII characters by their Unicode representation. * * @param s the string to convert to Unicode * @return the converted string */ public static String convertString(final String s) { final int len = s.length(); final StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { final char c = s.charAt(i); if (isASCII(c)) sb.append(c); else sb.append(unicodeToString(c)); } return sb.toString(); } /** * Converts a string by replacing non ASCII characters with their Unicode representation.
* ASCII characters are between 0x20 and 0x7e included, or tab, new line, carriage return or form * feed.
* Should be the same as {@link #convertString(String)} but comes from JavaCC. * * @param str a string * @return the converted string */ // ModMMa : added public static String addUnicodeEscapes(final String str) { final int strlen = str.length(); int found = 0; for (int i = 0; i < strlen; i++) { final char ch = str.charAt(i); if ((ch < 0x20 || ch > 0x7e) && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f') { found++; } } if (found > 0) { final StringBuilder buf = new StringBuilder(strlen + found * 5); for (int i = 0; i < strlen; i++) { final char ch = str.charAt(i); if ((ch < 0x20 || ch > 0x7e) && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f') { final String chstr = Integer.toString(ch, 16); final int chstrlen = chstr.length(); buf.append("\\u"); for (int j = chstrlen; j < 4; j++) buf.append("0"); buf.append(chstr); } else { buf.append(ch); } } return buf.toString(); } else { return str; } } } jtb-1.4.4/EDU/purdue/jtb/misc/Messages.java0000644000175000017500000001657211360636750020206 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class Messages handles messages (informations, warnings and fatal errors), printing a message to the user * and handling it appropriately. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : enhanced */ public class Messages { /** The number of errors */ private static int numErrors = 0; /** The number of warnings */ private static int numWarnings = 0; /** The number of informations */ private static int numInfos = 0; /** * Prints on System.err the number of informations, warnings and errors */ public static void printSummary() { System.err.println(numInfos + " informations, " + numWarnings + " warnings, " + numErrors + " errors."); } /** * Prints on System.out an information text. * * @param s an information text */ public static void info(final String s) { info(s, -1); } /** * Prints on System.out an information text and its line number. * * @param s an information text * @param lineNum a warning line number */ public static void info(final String s, final int lineNum) { if (lineNum == -1) System.out.println(Globals.jtbInputFileName + ": info: " + s); else System.out.println(Globals.jtbInputFileName + " (" + Integer.toString(lineNum) + "): info: " + s); ++numInfos; } /** * Prints on System.err a warning text. * * @param s a warning text */ public static void warning(final String s) { warning(s, -1); } /** * Prints on System.err a warning text and its line number. * * @param s a warning text * @param lineNum a warning line number */ public static void warning(final String s, final int lineNum) { if (lineNum == -1) System.err.println(Globals.jtbInputFileName + ": warning: " + s); else System.err.println(Globals.jtbInputFileName + " (" + Integer.toString(lineNum) + "): warning: " + s); ++numWarnings; } /** * Prints on System.err a soft (non fatal) error text. * * @param s an error text */ public static void softErr(final String s) { softErr(s, -1); } /** * Prints on System.err a soft (non fatal) error text and its line number. * * @param s an error text * @param lineNum an error line number */ public static void softErr(final String s, final int lineNum) { if (lineNum == -1) System.err.println(Globals.jtbInputFileName + ": soft error: " + s); else System.err.println(Globals.jtbInputFileName + " (" + Integer.toString(lineNum) + "): " + s); ++numErrors; } /** * Prints on System.err a message. * * @param s a message */ public static void notice(final String s) { System.err.println(Globals.jtbInputFileName + ": " + s); } /** * Prints on System.err a fatal error message, its stack trace, and terminates the program. * * @param s a message */ public static void hardErr(final String s) { System.err.println(Globals.jtbInputFileName + ": unexpected program error: " + s); System.err.println(); System.err.println("Please report this to " + Globals.SUPPORT); System.err.println(); try { throw new Exception(); } catch (final Exception e) { e.printStackTrace(); System.err.println(); System.exit(-1); } } /** * Prints on System.err a fatal error message, its stack trace, and terminates the program. * * @param t a Throwable */ public static void hardErr(final Throwable t) { System.err .println(Globals.jtbInputFileName + ": unexpected program error: " + t.getMessage()); System.err.println(); System.err.println("Please report this to " + Globals.SUPPORT); System.err.println(); // t.printStackTrace(); System.exit(-1); } /** * @return the number of informations */ public static int infoCount() { return numInfos; } /** * @return the number of warnings */ public static int warningCount() { return numWarnings; } /** * @return the number of errors */ public static int errorCount() { return numErrors; } /** * Sets the number of errors. * * @param i the number of errors */ public static void setErrorCount(final int i) { numErrors = i; } /** * Sets the number of warnings. * * @param i the number of warnings */ public static void setWarningCount(final int i) { numWarnings = i; } /** * Sets the number of informations. * * @param i the number of informations */ public static void setInfoCount(final int i) { numInfos = i; } /** * Resets to zero the number of errors and warnings. */ public static void resetCounts() { numErrors = numWarnings = numInfos = 0; } } jtb-1.4.4/EDU/purdue/jtb/misc/DepthFirstVisitorsGenerator.java0000644000175000017500000010327311365275212024115 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may * be made for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeList; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.visitor.AcceptInliner; /** * Class DepthFirstVisitorsGenerator contains methods to generate the different DepthFirstXXXVisitor * visitors classes files.
* It must be constructed with the list of the grammar {@link ClassInfo} classes.
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.3.1 : 20/04/2009 : MMa : removed unnecessary @SuppressWarnings("unused") in * genNodeTokenVisit * @version 1.4.3.3 : 27/04/2009 : MMa : put back @SuppressWarnings("unused") in genNodeTokenVisit */ public class DepthFirstVisitorsGenerator { /** The classes list */ private final ArrayList classesList; /** The (generated) visitors directory */ private final File visitorDir; /** The BufferedReaders buffer size */ public static final int BR_BUF_SZ = 16 * 1024; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** The javadoc break plus the OS line separator */ public static final String BRLS = "
" + LS; /** The javadoc break plus the OS line separator string lenght */ public static final int BRLSLEN = BRLS.length(); /** The (reused) buffer for reformatting javadoc comments into single line ones */ final StringBuilder cb = new StringBuilder(512); /** The accept methods inliner visitor */ static AcceptInliner al = null; /** The indentation object */ final Spacing spc = new Spacing(Globals.INDENT_AMT); /** The buffer to write to */ StringBuilder sb = null; /** * Constructor. Creates the visitor directory if it does not exist. * * @param classes the classes list */ public DepthFirstVisitorsGenerator(final ArrayList classes) { classesList = classes; sb = new StringBuilder(sbBufferSize()); visitorDir = new File(Globals.visitorsDirName); if (!visitorDir.exists()) visitorDir.mkdir(); if (Globals.inlineAcceptMethods) al = new AcceptInliner(); } /* * Visitors files generation methods */ /** * Generates the DepthFirstRetArguVisitor file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genDepthFirstRetArguVisitorFile() throws FileExistsException { final String outFilename = Globals.dFRetArguVisitorName + ".java"; try { final File file = new File(visitorDir, outFilename); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), BR_BUF_SZ)); out.print(genDepthFirstRetArguVisitor()); out.close(); } catch (final IOException e) { Messages.hardErr("Could not generate " + outFilename); } } /** * Generates the DepthFirstRetVisitor file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genDepthFirstRetVisitorFile() throws FileExistsException { final String outFilename = Globals.dFRetVisitorName + ".java"; try { final File file = new File(visitorDir, outFilename); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), BR_BUF_SZ)); out.print(genDepthFirstRetVisitor()); out.close(); } catch (final IOException e) { Messages.hardErr("Could not generate " + outFilename); } } /** * Generates the DepthFirstVoidArguVisitor file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genDepthFirstVoidArguVisitorFile() throws FileExistsException { final String outFilename = Globals.dFVoidArguVisitorName + ".java"; try { final File file = new File(visitorDir, outFilename); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), BR_BUF_SZ)); out.print(genDepthFirstVoidArguVisitor()); out.close(); } catch (final IOException e) { Messages.hardErr("Could not generate " + outFilename); } } /** * Generates the DepthFirstVoidVisitor file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genDepthFirstVoidVisitorFile() throws FileExistsException { final String outFilename = Globals.dFVoidVisitorName + ".java"; try { final File file = new File(visitorDir, outFilename); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), BR_BUF_SZ)); out.print(genDepthFirstVoidVisitor()); out.close(); } catch (final IOException e) { Messages.hardErr("Could not generate " + outFilename); } } /* * Visitors source classes generation methods */ /** * Generates a DepthFirstRetArguVisitor class source. * * @return the buffer with the DepthFirstRetArguVisitor class source */ public StringBuilder genDepthFirstRetArguVisitor() { final String clDecl = Globals.dFRetArguVisitorName.concat("<").concat(Globals.genRetType) .concat(", ").concat(Globals.genArguType) .concat("> implements ") .concat(Globals.iRetArguVisitorName) .concat("<").concat(Globals.genRetType) .concat(", ").concat(Globals.genArguType) .concat(">"); final String consBeg = Globals.genRetType.concat(" visit(final "); final String consEnd = " n, final ".concat(Globals.genArguType).concat(" argu)"); return genAnyDepthFirstVisitor(Globals.retArguVisitorComment, clDecl, consBeg, consEnd, true, true); } /** * Generates a DepthFirstRetVisitor class source. * * @return the buffer with the DepthFirstRetArguVisitor class source */ public StringBuilder genDepthFirstRetVisitor() { final String clDecl = Globals.dFRetVisitorName.concat("<").concat(Globals.genRetType) .concat("> implements ") .concat(Globals.iRetVisitorName).concat("<") .concat(Globals.genRetType).concat(">"); final String consBeg = Globals.genRetType.concat(" visit(final "); final String consEnd = " n)"; return genAnyDepthFirstVisitor(Globals.retVisitorComment, clDecl, consBeg, consEnd, true, false); } /** * Generates a DepthFirstVoidArguVisitor class source. * * @return the buffer with the DepthFirstRetArguVisitor class source */ public StringBuilder genDepthFirstVoidArguVisitor() { final String clDecl = Globals.dFVoidArguVisitorName.concat("<").concat(Globals.genArguType) .concat("> implements ") .concat(Globals.iVoidArguVisitorName) .concat("<").concat(Globals.genArguType) .concat(">"); final String consBeg = "void visit(final "; final String consEnd = " n, final ".concat(Globals.genArguType).concat(" argu)"); return genAnyDepthFirstVisitor(Globals.voidArguVisitorComment, clDecl, consBeg, consEnd, false, true); } /** * Generates a DepthFirstVoidVisitor class source. * * @return the buffer with the DepthFirstRetArguVisitor class source */ public StringBuilder genDepthFirstVoidVisitor() { final String clDecl = Globals.dFVoidVisitorName.concat(" implements ") .concat(Globals.iVoidVisitorName); final String consBeg = "void visit(final "; final String consEnd = " n)"; return genAnyDepthFirstVisitor(Globals.voidVisitorComment, clDecl, consBeg, consEnd, false, false); } /** * Common method to generate all the DepthFirst visitors. * * @param aComment a visitor type that will be inserted in the class comment * @param aClDecl the class declaration * @param aConsBeg the beginning of the visit methods * @param aConsEnd the end of the visit methods * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ public StringBuilder genAnyDepthFirstVisitor(final String aComment, final String aClDecl, final String aConsBeg, final String aConsEnd, final boolean aRet, final boolean aArgu) { sb.setLength(0); sb.append(Globals.genFileHeaderComment()).append(LS); sb.append("package ").append(Globals.visitorsPackageName).append(";").append(LS).append(LS); if (!Globals.visitorsPackageName.equals(Globals.nodesPackageName)) sb.append("import ").append(Globals.nodesPackageName).append(".*;").append(LS); sb.append("import java.util.*;").append(LS).append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb .append( " * Provides default methods which visit each node in the tree in depth-first order.
") .append(LS); sb.append(" * In your \"").append(aComment) .append("\" visitors extend this class and override part or all of these methods.") .append(LS); sb.append(" *").append(LS); if (aRet) sb.append(" * @param The user return information type").append(LS); if (aArgu) sb.append(" * @param The user argument type").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(aClDecl).append(" {").append(LS).append(LS); spc.updateSpc(+1); if (Globals.depthLevel) { if (Globals.javaDocComments) { sb.append(spc.spc).append("/** The depth level (0, 1, ...) */").append(LS); } sb.append(spc.spc).append("int depthLevel = 0;").append(LS); } genBaseNodesVisitMethods(sb, spc, aRet, aArgu); if (Globals.javaDocComments) { sb.append(spc.spc).append("/*").append(LS); sb.append(spc.spc) .append(" * User grammar generated visit methods (to be overridden if necessary)") .append(LS); sb.append(spc.spc).append(" */").append(LS).append(LS); } for (final Iterator e = classesList.iterator(); e.hasNext();) { final ClassInfo classInfo = e.next(); final String className = classInfo.getClassName(); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link ").append(className) .append("} node, whose children are the following :").append(LS); sb.append(spc.spc).append(" *

").append(LS); sb.append(classInfo.genAllFieldsComment(spc)); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aConsBeg).append(className).append(aConsEnd) .append(" {").append(LS); spc.updateSpc(+1); if (aRet) sb.append(spc.spc).append(Globals.genRetType).append(" nRes = null;").append(LS); if (Globals.inlineAcceptMethods) { // inline, call visitor al.genAcceptMethods(sb, spc, classInfo, aRet, aArgu); } else { // no inlining, just direct accept calls // TODO for EUT3, try / catch / finally java code should be printed !!! final Iterator fni = classInfo.getFieldNames().iterator(); Iterator fci = null; if (Globals.javaDocComments) fci = classInfo.getFieldComments().iterator(); for (; fni.hasNext();) { final String fn = fni.next(); if (fci != null) sb.append(spc.spc).append(fmtComment(fci.next())).append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc).append("n.").append(fn); sb.append(".accept(this").append(aArgu ? ", argu" : "").append(");").append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); } } if (aRet) sb.append(spc.spc).append("return nRes;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS).append(LS); } spc.updateSpc(-1); sb.append("}").append(LS); return sb; } /** * Reformats javadoc comments into single line ones. * * @param com the javadoc comment * @return the buffer */ StringBuilder fmtComment(final String com) { cb.setLength(0); final int cl = com.length(); for (int i = 0; i < cl - 3;) { if (" * ".equals(com.substring(i, i + 3))) { cb.append("// "); i += 3; } else if (BRLS.equals(com.substring(i, i + BRLSLEN))) { if (i + BRLSLEN < cl) cb.append(LS).append(spc.spc); i += BRLSLEN; } else { cb.append(com.charAt(i)); i++; } } return cb; } /* * The base classes visit methods */ /** * Generates the base nodes classes visit methods. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genBaseNodesVisitMethods(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(4400); sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/*").append(LS); sb.append(spc.spc) .append(" * Base nodes classes visit methods (to be overridden if necessary)").append(LS); sb.append(spc.spc).append(" */").append(LS).append(LS); } genNodeChoiceVisit(sb, spc, aRet, aArgu); sb.append(LS); genNodeListVisit(sb, spc, aRet, aArgu); sb.append(LS); genNodeListOptVisit(sb, spc, aRet, aArgu); sb.append(LS); genNodeOptVisit(sb, spc, aRet, aArgu); sb.append(LS); genNodeSeqVisit(sb, spc, aRet, aArgu); sb.append(LS); genNodeTokenVisit(sb, spc, aRet, aArgu); sb.append(LS); return sb; } /** * Generates the base node {@link NodeChoice} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeChoiceVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(900); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeChoice} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeChoiceName).append(" n"); if (aArgu) sb.append(", final ").append(Globals.genArguType).append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); if (aRet) { sb.append(spc.spc).append("final ").append(Globals.genRetType) .append(" nRes = n.choice.accept(this").append(aArgu ? ", argu" : "").append(");") .append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); sb.append(spc.spc).append("return nRes;").append(LS); } else { sb.append(spc.spc).append("n.choice.accept(this").append(aArgu ? ", argu" : "").append(");") .append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); sb.append(spc.spc).append("return;").append(LS); } spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Generates the base node {@link NodeList} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeListVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(900); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeList} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeListName).append(" n"); if (aArgu) sb.append(", final ").append(Globals.genArguType).append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); if (aRet) sb.append(spc.spc).append(Globals.genRetType).append(" nRes = null;").append(LS); sb.append(spc.spc).append("for (final Iterator<").append(Globals.iNodeName) .append("> e = n.elements(); e.hasNext();) {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc); if (aRet) { sb.append("@SuppressWarnings(\"unused\")").append(LS); sb.append(spc.spc).append("final ").append(Globals.genRetType).append(" sRes = "); } sb.append("e.next().accept(this").append(aArgu ? ", argu" : "").append(");").append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(spc.spc).append("return").append(aRet ? " nRes" : "").append(";").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Generates the base node {@link NodeListOptional} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeListOptVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1100); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeListOptional} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeListOptName).append(" n"); if (aArgu) sb.append(", final ").append(Globals.genArguType).append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("if (n.present()) {").append(LS); spc.updateSpc(+1); if (aRet) sb.append(spc.spc).append(Globals.genRetType).append(" nRes = null;").append(LS); sb.append(spc.spc).append("for (final Iterator<").append(Globals.iNodeName) .append("> e = n.elements(); e.hasNext();) {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc); if (aRet) { sb.append("@SuppressWarnings(\"unused\")").append(LS); sb.append(spc.spc).append(Globals.genRetType).append(" sRes = "); } sb.append("e.next().accept(this").append(aArgu ? ", argu" : "").append(");").append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); sb.append(spc.spc).append("}").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("return").append(aRet ? " nRes" : "").append(";").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("} else").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("return").append(aRet ? " null" : "").append(";").append(LS); spc.updateSpc(-1); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Generates the base node {@link NodeOptional} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeOptVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(720); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeOptional} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeOptName).append(" n"); if (aArgu) sb.append(", final ").append(Globals.genArguType).append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); if (aRet) { sb.append(spc.spc).append("if (n.present()) {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc).append("final ").append(Globals.genRetType) .append(" nRes = n.node.accept(this").append(aArgu ? ", argu" : "").append(");").append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); sb.append(spc.spc).append("return nRes;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("} else").append(LS); } else { sb.append(spc.spc).append("if (n.present()) {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc).append("n.node.accept(this").append(aArgu ? ", argu" : "").append(");") .append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); sb.append(spc.spc).append("return;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("} else").append(LS); } sb.append(spc.spc).append("return").append(aRet ? " null" : "").append(";").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Generates the base node {@link NodeSequence} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeSeqVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(920); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeSequence} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeSeqName).append(" n"); if (aArgu) sb.append(", final ").append(Globals.genArguType).append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); if (aRet) sb.append(spc.spc).append(Globals.genRetType).append(" nRes = null;").append(LS); sb.append(spc.spc).append("for (final Iterator<").append(Globals.iNodeName) .append("> e = n.elements(); e.hasNext();) {").append(LS); spc.updateSpc(+1); if (Globals.depthLevel) sb.append(spc.spc).append("++depthLevel;").append(LS); sb.append(spc.spc); if (aRet) { sb.append("@SuppressWarnings(\"unused\")").append(LS); sb.append(spc.spc).append(Globals.genRetType).append(" subRet = "); } sb.append("e.next().accept(this").append(aArgu ? ", argu" : "").append(");").append(LS); if (Globals.depthLevel) sb.append(spc.spc).append("--depthLevel;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(spc.spc).append("return").append(aRet ? " nRes" : "").append(";").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Generates the base node {@link NodeToken} visit method. * * @param aSB the buffer to output into (will be allocated if null) * @param spc the indentation * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise * @return the buffer with the DepthFirst visitor class source */ static StringBuilder genNodeTokenVisit(final StringBuilder aSB, final Spacing spc, final boolean aRet, final boolean aArgu) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(680); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Visits a {@link NodeToken} node") .append(aArgu ? ", passing it an argument." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) sb.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) sb.append(spc.spc).append(" * @return the user return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(aRet ? Globals.genRetType : "void") .append(" visit(final ").append(Globals.nodeTokenName).append(" n"); if (aArgu) sb.append(", @SuppressWarnings(\"unused\") final ").append(Globals.genArguType) .append(" argu"); sb.append(") {").append(LS); spc.updateSpc(+1); if (aRet) sb.append(spc.spc).append(Globals.genRetType).append(" nRes = null;").append(LS); sb.append(spc.spc).append("@SuppressWarnings(\"unused\")").append(LS); sb.append(spc.spc).append("final String tkIm = n.tokenImage;").append(LS); sb.append(spc.spc).append("return").append(aRet ? " nRes" : "").append(";").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); return sb; } /** * Estimates the visitors files size. * * @return the estimated size */ int sbBufferSize() { return (Globals.javaDocComments ? 600 : 300) * classesList.size(); } } jtb-1.4.4/EDU/purdue/jtb/misc/Globals.java0000644000175000017500000002671511416553766020031 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may * be made for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class Globals contains global program information. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-11/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.1 : 02/2010 : MMa : added static flag */ public class Globals { /* * Global constants */ /** The java program name */ public static final String PROG_NAME = "JTB"; /** The shell script name */ public static final String SCRIPT_NAME = "jtb"; /** The program version */ public static final String VERSION = "1.4.4"; /** The serial uid version */ public static final long SERIAL_UID = 144L; /** Some of the authors */ public static final String AUTHORS = "Wanjun Wang, Kevin Tao, Vids Samanta, Marc Mazas"; /** An indication in case of JTB internal errors */ public static final String SUPPORT = "support"; /** Turns on / off debugging class comment printing */ public static final boolean PRINT_CLASS_COMMENT = false; /** The indentation default number of characters */ public static final int INDENT_AMT = 2; /* * Classes / interfaces names (constants) */ /** Node interface that all tree nodes implement */ public static final String iNodeName = "INode"; /** List interface that NodeList, NodeListOptional and NodeSequence implement */ public static final String iNodeListName = "INodeList"; /** Node representing a grammar choice such as ( A | B ) */ public static final String nodeChoiceName = "NodeChoice"; /** Node representing a list such as ( A )+ */ public static final String nodeListName = "NodeList"; /** Node representing an optional list such as (A )* */ public static final String nodeListOptName = "NodeListOptional"; /** Node representing an optional such as [ A ] or ( A )? */ public static final String nodeOptName = "NodeOptional"; /** Node representing a nested sequence of nodes */ public static final String nodeSeqName = "NodeSequence"; /** Node representing a token string such as "package" */ public static final String nodeTokenName = "NodeToken"; /** Fake node type representing the tokens "try {" in an ExpansionUnit type 3 */ public static final String fakeNodeLeftTry = "fakeNodeLeftTry"; /** Fake node type representing the tokens "}" in an ExpansionUnit type 3 */ public static final String fakeNodeRightTry = "fakeNodeRightTry"; /** Fake node type representing the tokens "catch (...) {...}" in an ExpansionUnit type 3 */ public static final String fakeNodeCatch = "fakeNodeCatch"; /** Fake node type representing the tokens "finally {...}" in an ExpansionUnit type 3 */ public static final String fakeNodeFinally = "fakeNodeFinally"; /** "RetArgu" visitor interface name (with return type and a user object argument) */ public static final String iRetArguVisitorName = "IRetArguVisitor"; /** Depth First "RetArgu" visitor class name (with return type and a user object argument) */ public static final String dFRetArguVisitorName = "DepthFirstRetArguVisitor"; /** Javadoc comment fragment for "RetArgu" visitor */ public static final String retArguVisitorComment = "RetArgu"; /** "Ret" visitor interface name (with return type and no user object argument) */ public static final String iRetVisitorName = "IRetVisitor"; /** Depth First "Ret" visitor class name (with return type and no user object argument) */ public static final String dFRetVisitorName = "DepthFirstRetVisitor"; /** Javadoc comment fragment for "Ret" visitor */ public static final String retVisitorComment = "Ret"; /** "VoidArgu" visitor interface name (with no return type and a user object argument) */ public static final String iVoidArguVisitorName = "IVoidArguVisitor"; /** Depth First "VoidArgu" visitor class name (with no return type and a user object argument) */ public static final String dFVoidArguVisitorName = "DepthFirstVoidArguVisitor"; /** Javadoc comment fragment for "VoidArgu" visitor */ public static final String voidArguVisitorComment = "VoidArgu"; /** "Void" visitor interface name (with no return type and no user object argument)) */ public static final String iVoidVisitorName = "IVoidVisitor"; /** Depth First "Void" visitor class name (with no return type and no user object argument) */ public static final String dFVoidVisitorName = "DepthFirstVoidVisitor"; /** Javadoc comment fragment for "Void" visitor */ public static final String voidVisitorComment = "Void"; /** Generics visitor methods return type */ public static final String genRetType = "R"; /** Generics visitor methods user argument (second argument) type */ public static final String genArguType = "A"; /** The JTB result type variables prefix */ public static final String JTBRT_PREFIX = "jtbrt_"; /* * Changeable flags (command line options) */ /** * -cl option which prints the generated classes list to System.out */ public static boolean printClassList = false; /** * -w options which prevents JTB from overwriting existing files */ public static boolean noOverwrite = false; /** * -e option which suppresses JTB semantic error checking */ public static boolean noSemanticCheck = false; /** * -jd option which generates JavaDoc-friendly comments in generated visitors and syntax tree * classes */ public static boolean javaDocComments = false; /** * -f option which generates descriptive node class child field names such as whileStatement, * nodeToken2, ... rather than f0, f1, ... */ public static boolean descriptiveFieldNames = false; /** * -pp option which generates parent pointer and getParent() and setParent() methods in all node * classes */ public static boolean parentPointer = false; /** * -dl option which generates depthLevel field in all visitor classes */ public static boolean depthLevel = false; /** * -tk option which stores special tokens in the parse tree */ public static boolean keepSpecialTokens = false; /** * -ia option which "inlines" the visitors accept methods on base classes */ public static boolean inlineAcceptMethods = false; /** * -scheme option which generates the Scheme programming language record definitions file * records.scm and the SchemeTreeBuilder visitor */ public static boolean schemeToolkit = false; /** * -printer option which generates TreeDumper and TreeFormatter visitors */ public static boolean printerToolkit = false; /** * static or not option that comes from JavaCC */ public static boolean staticFlag = false; /* * Default names */ /** default nodes package name */ public static final String DEF_ND_PKG_NAME = "syntaxtree"; /** default nodes package name */ public static final String DEF_VIS_PKG_NAME = "visitor"; /** default nodes package name */ public static final String DEF_ND_DIR_NAME = "syntaxtree"; /** default nodes package name */ public static final String DEF_VIS_DIR_NAME = "visitor"; /** default nodes package name */ public static final String DEF_OUT_FILE_NAME = "jtb.out.jj"; /* * Changeable names */ /** * -np & -p options which defines the nodes package name (default is syntaxtree) */ public static String nodesPackageName = DEF_ND_PKG_NAME; /** * -vp & -p options which defines the visitors package name (default is visitor) */ public static String visitorsPackageName = DEF_VIS_PKG_NAME; /** * -nd & -d options which defines the nodes directory name (default is syntaxtree) */ public static String nodesDirName = DEF_ND_DIR_NAME; /** * -vd & -d options which defines the visitors directory name (default is visitor) */ public static String visitorsDirName = DEF_VIS_DIR_NAME; /** * -ns option which defines the nodes superclass */ public static String nodesSuperclass = null; /** * the input (jtb) file name (must be set in main) */ public static String jtbInputFileName; /** * -o option which defines the output (generated) file name (default is jtb.out.jj) */ public static String jtbOutputFileName = DEF_OUT_FILE_NAME; /* * Convenience methods */ /** * Builds a file header comment ("Generated by JTB version"). * * @return a file header comment */ public static String genFileHeaderComment() { return "/* Generated by " + PROG_NAME + " " + VERSION + " */"; } } jtb-1.4.4/EDU/purdue/jtb/misc/FieldNameGenerator.java0000644000175000017500000001402711360636750022123 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import java.util.Hashtable; /** * Class FieldNameGenerator generates the names of the fields of node classes depending on whether * the "-f" parameter for descriptive field names has been used or not. *

* By default, field will be named "fX" where X ascends from 0 to the number of children - 1. *

* If the "-f" parameter is used, the names will be based on the classes of the children.
* For example, a child of class "WhileStatement" will be called "whileStatementX" (note the * lowercase first letter), where X is either nothing if this is the first WhileStatement in this * production or 1 through the number of children - 1 for any additional children of the same type. *

* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class FieldNameGenerator { /** The field number */ private int fieldNum = 0; /** * nameTable is used for the "-f" option (Descriptive field names).
* Key = field names in use in current production
* Value = int value of the last suffix used */ private Hashtable nameTable; /** * Constructor. Creates an Hashtable of descriptive field names if the corresponding option flag * is set. */ public FieldNameGenerator() { if (Globals.descriptiveFieldNames) nameTable = new Hashtable(); } /** * Resets the instance. */ public void reset() { fieldNum = 0; if (Globals.descriptiveFieldNames) nameTable.clear(); } /** * Generates the field name used in the comment for a given class field name. * * @param fieldName the class field name * @return the comment field name */ public String genCommentFieldName(final String fieldName) { if (!Globals.descriptiveFieldNames) return "f" + String.valueOf(fieldNum++); else { final String prefix = varNameForClass(fieldName); Integer suffix = nameTable.get(prefix); if (suffix == null) { suffix = new Integer(0); nameTable.put(prefix, suffix); return prefix; } else { suffix = new Integer(suffix.intValue() + 1); nameTable.put(prefix, suffix); return prefix + suffix.toString(); } } } /** * Returns a variable name for the name of the given class.
* Ex : class is "TipTop", variable will be "tipTop". * * @param className the class name * @return the variable name */ public String varNameForClass(final String className) { // final StringBuffer buf = new StringBuffer( // String.valueOf(Character.toLowerCase(className.charAt(0)))); // buf.append(className.substring(1, className.length())); // return buf.toString(); final StringBuffer buf = new StringBuffer(className); buf.setCharAt(0, Character.toLowerCase(className.charAt(0))); return buf.toString(); } /** * Gets the node type corresponding to the modifier. * * @param mod the modifier * @return the node type */ public String getNameForMod(final String mod) { if (mod.equals("+")) return Globals.nodeListName; else if (mod.equals("*")) return Globals.nodeListOptName; else if (mod.equals("?")) return Globals.nodeOptName; else { Messages.hardErr("Illegal EBNF modifier in " + "ExpansionUnit: mod = " + mod); return ""; } } } jtb-1.4.4/EDU/purdue/jtb/misc/JavaBranchPrinter.java0000644000175000017500000001015011360636750021764 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.visitor.JavaPrinter; /** * Class JavaBranchPrinter visits a java code branch of the tree and returns a pretty printed string * representation of the subtree. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class JavaBranchPrinter { /** The buffer to print into */ private final StringBuilder sb; /** The {@link JavaPrinter} to use */ private final JavaPrinter jp; /** The indentation object */ private Spacing spc; /** * Constructs a new instance with a default allocated buffer and a given indentation object. * * @param aSPC an indentation */ public JavaBranchPrinter(final Spacing aSPC) { sb = new StringBuilder(512); spc = aSPC; if (spc == null) spc = new Spacing(Globals.INDENT_AMT); jp = new JavaPrinter(sb, spc); } /** * Visits a given (java code) node branch of the tree and returns a pretty printed string * representation of the subtree.
* Implementation note : it reuses a class allocated StringBuilder buffer, which is therefore * overwritten on a next call. * * @param javaNode the node to walk down and pretty print * @return the pretty print in a reused StringBuilder buffer */ public StringBuilder genJavaBranch(final INode javaNode) { sb.setLength(0); jp.reset(sb, spc); javaNode.accept(jp); return sb; } } jtb-1.4.4/EDU/purdue/jtb/misc/Spacing.java0000644000175000017500000000762011360636750020015 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. All rights reserved. Redistribution and use in source and * binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the * following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials provided with the * distribution. Neither UCLA nor the names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are Copyright 1997, 1998, 1999 by the Purdue * Research Foundation of Purdue University. All rights reserved. Redistribution and use in source and binary * forms are permitted provided that this entire copyright notice is duplicated in all such copies, and that * any documentation, announcements, and other materials related to such distribution and use acknowledge that * the software was developed at Purdue University, West Lafayette, Indiana by Kevin Tao and Jens Palsberg. No * charge may be made for copies, derivations, or distributions of this material without the express written * consent of the copyright holder. Neither the name of the University nor the name of the author may be used * to endorse or promote products derived from this material without specific prior written permission. THIS * SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class Spacing is used for of pretty printing to provide necessary indentation. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class Spacing { /** the indentation amount */ public final int INDENT_AMT; /** the indentation string */ public String spc = ""; /** the indentation level */ public int indentLevel = 0; /** * Constructor. * * @param indentAmt the indentation amount */ public Spacing(final int indentAmt) { INDENT_AMT = indentAmt; } /** * Resets the instance. */ public void reset() { spc = ""; indentLevel = 0; } /** * Returns the indentation string corresponding to the indentation amount and level. */ @Override public String toString() { return spc; } /** * Updates the indentation. * * @param numIndentLvls the (positive or negative) indentation level delta. */ public void updateSpc(final int numIndentLvls) { indentLevel += numIndentLvls; if (numIndentLvls < 0) spc = spc.substring(-1 * numIndentLvls * INDENT_AMT); else if (numIndentLvls > 0) { final StringBuffer buf = new StringBuffer(spc); for (int i = 0; i < numIndentLvls * INDENT_AMT; ++i) buf.append(" "); spc = buf.toString(); } } } jtb-1.4.4/EDU/purdue/jtb/misc/VarInfo.java0000644000175000017500000001134211360636750017771 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class VarInfo stores information for a variable : type, name, initializer, and constructs its * declaration. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : enhanced * @version 1.4.3 : 03/2010 : MMa : added node declarations initialization in all cases */ public class VarInfo { /** The variable type */ private final String type; /** The variable name */ private final String name; /** The variable initializer */ private final String initializer; /** The whole variable declaration */ private String declaration; /** * Creates a new instance with no initializer. * * @param tp the variable type * @param nm the variable name */ public VarInfo(final String tp, final String nm) { this(tp, nm, null); } /** * Creates a new instance with an initializer. * * @param tp the variable type * @param nm the variable name * @param init the variable initializer */ public VarInfo(final String tp, final String nm, final String init) { type = tp; name = nm; initializer = init; declaration = null; } /** * @return the variable type */ public String getType() { return type; } /** * @return the variable name */ public String getName() { return name; } /** * @return the variable initializer */ public String getInitializer() { return initializer; } /** * Same as {@link #generateNodeDeclaration()}. * * @return the whole variable declaration string */ @Override public String toString() { return generateNodeDeclaration(); } /** * Generates and stores, if not yet done, and returns the variable declaration string. * * @return the variable declaration string */ public String generateNodeDeclaration() { if (declaration == null) { final StringBuilder buf = new StringBuilder(64); // always initialize even if initializer is null buf.append(type).append(" ").append(name).append(" = ").append(initializer).append(";"); declaration = buf.toString(); } return declaration; } } jtb-1.4.4/EDU/purdue/jtb/misc/ClassInfo.java0000644000175000017500000004517111360636750020315 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. All rights reserved. Redistribution and use in * source and binary forms, with or without modification, are permitted provided that the following * conditions are met: Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. Redistributions in binary form must reproduce * the above copyright notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. Neither UCLA nor the names * of its contributors may be used to endorse or promote products derived from this software without * specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are Copyright 1997, 1998, 1999 by the * Purdue Research Foundation of Purdue University. All rights reserved. Redistribution and use in * source and binary forms are permitted provided that this entire copyright notice is duplicated in * all such copies, and that any documentation, announcements, and other materials related to such * distribution and use acknowledge that the software was developed at Purdue University, West * Lafayette, Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may be made for copies, * derivations, or distributions of this material without the express written consent of the * copyright holder. Neither the name of the University nor the name of the author may be used to * endorse or promote products derived from this material without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR * PURPOSE. */ package EDU.purdue.jtb.misc; import java.util.ArrayList; import java.util.Iterator; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.visitor.CommentsPrinter; /** * Class ClassInfo is used by the visitors to store and ask for information about a class including * its name, the list of field types, names and initializers. *

* Uses class {@link CommentsPrinter} to find field javadoc comments and format them.
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class ClassInfo { /** The node */ final INode astNode; /** The class name */ final String className; /** The list of the types of the class fields representing the node's children */ final ArrayList fieldTypes; /** The list of the names of the class fields representing the node's children */ final ArrayList fieldNames; /** The list of the initializers of the class fields representing the node's children */ final ArrayList fieldInitializers; /** True if the class allows specific initializing constructor(s) (without {@link NodeToken} nodes */ boolean needInitializingConstructor = false; /** * The list of the javadoc comments of the class fields representing the node's children
* Start with " * " but without indentation, and may be on multiple lines */ ArrayList fieldComments = null; /** The comments printer visitor */ static CommentsPrinter cpv = new CommentsPrinter(); /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Constructs an instance giving an ExpansionChoices node and a name * * @param ec the ExpansionChoices node * @param cn the class name */ public ClassInfo(final ExpansionChoices ec, final String cn) { astNode = ec; className = cn; final int nb = (ec.f1.present() ? ec.f1.size() + 1 : 1); fieldTypes = new ArrayList(nb); fieldNames = new ArrayList(nb); fieldInitializers = new ArrayList(nb); } /** * Getter for the node. * * @return the node */ public INode getAstNode() { return astNode; } /** * Getter for the class name. * * @return the class name */ public String getClassName() { return className; } /** * Getter for the fields types. * * @return the fields types */ public ArrayList getFieldTypes() { return fieldTypes; } /** * Getter for the fields names. * * @return the fields names */ public ArrayList getFieldNames() { return fieldNames; } /** * Getter for the fields comments (which may be null). * * @return the fields comments */ public ArrayList getFieldComments() { return fieldComments; } /** * Setter for the fields comments. * * @param fc the fields comments */ public void setFieldComments(final ArrayList fc) { fieldComments = fc; } /** * Adds a field type, name (with no initializer) to the internal lists. * * @param fieldType the field type * @param fieldName the field name */ public void addField(final String fieldType, final String fieldName) { addField(fieldType, fieldName, null); } /** * Adds a field type, name and initializer to the internal lists. * * @param fieldType the field type * @param fieldName the field name * @param fieldInitializer the field initializer */ public void addField(final String fieldType, final String fieldName, final String fieldInitializer) { fieldTypes.add(fieldType); fieldNames.add(fieldName); if (fieldInitializer == null || fieldInitializer.equals("")) fieldInitializers.add(null); else { fieldInitializers.add(fieldInitializer); needInitializingConstructor = true; } } /** * Generates the BNF description of the current class as a bunch of comments showing which field * names belong to which parts of the production.
* Does not add the javadoc opening and closing delimiters. * * @param spc the indentation * @return the BNF description */ public String genAllFieldsComment(final Spacing spc) { if (fieldComments == null) fieldComments = new ArrayList(fieldNames.size()); return cpv.formatAllFieldsComment(spc, this); } /** * Generates the node class code into a newly allocated buffer. * * @param spc the current indentation * @return the buffer with the node class code */ public StringBuilder genClassString(final Spacing spc) { Iterator types = fieldTypes.iterator(); Iterator names = fieldNames.iterator(); Iterator inits; final StringBuilder sb = new StringBuilder(2048); /* * class declaration */ sb.append(spc.spc).append("public class " + className); if (Globals.nodesSuperclass != null) sb.append(" extends ").append(Globals.nodesSuperclass); sb.append(" implements ").append(Globals.iNodeName).append(" {").append(LS).append(LS); spc.updateSpc(+1); /* * data fields declarations */ for (; types.hasNext();) { if (Globals.javaDocComments) sb.append(spc.spc).append("/** A child node */").append(LS); sb.append(spc.spc).append("public ").append(types.next()).append(" ").append(names.next()) .append(";").append(LS).append(LS); } if (Globals.parentPointer) { if (Globals.javaDocComments) sb.append(spc.spc).append("/** The parent pointer */").append(LS); sb.append(spc.spc).append("private ").append(Globals.iNodeName).append(" parent;").append(LS) .append(LS); } if (Globals.javaDocComments) sb.append(spc.spc).append("/** The serial version uid */").append(LS); sb.append(spc.spc).append("private static final long serialVersionUID = ") .append(Globals.SERIAL_UID + "L;").append(LS).append(LS); /* * standard constructor header */ if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Constructs the node with "); sb.append(fieldTypes.size() > 1 ? "all its children nodes." : "its child node.").append(LS); sb.append(spc.spc).append(" *").append(LS); types = fieldTypes.iterator(); sb.append(spc.spc).append(" * @param n0 ").append(fieldTypes.size() > 1 ? "first" : "the") .append(" child node").append(LS); for (int i = 1; i < fieldTypes.size(); i++) sb.append(spc.spc).append(" * @param n").append(i).append(" next child node").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(className).append("("); types = fieldTypes.iterator(); if (types.hasNext()) sb.append("final ").append(types.next()).append(" n0"); for (int i = 1; types.hasNext(); i++) sb.append(", final ").append(types.next()).append(" n").append(i); sb.append(") {").append(LS); /* * standard constructor body */ names = fieldNames.iterator(); spc.updateSpc(+1); for (int count = 0; names.hasNext(); ++count) { final String nm = names.next(); sb.append(spc.spc).append(nm).append(" = n").append(count).append(";").append(LS); if (Globals.parentPointer) { sb.append(spc.spc).append("if (").append(nm).append(" != null)").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append(nm).append(".setParent(this);").append(LS); spc.updateSpc(-1); } } spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); /* * specific initializing constructor header if necessary */ if (needInitializingConstructor) { int count = 0; boolean firstTime = true; sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Constructs the node with only its non ") .append(Globals.nodeTokenName); sb.append(" child node").append(fieldTypes.size() > 1 ? "(s)." : ".").append(LS); sb.append(spc.spc).append(" *").append(LS); types = fieldTypes.iterator(); inits = fieldInitializers.iterator(); while (types.hasNext()) { types.next(); if (inits.next() == null) { if (!firstTime) sb.append(spc.spc).append(" * @param n").append(count).append(" next child node") .append(LS); else sb.append(spc.spc).append(" * @param n").append(count).append(" first child node") .append(LS); ++count; firstTime = false; } } sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(className).append("("); count = 0; firstTime = true; types = fieldTypes.iterator(); inits = fieldInitializers.iterator(); while (types.hasNext()) { final String type = types.next(); if (inits.next() == null) { if (!firstTime) sb.append(", final "); else sb.append("final "); sb.append(type).append(" n").append(count); ++count; firstTime = false; } } sb.append(") {").append(LS); } /* * specific initializing constructor body if necessary */ if (needInitializingConstructor) { int count = 0; names = fieldNames.iterator(); inits = fieldInitializers.iterator(); spc.updateSpc(+1); while (names.hasNext()) { final String nm = names.next(); final String init = inits.next(); if (init != null) sb.append(spc.spc).append(nm).append(" = ").append(init).append(";").append(LS); else { sb.append(spc.spc).append(nm).append(" = n").append(count).append(";").append(LS); ++count; } if (Globals.parentPointer) { sb.append(spc.spc).append("if (").append(nm).append(" != null)").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append(" ").append(nm).append(".setParent(this);").append(LS); spc.updateSpc(-1); } } spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); } /* * visit methods */ sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Accepts the ").append(Globals.iRetArguVisitorName) .append(" visitor.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param <").append(Globals.genRetType) .append("> the user return type").append(LS); sb.append(spc.spc).append(" * @param <").append(Globals.genArguType) .append("> the user argument type").append(LS); sb.append(spc.spc).append(" * @param vis the visitor").append(LS); sb.append(spc.spc).append(" * @param argu a user chosen argument").append(LS); sb.append(spc.spc).append(" * @return a user chosen return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public <").append(Globals.genRetType).append(", ") .append(Globals.genArguType).append("> " + Globals.genRetType).append(" accept(final ") .append(Globals.iRetArguVisitorName).append("<" + Globals.genRetType).append(", ") .append(Globals.genArguType).append("> vis, final " + Globals.genArguType).append(" argu) {") .append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("return vis.visit(this, argu);").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Accepts the ").append(Globals.iRetVisitorName) .append(" visitor.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param <").append(Globals.genRetType) .append("> the user return type").append(LS); sb.append(spc.spc).append(" * @param vis the visitor").append(LS); sb.append(spc.spc).append(" * @return a user chosen return information").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public <").append(Globals.genRetType).append("> ") .append(Globals.genRetType + " accept(final ").append(Globals.iRetVisitorName).append("<") .append(Globals.genRetType).append("> vis) {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("return vis.visit(this);").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Accepts the ").append(Globals.iVoidArguVisitorName) .append(" visitor.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param <").append(Globals.genArguType) .append("> the user argument type").append(LS); sb.append(spc.spc).append(" * @param vis the visitor").append(LS); sb.append(spc.spc).append(" * @param argu a user chosen argument").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public <").append(Globals.genArguType) .append("> void accept(final " + Globals.iVoidArguVisitorName).append("<") .append(Globals.genArguType).append("> vis, final " + Globals.genArguType).append(" argu) {") .append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("vis.visit(this, argu);").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Accepts the ").append(Globals.iVoidVisitorName) .append(" visitor.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param vis the visitor").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public void accept(final ").append(Globals.iVoidVisitorName) .append(" vis) {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("vis.visit(this);").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); /* * parent getter & setter methods */ if (Globals.parentPointer) { sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Setter for the parent node.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @param n the parent node").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public void setParent(final ").append(Globals.iNodeName) .append(" n) {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("parent = n;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); sb.append(LS); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(spc.spc).append(" * Getter for the parent node.").append(LS); sb.append(spc.spc).append(" *").append(LS); sb.append(spc.spc).append(" * @return the parent node").append(LS); sb.append(spc.spc).append(" */").append(LS); } sb.append(spc.spc).append("public ").append(Globals.iNodeName).append(" getParent() {") .append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("return parent;").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); } /* * end */ spc.updateSpc(-1); sb.append(spc.spc).append(LS); sb.append(spc.spc).append("}").append(LS); return sb; } } jtb-1.4.4/EDU/purdue/jtb/misc/TreeFormatterGenerator.java0000644000175000017500000006614011360636750023065 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; /** * Class TreeFormatterBuilder generates the TreeFormatter visitor which is a skeleton * pretty-printer.
* Using some pre-defined methods, users can quickly and easily create a formatter for their * grammar.
* The formatter will then take a tree, insert token location information into the NodeTokens of the * tree.
* TreeDumper can then be used to output the result.
* Note that unlike the other automatically generated file, since this one must be edited to be * useful, JTB will not overwrite this file automatically.
* JTB will take this precaution for the other files only if the "-ow" command-line parameter is * used. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.3 : 03/2010 : MMa : fixed output of constructor */ public class TreeFormatterGenerator { /** The visitor class name */ public static final String visitorName = "TreeFormatter"; /** The visitor source file name */ public static final String outFilename = visitorName + ".java"; /** The visitors directory */ private final File visitorDir; /** The classes list */ private final ArrayList classList; /** The buffer to print into */ protected StringBuilder sb; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Constructor with a given list of classes. Will create the visitors directory if it does not * exist. * * @param classes the list of classes */ public TreeFormatterGenerator(final ArrayList classes) { classList = classes; sb = new StringBuilder(500 * classes.size()); visitorDir = new File(Globals.visitorsDirName); if (!visitorDir.exists()) visitorDir.mkdir(); } /** * Saves the current buffer in the output file (global variable).
* Since the user is expected to edit and customize this file, this method will never overwrite * the file if it exists, regardless of the global no overwrite flag. * * @throws FileExistsException if the file exists */ public void saveToFile() throws FileExistsException { try { final File file = new File(visitorDir, outFilename); if (file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), sb.length())); out.print(sb); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } // TODO passer les méthodes suivantes en spc.spc /** * Generates the tree formatter visitor source in its file.
* * @throws FileExistsException if the file exists */ public void generateTreeFormatter() throws FileExistsException { sb.append(Globals.genFileHeaderComment()).append(LS); sb.append("package " + Globals.visitorsPackageName + ";").append(LS).append(LS); sb.append("import java.util.ArrayList;").append(LS); sb.append("import java.util.Iterator;").append(LS).append(LS); sb.append("import " + Globals.nodesPackageName + ".*;").append(LS).append(LS); sb.append("/**").append(LS); sb.append(" * A skeleton output formatter for your language grammar.
").append(LS); sb.append(" * Using the add() method along with force(), indent(), and outdent(),
") .append(LS); sb.append(" * you can easily specify how this visitor will format the given syntax tree.
") .append(LS); sb.append(" * See the JTB documentation for more details.").append(LS); sb.append(" *

").append(LS); sb.append(" * Pass your syntax tree to this visitor, and then to the TreeDumper visitor
") .append(LS); sb.append(" * in order to \"pretty print\" your tree.").append(LS); sb.append(" */").append(LS); sb.append("public class TreeFormatter extends " + Globals.dFVoidVisitorName + " {").append(LS) .append(LS); sb.append(" /** The list of formatting commands */").append(LS); sb .append(" private final ArrayList cmdQueue = new ArrayList();") .append(LS); sb.append(" /** True if line to be wrapped, false otherwise */").append(LS); sb.append(" private boolean lineWrap;").append(LS); sb.append(" /** The wrap width */").append(LS); sb.append(" private final int wrapWidth;").append(LS); sb.append(" /** The indentation amount */").append(LS); sb.append(" private final int indentAmt;").append(LS); sb.append(" /** The current line number */").append(LS); sb.append(" private int curLine = 1;").append(LS); sb.append(" /** The current column number */").append(LS); sb.append(" private int curColumn = 1;").append(LS); sb.append(" /** The current indentation */").append(LS); sb.append(" private int curIndent = 0;").append(LS); sb.append(" /** The default indentation */").append(LS); sb.append(" private static int INDENT_AMT = 2;").append(LS).append(LS); sb.append(" /**").append(LS); sb .append( " * Constructor with a default indentation amount of {@link #INDENT_AMT} and no line-wrap.") .append(LS); sb.append(" */").append(LS); sb.append(" public TreeFormatter() { this(INDENT_AMT, 0); }").append(LS).append(LS); sb.append(" /**").append(LS); sb .append( " * Constructor using an indent amount and a line width used to wrap long lines.
") .append(LS); sb.append(" * If a token's beginColumn value is greater than the specified wrapWidth,
") .append(LS); sb.append(" * it will be moved to the next line andindented one extra level.
").append(LS); sb.append(" * To turn off line-wrapping, specify a wrapWidth of 0.").append(LS); sb.append(" *").append(LS); sb.append(" * @param aIndentAmt Amount of spaces per indentation level").append(LS); sb.append(" * @param aWrapWidth Wrap lines longer than wrapWidth. 0 for no wrap").append(LS); sb.append(" */").append(LS); sb.append(" public TreeFormatter(final int aIndentAmt, final int aWrapWidth) {").append(LS); sb.append(" this.indentAmt = aIndentAmt;").append(LS); sb.append(" this.wrapWidth = aWrapWidth;").append(LS).append(LS); sb.append(" if (wrapWidth > 0)").append(LS); sb.append(" lineWrap = true;").append(LS); sb.append(" else").append(LS); sb.append(" lineWrap = false;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Accepts a " + Globals.iNodeListName + " object.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node list to process").append(LS); sb.append(" */").append(LS); sb.append(" protected void processList(final " + Globals.iNodeListName + " n) {").append(LS); sb.append(" processList(n, null);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append( " * Accepts a " + Globals.iNodeListName + " object and performs a format command (if non null)
").append(LS); sb.append(" * between each node in the list (but not after the last node).").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node list to process").append(LS); sb.append(" * @param cmd the format command").append(LS); sb.append(" */").append(LS); sb.append( " protected void processList(final " + Globals.iNodeListName + " n, final FormatCommand cmd) {").append(LS); sb.append( " for (final Iterator<" + Globals.iNodeName + "> e = n.elements(); e.hasNext();) {").append(LS); sb.append(" e.next().accept(this);").append(LS); sb.append(" if (cmd != null && e.hasNext())").append(LS); sb.append(" cmdQueue.add(cmd);").append(LS); sb.append(" }").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb .append( " * Inserts one line break and indents the next line to the current indentation level.
") .append(LS); sb.append(" * Use \"add(force());\".").append(LS); sb.append(" *").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand force() { return force(1); }").append(LS).append(LS); sb.append(" /**").append(LS); sb .append( " * Inserts a given number of line breaks and indents the next line to the current indentation level.
") .append(LS); sb.append(" * Use \"add(force(i));\".").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the number of line breaks").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand force(final int i) {").append(LS); sb.append(" return new FormatCommand(FormatCommand.FORCE, i);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Increases the indentation level by one.
").append(LS); sb.append(" * Use \"add(indent());\".").append(LS); sb.append(" *").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand indent() { return indent(1); }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Increases the indentation level by a given number.
").append(LS); sb.append(" * Use \"add(indent(i));\".").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the number of indentation levels to add").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand indent(final int i) {").append(LS); sb.append(" return new FormatCommand(FormatCommand.INDENT, i);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Reduces the indentation level by one.
").append(LS); sb.append(" * Use \"add(outdent());\".").append(LS); sb.append(" *").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand outdent() { return outdent(1); }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Reduces the indentation level by a given number.
").append(LS); sb.append(" * Use \"add(outdent(i));\".").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the number of indentation levels to substract").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand outdent(final int i) {").append(LS); sb.append(" return new FormatCommand(FormatCommand.OUTDENT, i);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Adds one space between tokens.
").append(LS); sb.append(" * Use \"add(space());\".").append(LS); sb.append(" *").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand space() { return space(1); }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Adds a given number of spaces between tokens.
").append(LS); sb.append(" * Use \"add(space(i));\".").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the number of spaces to add").append(LS); sb.append(" * @return the corresponding FormatCommand").append(LS); sb.append(" */").append(LS); sb.append(" protected FormatCommand space(final int i) {").append(LS); sb.append(" return new FormatCommand(FormatCommand.SPACE, i);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Use this method to add FormatCommands to the command queue to be executed
") .append(LS); sb.append(" * when the next token in the tree is visited.").append(LS); sb.append(" *").append(LS); sb.append(" * @param cmd the FormatCommand to be added").append(LS); sb.append(" */").append(LS); sb.append(" protected void add(final FormatCommand cmd) {").append(LS); sb.append(" cmdQueue.add(cmd);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Executes the commands waiting in the command queue,
").append(LS); sb.append(" * then inserts the proper location information into the current NodeToken.") .append(LS); sb.append(" *

").append(LS); sb.append(" * If there are any special tokens preceding this token,
").append(LS); sb.append(" * they will be given the current location information.
").append(LS); sb.append(" * The token will follow on the next line, at the proper indentation level.
") .append(LS); sb.append(" * If this is not the behavior you want from special tokens,
").append(LS); sb.append(" * feel free to modify this method.").append(LS); sb.append(" */").append(LS); sb.append(" @Override").append(LS); sb.append(" public void visit(final " + Globals.nodeTokenName + " n) {").append(LS); sb.append(" for (Iterator e = cmdQueue.iterator(); e.hasNext();) {") .append(LS); sb.append(" final FormatCommand cmd = e.next();").append(LS); sb.append(" switch (cmd.getCommand()) {").append(LS); sb.append(" case FormatCommand.FORCE :").append(LS); sb.append(" curLine += cmd.getNumCommands();").append(LS); sb.append(" curColumn = curIndent + 1;").append(LS); sb.append(" break;").append(LS); sb.append(" case FormatCommand.INDENT :").append(LS); sb.append(" curIndent += indentAmt * cmd.getNumCommands();").append(LS); sb.append(" break;").append(LS); sb.append(" case FormatCommand.OUTDENT :").append(LS); sb.append(" if (curIndent >= indentAmt)").append(LS); sb.append(" curIndent -= indentAmt * cmd.getNumCommands();").append(LS); sb.append(" break;").append(LS); sb.append(" case FormatCommand.SPACE :").append(LS); sb.append(" curColumn += cmd.getNumCommands();").append(LS); sb.append(" break;").append(LS); sb.append(" default :").append(LS); sb.append(" throw new TreeFormatterException(\"Invalid value in command queue.\");") .append(LS); sb.append(" }").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" cmdQueue.removeAll(cmdQueue);").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Handle all special tokens preceding this NodeToken").append(LS); sb.append(" //").append(LS); sb.append(" if (n.numSpecials() > 0)").append(LS); sb.append( " for (final Iterator<" + Globals.nodeTokenName + "> e = n.specialTokens.iterator(); e.hasNext();) {").append(LS); sb.append(" NodeToken special = e.next();").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Place the token").append(LS); sb.append(" // Move cursor to next line after the special token").append(LS); sb.append(" // Don't update curColumn - want to keep current indent level").append(LS); sb.append(" //").append(LS); sb.append(" placeToken(special, curLine, curColumn);").append(LS); sb.append(" curLine = special.endLine + 1;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" placeToken(n, curLine, curColumn);").append(LS); sb.append(" curLine = n.endLine;").append(LS); sb.append(" curColumn = n.endColumn;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Inserts token location (beginLine, beginColumn, endLine, endColumn)
") .append(LS); sb.append(" * information into the NodeToken.
").append(LS); sb.append(" * Takes into account line-wrap. Does not update curLine and curColumn.") .append(LS); sb.append(" *").append(LS); sb.append(" * @param n the NodeToken to insert").append(LS); sb.append(" * @param aLine the insertion line number").append(LS); sb.append(" * @param aColumn the insertion column number").append(LS); sb.append(" */").append(LS); sb.append( " private void placeToken(final " + Globals.nodeTokenName + " n, final int aLine, final int aColumn) {").append(LS); sb.append(" final int length = n.tokenImage.length();").append(LS); sb.append(" int line = aLine;").append(LS); sb.append(" int column = aColumn;").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Find beginning of token. Only line-wrap for single-line tokens").append(LS); sb.append(" //").append(LS); sb.append(" if (!lineWrap || n.tokenImage.indexOf('\\n') != -1 ||").append(LS); sb.append(" column + length <= wrapWidth)").append(LS); sb.append(" n.beginColumn = column;").append(LS); sb.append(" else {").append(LS); sb.append(" ++line;").append(LS); sb.append(" column = curIndent + indentAmt + 1;").append(LS); sb.append(" n.beginColumn = column;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" n.beginLine = line;").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Find end of token; don't count '\\n' if it's the last character").append(LS); sb.append(" //").append(LS); sb.append(" for (int i = 0; i < length; ++i) {").append(LS); sb.append(" if (n.tokenImage.charAt(i) == '\\n' && i < length - 1) {").append(LS); sb.append(" ++line;").append(LS); sb.append(" column = 1;").append(LS); sb.append(" }").append(LS); sb.append(" else").append(LS); sb.append(" ++column;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" n.endLine = line;").append(LS); sb.append(" n.endColumn = column;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // User-generated visitor methods below").append(LS); sb.append(" //").append(LS).append(LS); final Spacing spc = new Spacing(Globals.INDENT_AMT); spc.updateSpc(+1); for (final Iterator e = classList.iterator(); e.hasNext();) { final ClassInfo cur = e.next(); final String className = cur.getClassName(); if (Globals.javaDocComments) { sb.append(spc.spc).append("/**").append(LS); sb.append(cur.genAllFieldsComment(spc)); sb.append(spc.spc).append(" */").append(LS); sb.append(spc.spc).append("@Override").append(LS); } sb.append(spc.spc).append("public void visit"); sb.append("(final ").append(className).append(" n) {").append(LS); spc.updateSpc(+1); final Iterator names = cur.getFieldNames().iterator(); final Iterator types = cur.getFieldTypes().iterator(); while (names.hasNext() && types.hasNext()) { final String name = names.next(); final String type = types.next(); if (type.equals(Globals.nodeListName)) sb.append(spc.spc).append("processList(n.").append(name).append(");").append(LS); else if (type.equals(Globals.nodeListOptName)) { sb.append(spc.spc).append("if (n.").append(name).append(".present()) {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("processList(n.").append(name).append(");").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); } else if (type.equals(Globals.nodeOptName)) { sb.append(spc.spc).append("if (n.").append(name).append(".present()) {").append(LS); spc.updateSpc(+1); sb.append(spc.spc).append("n.").append(name).append(".accept(this);").append(LS); spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS); } else sb.append(spc.spc).append("n.").append(name).append(".accept(this);").append(LS); } spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS).append(LS); } spc.updateSpc(-1); sb.append(spc.spc).append("}").append(LS).append(LS); // // Print class FormatCommand // sb.append("/**").append(LS); sb.append(" * Stores a format command.").append(LS); sb.append(" */").append(LS); sb.append("class FormatCommand {").append(LS).append(LS); sb.append(" /** Line break format code */").append(LS); sb.append(" public static final int FORCE = 0;").append(LS); sb.append(" /** Indentation format code */").append(LS); sb.append(" public static final int INDENT = 1;").append(LS); sb.append(" /** Unindentation format code */").append(LS); sb.append(" public static final int OUTDENT = 2;").append(LS); sb.append(" /** Spacing format code */").append(LS); sb.append(" public static final int SPACE = 3;").append(LS).append(LS); sb.append(" /** The format command code */").append(LS); sb.append(" private int command;").append(LS); sb.append(" /** The format command repetition number */").append(LS); sb.append(" private int numCommands;").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor with class members.").append(LS); sb.append(" *").append(LS); sb.append(" * @param aCmd the command code").append(LS); sb.append(" * @param aNumCmd the command repetition number").append(LS); sb.append(" */").append(LS); sb.append(" FormatCommand(final int aCmd, final int aNumCmd) {").append(LS); sb.append(" this.command = aCmd;").append(LS); sb.append(" this.numCommands = aNumCmd;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * @return the command code").append(LS); sb.append(" */").append(LS); sb.append(" public int getCommand() { return command; }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * @return the command repetition number").append(LS); sb.append(" */").append(LS); sb.append(" public int getNumCommands() { return numCommands; }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Sets the command code.").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the command code").append(LS); sb.append(" */").append(LS); sb.append(" public void setCommand(final int i) { command = i; }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Sets the command repetition number.").append(LS); sb.append(" *").append(LS); sb.append(" * @param i the command repetition number").append(LS); sb.append(" */").append(LS); sb.append(" public void setNumCommands(final int i) { numCommands = i; }").append(LS) .append(LS); sb.append("}").append(LS).append(LS); // // Print class TreeFormatterException // sb.append("/**").append(LS); sb.append(" * The TreeFormatter exception class.").append(LS); sb.append(" */").append(LS); sb.append("class TreeFormatterException extends RuntimeException {").append(LS).append(LS); sb.append(" /** The serial version uid */").append(LS); sb.append(" private static final long serialVersionUID = 1L;").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor with no message.").append(LS); sb.append(" */").append(LS); sb.append(" TreeFormatterException() { super(); }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor with a given message.").append(LS); sb.append(" *").append(LS); sb.append(" * @param s the exception message").append(LS); sb.append(" */").append(LS); sb.append(" TreeFormatterException(final String s) { super(s); }").append(LS).append(LS); sb.append("}").append(LS); } } jtb-1.4.4/EDU/purdue/jtb/misc/FileExistsException.java0000644000175000017500000000615211360636750022366 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; /** * Class handling file exception. * * @author Marc Mazas, mmazas@sopragroup.com */ public class FileExistsException extends Exception { /** Default serialVersionUID */ private static final long serialVersionUID = 1L; /** * Constructor with no message. */ public FileExistsException() { super(); } /** * Constructor with a specific message. * * @param s a message */ public FileExistsException(final String s) { super(s); } } jtb-1.4.4/EDU/purdue/jtb/misc/TreeDumperGenerator.java0000644000175000017500000003245311360636750022356 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; /** * Class TreeDumperBuilder generates the TreeDumper visitor which simply prints all the tokens in * the tree at the locations given in their beginLine and beginColumn member variables.
* Similar to {@link FilesGenerator} class. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class TreeDumperGenerator { /** The visitor class name */ public static final String visitorName = "TreeDumper"; /** The visitor source file name */ public static final String outFilename = visitorName + ".java"; /** The visitors directory */ private final File visitorDir; /** The buffer to print into */ protected StringBuilder sb; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Constructor. Will create the visitors directory if it does not exist. */ public TreeDumperGenerator() { visitorDir = new File(Globals.visitorsDirName); sb = new StringBuilder(5 * 1024); if (!visitorDir.exists()) visitorDir.mkdir(); } /** * Saves the current buffer in the output file (global variable). * * @throws FileExistsException if the file exists and the noOverwrite flag is set */ public void saveToFile() throws FileExistsException { try { final File file = new File(visitorDir, outFilename); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFilename); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), sb.length())); out.print(sb); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } // TODO passer les méthodes suivantes en spc.spc /** * Generates the tree dumper visitor source in its file.
* * @throws FileExistsException if the file exists and the no overwrite flag has been set */ public void generateTreeDumper() throws FileExistsException { sb.append(Globals.genFileHeaderComment() + LS); sb.append("package " + Globals.visitorsPackageName + ";").append(LS).append(LS); sb.append("import " + Globals.nodesPackageName + ".*;").append(LS); sb.append("import java.io.OutputStream;").append(LS); sb.append("import java.io.PrintWriter;").append(LS); sb.append("import java.io.Writer;").append(LS); sb.append("import java.util.Iterator;").append(LS).append(LS); sb.append("/**").append(LS); sb.append(" * Dumps the syntax tree using the location information in each NodeToken.") .append(LS); sb.append(" */").append(LS); sb.append("public class TreeDumper extends " + Globals.dFVoidVisitorName + " {").append(LS) .append(LS); sb.append(" /** The PrintWriter to write to */").append(LS); sb.append(" protected PrintWriter out;").append(LS); sb.append(" /** The current line */").append(LS); sb.append(" private int curLine = 1;").append(LS); sb.append(" /** The current column */").append(LS); sb.append(" private int curColumn = 1;").append(LS); sb.append(" /** True to start dumping at the next token visited, false otherwise */") .append(LS); sb.append(" private boolean startAtNextToken = false;").append(LS); sb.append(" /** True to print specials (comments), false otherwise */").append(LS); sb.append(" private boolean printSpecials = true;").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor using System.out as its output location.").append(LS); sb.append(" */").append(LS); sb.append(" public TreeDumper() { out = new PrintWriter(System.out, true); }").append(LS) .append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor using the given Writer as its output location.").append(LS); sb.append(" *").append(LS); sb.append(" * @param o the output Writer to write to").append(LS); sb.append(" */").append(LS); sb.append(" public TreeDumper(final Writer o) { out = new PrintWriter(o, true); }") .append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Constructor using the given OutputStream as its output location.").append(LS); sb.append(" *").append(LS); sb.append(" * @param o the output OutputStream to write to").append(LS); sb.append(" */").append(LS); sb.append(" public TreeDumper(final OutputStream o) { out = new PrintWriter(o, true); }") .append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Flushes the OutputStream or Writer that this TreeDumper is using.").append(LS); sb.append(" */").append(LS); sb.append(" public void flushWriter() { out.flush(); }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Allows you to specify whether or not to print special tokens.").append(LS); sb.append(" *").append(LS); sb.append(" * @param b true to print specials, false otherwise").append(LS).append(LS); sb.append(" */").append(LS); sb.append(" public void printSpecials(final boolean b) { printSpecials = b; }").append(LS) .append(LS); sb.append(" /**").append(LS); sb.append(" * Starts the tree dumper on the line containing the next token").append(LS); sb.append(" * visited. For example, if the next token begins on line 50 and the").append(LS); sb.append(" * dumper is currently on line 1 of the file, it will set its current").append(LS); sb.append(" * line to 50 and continue printing from there, as opposed to").append(LS); sb.append(" * printing 49 blank lines and then printing the token.").append(LS); sb.append(" */").append(LS); sb.append(" public void startAtNextToken() { startAtNextToken = true; }").append(LS) .append(LS); sb.append(" /**").append(LS); sb.append(" * Resets the position of the output \"cursor\" to the first line and").append(LS); sb.append(" * column. When using a dumper on a syntax tree more than once, you").append(LS); sb.append(" * either need to call this method or startAtNextToken() between each").append(LS); sb.append(" * dump.").append(LS); sb.append(" */").append(LS); sb.append(" public void resetPosition() { curLine = curColumn = 1; }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Dumps the current NodeToken to the output stream being used.").append(LS); sb.append(" *").append(LS); sb.append(" * @throws IllegalStateException if the token position is invalid").append(LS); sb.append(" * relative to the current position, i.e. its location places it").append(LS); sb.append(" * before the previous token.").append(LS); sb.append(" */").append(LS); sb.append(" @Override").append(LS); sb.append(" public void visit(final " + Globals.nodeTokenName + " n) {").append(LS); sb.append(" if (n.beginLine == -1 || n.beginColumn == -1) {").append(LS); sb.append(" printToken(n.tokenImage);").append(LS); sb.append(" return;").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Handle special tokens").append(LS); sb.append(" //").append(LS); sb.append(" if (printSpecials && n.numSpecials() > 0)").append(LS); sb.append( " for (final Iterator<" + Globals.nodeTokenName + "> e = n.specialTokens.iterator(); e.hasNext();)").append(LS); sb.append(" visit(e.next());").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Handle startAtNextToken option").append(LS); sb.append(" //").append(LS); sb.append(" if (startAtNextToken) {").append(LS); sb.append(" curLine = n.beginLine;").append(LS); sb.append(" curColumn = 1;").append(LS); sb.append(" startAtNextToken = false;").append(LS).append(LS); sb.append(" if (n.beginColumn < curColumn)").append(LS); sb.append(" out.println();").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Check for invalid token position relative to current position.").append(LS); sb.append(" //").append(LS); sb.append(" if (n.beginLine < curLine)").append(LS); sb.append(" throw new IllegalStateException(\"at token \\\"\" + n.tokenImage +") .append(LS); sb.append(" \"\\\", n.beginLine = \" + Integer.toString(n.beginLine) +").append(LS); sb.append(" \", curLine = \" + Integer.toString(curLine));").append(LS); sb.append(" else if (n.beginLine == curLine && n.beginColumn < curColumn)").append(LS); sb.append(" throw new IllegalStateException(\"at token \\\"\" + n.tokenImage +") .append(LS); sb.append(" \"\\\", n.beginColumn = \" +").append(LS); sb.append(" Integer.toString(n.beginColumn) + \", curColumn = \" +").append(LS); sb.append(" Integer.toString(curColumn));").append(LS).append(LS); sb.append(" //").append(LS); sb.append(" // Move output \"cursor\" to proper location, then print the token").append(LS); sb.append(" //").append(LS); sb.append(" if (curLine < n.beginLine) {").append(LS); sb.append(" curColumn = 1;").append(LS); sb.append(" for (; curLine < n.beginLine; ++curLine)").append(LS); sb.append(" out.println();").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" for (; curColumn < n.beginColumn; ++curColumn)").append(LS); sb.append(" out.print(\" \");").append(LS).append(LS); sb.append(" printToken(n.tokenImage);").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" /**").append(LS); sb.append(" * Prints a given String, updating line and column numbers.").append(LS); sb.append(" *").append(LS); sb.append(" * @param s the String to print").append(LS); sb.append(" */").append(LS); sb.append(" private void printToken(final String s) {").append(LS); sb.append(" for (int i = 0; i < s.length(); ++i) { ").append(LS); sb.append(" if (s.charAt(i) == '\\n') {").append(LS); sb.append(" ++curLine;").append(LS); sb.append(" curColumn = 1;").append(LS); sb.append(" }").append(LS); sb.append(" else").append(LS); sb.append(" curColumn++;").append(LS).append(LS); sb.append(" out.print(s.charAt(i));").append(LS); sb.append(" }").append(LS).append(LS); sb.append(" out.flush();").append(LS); sb.append(" }").append(LS).append(LS); sb.append("}").append(LS); } } jtb-1.4.4/EDU/purdue/jtb/misc/FilesGenerator.java0000644000175000017500000006161111360636750021342 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may * be made for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.misc; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; /** * Class FilesGenerator contains methods to generate the grammar (user) nodes java files, the base * nodes java files, the visitor interfaces and the default visitors classes files.
* It must be constructed with the list of the grammar {@link ClassInfo} classes. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5
* 1.4.0 : 11/09 : MMa : fixed directories creation errors */ public class FilesGenerator { /** The classes list */ private final ArrayList classes; /** The (generated) nodes directory */ private final File nodesDir; /** The (generated) visitors directory */ private final File visitorsDir; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Constructor. Creates the nodes and visitors directories if they do not exist. * * @param classesList the list of {@link ClassInfo} classes instances */ public FilesGenerator(final ArrayList classesList) { classes = classesList; nodesDir = new File(Globals.nodesDirName); visitorsDir = new File(Globals.visitorsDirName); if (!nodesDir.exists()) if (nodesDir.mkdirs()) Messages.info("\"" + Globals.nodesDirName + "\" directory created."); else Messages.softErr("Unable to create \"" + Globals.nodesDirName + "\" directory."); else if (!nodesDir.isDirectory()) Messages.softErr("\"" + Globals.nodesDirName + "\" exists but is not a directory."); if (!visitorsDir.exists()) if (visitorsDir.mkdirs()) Messages.info("\"" + Globals.visitorsDirName + "\" directory created."); else Messages.softErr("Unable to create \"" + Globals.visitorsDirName + "\" directory."); else if (!visitorsDir.isDirectory()) Messages.softErr("\"" + Globals.visitorsDirName + "\" exists but is not a directory."); } /** * Outputs the formatted nodes classes list. * * @param out a PrintWriter to output on */ public void outputFormattedNodesClassesList(final PrintWriter out) { final StringBuilder sb = null; out.print(formatNodesClassesList(sb)); out.flush(); } /** * Formats the nodes classes list. * * @param aSB a StringBuilder, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the formatted nodes classes list */ public StringBuilder formatNodesClassesList(final StringBuilder aSB) { final Spacing spc = new Spacing(Globals.INDENT_AMT); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(classes.size() * 100); for (final Iterator e = classes.iterator(); e.hasNext();) { final ClassInfo classInfo = e.next(); final String className = classInfo.getClassName(); sb.append("class ").append(className).append(":").append(LS); spc.updateSpc(+1); final Iterator types = classInfo.getFieldTypes().iterator(); final Iterator names = classInfo.getFieldNames().iterator(); for (; types.hasNext();) sb.append(spc.spc).append(types.next()).append(" ").append(names.next()).append(LS); sb.append(LS); spc.updateSpc(-1); } return sb; } /** * Generates nodes (classes source) files. * * @throws FileExistsException if one or more files exist and no overwrite flag has been set */ public void genNodesFiles() throws FileExistsException { try { boolean exists = false; for (final Iterator e = classes.iterator(); e.hasNext();) { final ClassInfo classInfo = e.next(); final File file = new File(nodesDir, classInfo.getClassName() + ".java"); if (Globals.noOverwrite && file.exists()) { Messages.softErr(classInfo.getClassName() + " exists but no overwrite flag has been set"); exists = true; break; } final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 2048)); out.print(genNodeClass(null, classInfo)); out.close(); } if (Globals.noOverwrite && exists) throw new FileExistsException("Some of the generated nodes classes files exist"); } catch (final IOException e) { Messages.hardErr(e); } } /** * Generates a node class source string. * * @param aSB a StringBuilder, used if not null * @param aClassInfo the class to generate the source string * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the node class source */ public StringBuilder genNodeClass(final StringBuilder aSB, final ClassInfo aClassInfo) { final Spacing spc = new Spacing(Globals.INDENT_AMT); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(2048); sb.append(Globals.genFileHeaderComment()).append(LS); sb.append("package ").append(Globals.nodesPackageName).append(";").append(LS).append(LS); sb.append("import ").append(Globals.visitorsPackageName).append(".*;").append(LS).append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * JTB node class for the production ").append(aClassInfo.getClassName()) .append(":
").append(LS); sb.append(" * Corresponding grammar :
").append(LS); sb.append(aClassInfo.genAllFieldsComment(spc)); sb.append(" */").append(LS); } sb.append(aClassInfo.genClassString(spc)); return sb; } /** * Generates the base nodes source files. * * @throws FileExistsException if one or more files exist and no overwrite flag has been set */ public void genBaseNodesFiles() throws FileExistsException { try { boolean b = true; b = b && fillFile(Globals.iNodeName + ".java", BaseClasses.genINodeInterface(null)); b = b && fillFile(Globals.iNodeListName + ".java", BaseClasses.genINodeListInterface(null)); b = b && fillFile(Globals.nodeChoiceName + ".java", BaseClasses.genNodeChoiceClass(null)); b = b && fillFile(Globals.nodeListName + ".java", BaseClasses.genNodeListClass(null)); b = b && fillFile(Globals.nodeListOptName + ".java", BaseClasses.genNodeListOptClass(null)); b = b && fillFile(Globals.nodeOptName + ".java", BaseClasses.genNodeOptClass(null)); b = b && fillFile(Globals.nodeSeqName + ".java", BaseClasses.genNodeSeqClass(null)); b = b && fillFile(Globals.nodeTokenName + ".java", BaseClasses.genNodeTokenClass(null)); if (Globals.noOverwrite && !b) throw new FileExistsException("Some of the base nodes classes files exist"); } catch (final IOException e) { Messages.hardErr(e); } } /** * Fills a class file given its class source. It adds the file header comment * ("Generated by JTB version"). * * @param fileName the class file name * @param classSource the class source * @throws IOException if any IO Exception * @return false if the file exists and the no overwrite flag is set, true otherwise */ public boolean fillFile(final String fileName, final StringBuilder classSource) throws IOException { final File file = new File(Globals.nodesDirName, fileName); if (Globals.noOverwrite && file.exists()) return false; final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 2048)); out.println(Globals.genFileHeaderComment()); out.print(classSource); out.close(); return true; } /** * Generates the "RetArgu" IVisitor interface source (with return type and a user object * argument). * * @param aSB a StringBuilder, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the visitor class source */ public StringBuilder genRetArguIVisitor(final StringBuilder aSB) { final String intf = Globals.iRetArguVisitorName.concat(genClassParamType(true, true)); final String consBeg = genClassBegArgList(true); final String consEnd = genClassEndArgList(true); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1500); genAnyIVisitorBeg(sb, Globals.retArguVisitorComment, intf, true, true); genBaseRetArguVisitMethods(sb); genAnyIVisitorEnd(sb, consBeg, consEnd, true, true); return sb; } /** * Generates the "Ret" IVisitor interface source (with return type and no user object argument). * * @param aSB a StringBuilder, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the visitor class source */ public StringBuilder genRetIVisitor(final StringBuilder aSB) { final String intf = Globals.iRetVisitorName.concat(genClassParamType(true, false)); final String consBeg = genClassBegArgList(true); final String consEnd = genClassEndArgList(false); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1500); genAnyIVisitorBeg(sb, Globals.retVisitorComment, intf, true, false); genBaseRetVisitMethods(sb); genAnyIVisitorEnd(sb, consBeg, consEnd, true, false); return sb; } /** * Generates the "VoidArgu" IVisitor interface source (with no return type and a user object * argument). * * @param aSB a StringBuilder, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the visitor class source */ public StringBuilder genVoidArguIVisitor(final StringBuilder aSB) { final String intf = Globals.iVoidArguVisitorName.concat(genClassParamType(false, true)); final String consBeg = genClassBegArgList(false); final String consEnd = genClassEndArgList(true); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1500); genAnyIVisitorBeg(sb, Globals.voidArguVisitorComment, intf, false, true); genBaseVoidArguVisitMethods(sb); genAnyIVisitorEnd(sb, consBeg, consEnd, false, true); return sb; } /** * Generates the "Void" IVisitor interface source (with no return type and no user object * argument). * * @param aSB a StringBuilder, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the visitor class source */ public StringBuilder genVoidIVisitor(final StringBuilder aSB) { final String intf = Globals.iVoidVisitorName.concat(genClassParamType(false, false)); final String consBeg = genClassBegArgList(false); final String consEnd = genClassEndArgList(false); StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1500); genAnyIVisitorBeg(sb, Globals.voidVisitorComment, intf, false, false); genBaseVoidVisitMethods(sb); genAnyIVisitorEnd(sb, consBeg, consEnd, false, false); return sb; } /** * Generates the start for all visitor interfaces. * * @param aSB the buffer to output into (must be non null) * @param aComment the target visitors names to insert in the interface comment * @param aIntf the interface name * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise */ void genAnyIVisitorBeg(final StringBuilder aSB, final String aComment, final String aIntf, final boolean aRet, final boolean aArgu) { aSB.append(Globals.genFileHeaderComment()).append(LS); aSB.append("package ").append(Globals.visitorsPackageName).append(";").append(LS).append(LS); if (!Globals.visitorsPackageName.equals(Globals.nodesPackageName)) aSB.append("import ").append(Globals.nodesPackageName).append(".*;").append(LS).append(LS); if (Globals.javaDocComments) { aSB.append("/**").append(LS); aSB.append(" * All \"").append(aComment).append("\" visitors must implement this interface.") .append(LS); if (aRet) aSB.append(" * @param The user return information type").append(LS); if (aArgu) aSB.append(" * @param
The user argument type").append(LS); aSB.append(" */").append(LS); } aSB.append("public interface ").append(aIntf).append(" {").append(LS); } /** * Generates the end for all visitor interfaces. * * @param aSB the buffer to output into (must be non null) * @param aConsBeg the beginning of the visit methods * @param aConsEnd the end of the visit methods * @param aRet true if there is a user return parameter type, false otherwise * @param aArgu true if there is a user argument parameter type, false otherwise */ void genAnyIVisitorEnd(final StringBuilder aSB, final String aConsBeg, final String aConsEnd, final boolean aRet, final boolean aArgu) { final Spacing spc = new Spacing(Globals.INDENT_AMT); spc.updateSpc(+1); if (Globals.javaDocComments) { aSB.append(spc.spc).append("/*").append(LS); aSB.append(spc.spc).append(" * User grammar generated visit methods").append(LS); aSB.append(spc.spc).append(" */").append(LS).append(LS); } for (final Iterator e = classes.iterator(); e.hasNext();) { final ClassInfo classInfo = e.next(); final String className = classInfo.getClassName(); if (Globals.javaDocComments) { aSB.append(spc.spc).append("/**").append(LS); aSB.append(spc.spc).append(" * Visits a {@link ").append(className) .append("} node, whose children are the following :").append(LS); aSB.append(spc.spc).append(" *

").append(LS); aSB.append(classInfo.genAllFieldsComment(spc)); aSB.append(spc.spc).append(" *").append(LS); aSB.append(spc.spc).append(" * @param n the node to visit").append(LS); if (aArgu) aSB.append(spc.spc).append(" * @param argu the user argument").append(LS); if (aRet) aSB.append(spc.spc).append(" * @return the user return information").append(LS); aSB.append(spc.spc).append(" */").append(LS); } aSB.append(spc.spc).append("public ").append(aConsBeg).append(className).append(aConsEnd) .append(";").append(LS).append(LS); } spc.updateSpc(-1); aSB.append("}").append(LS); } /** * Generates the "RetArgu" IVisitor (interface source) file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genRetArguIVisitorFile() throws FileExistsException { try { final File file = new File(visitorsDir, Globals.iRetArguVisitorName + ".java"); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(Globals.iRetArguVisitorName + ".java"); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 1500)); out.print(genRetArguIVisitor(null)); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } /** * Generates the "Ret" IVisitor (interface source) file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genRetIVisitorFile() throws FileExistsException { try { final File file = new File(visitorsDir, Globals.iRetVisitorName + ".java"); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(Globals.iRetVisitorName + ".java"); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 1500)); out.print(genRetIVisitor(null)); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } /** * Generates the "VoidArgu" IVisitor (interface source) file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genVoidArguIVisitorFile() throws FileExistsException { try { final File file = new File(visitorsDir, Globals.iVoidArguVisitorName + ".java"); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(Globals.iVoidArguVisitorName + ".java"); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 1500)); out.print(genVoidArguIVisitor(null)); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } /** * Generates the "Void" IVisitor (interface source) file. * * @throws FileExistsException if the file already exists and the no overwrite flag has been set */ public void genVoidIVisitorFile() throws FileExistsException { try { final File file = new File(visitorsDir, Globals.iVoidVisitorName + ".java"); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(Globals.iVoidVisitorName + ".java"); final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), 1500)); out.print(genVoidIVisitor(null)); out.close(); } catch (final IOException e) { Messages.hardErr(e); } } /** * Generates the base "RetArgu" visit methods. * * @param aSB a buffer, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the base visitor methods source */ StringBuilder genBaseRetArguVisitMethods(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(100); sb.append(LS); if (Globals.javaDocComments) { sb.append(" /*").append(LS); sb.append(" * Base \"RetArgu\" visit methods").append(LS); sb.append(" */").append(LS).append(LS); } BaseClasses.genRetArguVisitNodeList(sb); sb.append(LS); BaseClasses.genRetArguVisitNodeListOpt(sb); sb.append(LS); BaseClasses.genRetArguVisitNodeOpt(sb); sb.append(LS); BaseClasses.genRetArguVisitNodeSeq(sb); sb.append(LS); BaseClasses.genRetArguVisitNodeToken(sb); sb.append(LS); return sb; } /** * Generates the base "Ret" visit methods. * * @param aSB a buffer, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the base visitor methods source */ StringBuilder genBaseRetVisitMethods(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(100); sb.append(LS); if (Globals.javaDocComments) { sb.append(" /*").append(LS); sb.append(" * Base \"Ret\" visit methods").append(LS); sb.append(" */").append(LS).append(LS); } BaseClasses.genRetVisitNodeList(sb); sb.append(LS); BaseClasses.genRetVisitNodeListOpt(sb); sb.append(LS); BaseClasses.genRetVisitNodeOpt(sb); sb.append(LS); BaseClasses.genRetVisitNodeSeq(sb); sb.append(LS); BaseClasses.genRetVisitNodeToken(sb); sb.append(LS); return sb; } /** * Generates the base "VoidArgu" visit methods. * * @param aSB a buffer, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the base visitor methods source */ StringBuilder genBaseVoidArguVisitMethods(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(100); sb.append(LS); if (Globals.javaDocComments) { sb.append(" /*").append(LS); sb.append(" * Base \"VoidArgu\" visit methods").append(LS); sb.append(" */").append(LS).append(LS); } BaseClasses.genVoidArguVisitNodeList(sb); sb.append(LS); BaseClasses.genVoidArguVisitNodeListOpt(sb); sb.append(LS); BaseClasses.genVoidArguVisitNodeOpt(sb); sb.append(LS); sb.append(LS); BaseClasses.genVoidArguVisitNodeSeq(sb); sb.append(LS); BaseClasses.genVoidArguVisitNodeToken(sb); sb.append(LS); return sb; } /** * Generates the base "Void" visit methods. * * @param aSB a buffer, used if not null * @return StringBuilder the given one if not null, or a new allocated one if null, completed with * the base visitor methods source */ StringBuilder genBaseVoidVisitMethods(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(100); sb.append(LS); if (Globals.javaDocComments) { sb.append(" /*").append(LS); sb.append(" * Base \"Void\" visit methods").append(LS); sb.append(" */").append(LS).append(LS); } BaseClasses.genVoidVisitNodeList(sb); sb.append(LS); BaseClasses.genVoidVisitNodeListOpt(sb); sb.append(LS); BaseClasses.genVoidVisitNodeOpt(sb); sb.append(LS); BaseClasses.genVoidVisitNodeSeq(sb); sb.append(LS); BaseClasses.genVoidVisitNodeToken(sb); sb.append(LS); return sb; } /** * Generates the class parameter types. * * @param ret true if there is a user return parameter type, false otherwise * @param arg true if there is a user argument parameter type, false otherwise * @return the class parameter types string */ static String genClassParamType(final boolean ret, final boolean arg) { if (ret) { if (arg) { return "<" + Globals.genRetType + ", " + Globals.genArguType + ">"; } else { return "<" + Globals.genRetType + ">"; } } else { if (arg) { return "<" + Globals.genArguType + ">"; } else { return ""; } } } /** * Generates the beginning of the visit methods. * * @param arg true if there is a user argument parameter type, false otherwise * @return the beginning of the visit methods */ static String genClassBegArgList(final boolean arg) { if (arg) { return Globals.genRetType + " visit(final "; } else { return "void visit(final "; } } /** * Generates the end of the visit methods. * * @param arg true if there is a user argument parameter type, false otherwise * @return the end of the visit methods */ static String genClassEndArgList(final boolean arg) { if (arg) { return " n, final " + Globals.genArguType + " argu)"; } else { return " n)"; } } }jtb-1.4.4/EDU/purdue/jtb/misc/BaseClasses.java0000644000175000017500000022340611360636750020623 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLO Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLO nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OV IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * O PARTICULAV PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNEV OV CONTRIBUTORS BE LIABLE FOV ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OV CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OV SERVICES; LOSS OF USE, * DATA, OV PROFITS; OV BUSINESS INTERRUPTION) HOWEVEV CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHEV IN CONTRACT, STRICT LIABILITY, OV TORT * (INCLUDING NEGLIGENCE OV OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may * be made for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOV ANY PARTICULAV PURPOSE. */ package EDU.purdue.jtb.misc; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.INodeList; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeList; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; /** * Class BaseClasses contains static methods to generated string representations of the base classes * (nodes and visitors).
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ class BaseClasses { /** Return and Argument parameter types */ final static String parRetArgu = genClassParamType(true, true); /** Beginning of argument list for Return and Argument parameter types */ final static String begRetArgu = begArgList(true); /** End of argument list for Return and Argument parameter types */ final static String endRetArgu = endArgList(true); /** Return and no Argument parameter type */ final static String parRet = genClassParamType(true, false); /** Beginning of argument list for Return and no Argument parameter types */ final static String begRet = begArgList(true); /** End of argument list for Return and no Argument parameter types */ final static String endRet = endArgList(false); /** No Return and Argument parameter types */ final static String parVoidArgu = genClassParamType(false, true); /** Beginning of argument list for no Return and Argument parameter types */ final static String begVoidArgu = begArgList(false); /** End of argument list for no Return and Argument parameter types */ final static String endVoidArgu = endArgList(true); /** No Return and no Argument parameter types */ final static String parVoid = genClassParamType(false, false); /** Beginning of argument list for no Return and no Argument parameter types */ final static String begVoid = begArgList(false); /** End of argument list for no Return and no Argument parameter types */ final static String endVoid = endArgList(false); /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /* * Node interfaces methods */ /** * Generates the {@link INode} interface. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated interface */ static StringBuilder genINodeInterface(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1900); packageAndImports(sb); sb.append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * The interface which all syntax tree classes must implement.").append(LS); sb.append(" */").append(LS); } sb.append("public interface ").append(Globals.iNodeName) .append(" extends java.io.Serializable {").append(LS).append(LS); interfacesAcceptMethods(sb); if (Globals.parentPointer) { if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Gets the parent node.").append(LS); sb.append(" *").append(LS); sb.append(" * @return the parent node").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.iNodeName).append(" getParent();").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb .append(" * Sets the parent node. (It is the responsibility of each implementing class") .append(LS); sb.append(" * to call setParent() on each of its child nodes.)").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the parent node").append(LS); sb.append(" */").append(LS); } sb.append(" public void setParent(final ").append(Globals.iNodeName).append(" n);") .append(LS); } sb.append("}").append(LS); return sb; } /** * Generates the {@link INodeList} interface. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated interface */ static StringBuilder genINodeListInterface(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(1850); packageAndImports(sb); sb.append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * The interface which {@link ").append(Globals.nodeListName).append("}, {@link ") .append(Globals.nodeListOptName).append("} and {@link ").append(Globals.nodeSeqName) .append("} must implement.").append(LS); sb.append(" */").append(LS); } sb.append("public interface ").append(Globals.iNodeListName).append(" extends ") .append(Globals.iNodeName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a node to the list.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addNode(final ").append(Globals.iNodeName).append(" n);").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @param i the element index").append(LS); sb.append(" * @return the element at the given index").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.iNodeName).append(" elementAt(int i);").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return the iterator on the node list").append(LS); sb.append(" */").append(LS); } sb.append(" public java.util.Iterator<").append(Globals.iNodeName).append("> elements();") .append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return the list size").append(LS); sb.append(" */").append(LS); } sb.append(" public int size();").append(LS).append(LS); interfacesAcceptMethods(sb); sb.append("}").append(LS); return sb; } /* * Node classes methods */ /** * Generates the {@link NodeChoice} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeChoiceClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(2700); packageAndImports(sb); sb.append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * Represents a grammar choice (|), e.g. ' ( A | B ) '.
").append(LS); sb.append(" * The class stores the node and the \"which\" choice indicator (0, 1, ...).") .append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeChoiceName).append(extendsClause()) .append(" implements ").append(Globals.iNodeName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The real node */").append(LS); sb.append(" public ").append(Globals.iNodeName).append(" choice;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The \"which\" choice indicator */").append(LS); sb.append(" public int which;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The total number of choices */").append(LS); sb.append(" public int total;").append(LS).append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Constructs the {@link NodeChoice} with a given node and non standard (-1) ") .append("which choice and total number of choices.").append(LS); sb.append(" *").append(LS); sb.append(" * @param node the node").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeChoiceName).append("(final ") .append(Globals.iNodeName).append(" node) {").append(LS); sb.append(" this(node, -1, -1);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Constructs the {@link NodeChoice} with a given node, a which choice and ") .append("a total (not controlled).").append(LS); sb.append(" *").append(LS); sb.append(" * @param node the node").append(LS); sb.append(" * @param whichChoice the which choice").append(LS); sb.append(" * @param totalChoices the total number of choices").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeChoiceName).append("(final ") .append(Globals.iNodeName).append(" node, final int whichChoice, final int totalChoices) {") .append(LS); sb.append(" choice = node;").append(LS); sb.append(" which = whichChoice;").append(LS); sb.append(" total = totalChoices;").append(LS); sb.append((Globals.parentPointer ? " choice.setParent(this);" : "")); sb.append((Globals.parentPointer ? LS : "")); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptRetArguComment(sb); sb.append(" public ").append(parRetArgu).append(" ").append(begRetArgu) .append(Globals.iRetArguVisitorName).append(parRetArgu).append(endRetArgu).append(" {") .append(LS); sb.append(" return choice.accept(vis, argu);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptRetComment(sb); sb.append(" public ").append(parRet).append(" ").append(begRet) .append(Globals.iRetVisitorName).append(parRet).append(endRet).append(" {").append(LS); sb.append(" return choice.accept(vis);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptVoidArguComment(sb); sb.append(" public ").append(parVoidArgu).append(" ").append(begVoidArgu) .append(Globals.iVoidArguVisitorName).append(parVoidArgu).append(endVoidArgu).append(" {") .append(LS); sb.append(" choice.accept(vis, argu);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptVoidComment(sb); sb.append(" public ").append(parVoid).append(begVoid).append(Globals.iVoidVisitorName) .append(parVoid).append(endVoid).append(" {").append(LS); sb.append(" choice.accept(vis);").append(LS); sb.append(" }").append(LS).append(LS); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /** * Generates the {@link NodeList} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeListClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(4050); packageAndImports(sb); sb.append("import java.util.*;").append(LS).append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * Represents a grammar list (+), e.g. ' ( A )+ '.
").append(LS); sb.append(" * The class stores the nodes list in an ArrayList.").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeListName).append(extendsClause()) .append(" implements ").append(Globals.iNodeListName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The list of nodes */").append(LS); sb.append(" public ArrayList<").append(Globals.iNodeName).append("> nodes;").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /** The allocation sizes table */").append(LS); } sb.append(" private static final int allocTb[] = {1, 2, 3, 4, 5, 10, 20, 50};").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /** The allocation number */").append(LS); } sb.append(" private int allocNb = 0;").append(LS).append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a default first allocation.") .append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListName).append("() {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName) .append(">(allocTb[allocNb]);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a given allocation.").append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListName).append("(final int sz) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a default first allocation ") .append("and adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListName).append("(final ").append(Globals.iNodeName) .append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName) .append(">(allocTb[allocNb]);").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a given allocation and ") .append("adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListName).append("(final int sz, final ") .append(Globals.iNodeName).append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a node to the list of nodes, managing progressive ") .append("allocation increments.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addNode(final ").append(Globals.iNodeName).append(" n) {").append(LS); sb.append(" if (++allocNb < allocTb.length)").append(LS); sb.append(" nodes.ensureCapacity(allocTb[allocNb]);").append(LS); sb.append(" else").append(LS); sb.append(" nodes.ensureCapacity((allocNb - allocTb.length + 2) * ") .append("allocTb[(allocTb.length - 1)]);").append(LS); sb.append(" nodes.add(n);").append(LS); parentPointerSetCall(sb); sb.append(" }").append(LS).append(LS); listMethods(sb); classesAcceptMethods(sb); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /** * Generates the {@link NodeListOptional} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeListOptClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(4250); packageAndImports(sb); sb.append("import java.util.*;").append(LS).append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * Represents an optional grammar list (*), e.g. ' ( A )* '.
").append(LS); sb.append(" * The class stores the nodes list in an ArrayList.").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeListOptName).append(extendsClause()) .append(" implements ").append(Globals.iNodeListName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The list of nodes */").append(LS); sb.append(" public ArrayList<").append(Globals.iNodeName).append("> nodes;").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /** The allocation sizes table */").append(LS); } sb.append(" private static final int allocTb[] = {0, 1, 2, 3, 4, 5, 10, 20, 50};").append(LS) .append(LS); if (Globals.javaDocComments) { sb.append(" /** The allocation number */").append(LS); } sb.append(" private int allocNb = 0;").append(LS).append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a default first allocation.") .append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListOptName).append("() {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName) .append(">(allocTb[allocNb]);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a given allocation.").append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListOptName).append("(final int sz) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a default first allocation and ") .append("adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListOptName).append("(final ") .append(Globals.iNodeName).append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName) .append(">(allocTb[allocNb]);").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty list of nodes with a given allocation and ") .append("adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeListOptName).append("(final int sz, final ") .append(Globals.iNodeName).append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a node to the list of nodes, managing progressive ") .append("allocation increments.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addNode(final ").append(Globals.iNodeName).append(" n) {").append(LS); sb.append(" if (++allocNb < allocTb.length)").append(LS); sb.append(" nodes.ensureCapacity(allocTb[allocNb]);").append(LS); sb.append(" else").append(LS); sb.append(" nodes.ensureCapacity((allocNb - allocTb.length + 2) * ") .append("allocTb[(allocTb.length - 1)]);").append(LS); sb.append(" nodes.add(n);").append(LS); parentPointerSetCall(sb); sb.append(" }").append(LS).append(LS); listMethods(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return true if there is at least one node, false otherwise").append(LS); sb.append(" */").append(LS); } sb.append(" public boolean present() {").append(LS); sb.append(" return (nodes.size() != 0); }").append(LS).append(LS); classesAcceptMethods(sb); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /** * Generates the {@link NodeOptional} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeOptClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(2700); packageAndImports(sb); sb.append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb .append( " * Represents a grammar optional node (? or []), e.g. ' ( A )? ' or ' [ A ] '.
") .append(LS); sb.append(" * The class stores the node.").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeOptName).append(extendsClause()) .append(" implements ").append(Globals.iNodeName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The node (if null there is no node) */").append(LS); sb.append(" public ").append(Globals.iNodeName).append(" node;").append(LS).append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty {@link NodeOptional}.").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeOptName).append("() {").append(LS); sb.append(" node = null;").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes a {@link NodeOptional} with a node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeOptName).append("(final ").append(Globals.iNodeName) .append(" n) {").append(LS); sb.append(" addNode(n);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a node to the {@link NodeOptional}.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addNode(final ").append(Globals.iNodeName).append(" n) {").append(LS); sb.append(" if (node != null)").append(LS) .append(" throw new Error(\"Attempt to set optional node twice\");").append(LS); sb.append(" node = n;").append(LS); parentPointerSetCall(sb); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return true if the node exists, false otherwise").append(LS); sb.append(" */").append(LS); } sb.append(" public boolean present() {").append(LS); sb.append(" return (node != null); }").append(LS).append(LS); classesAcceptMethods(sb); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /** * Generates the {@link NodeSequence} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeSeqClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(3800); packageAndImports(sb); sb.append(LS); sb.append("import java.util.*;").append(LS).append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * Represents a sequence of nodes (x y z ...) nested ") .append("within a choice (|), list (+),").append(LS) .append(" * optional list (*), or optional node (? or []), e.g. ' ( A B )+ ' ") .append("or ' [ C D E ] '.
").append(LS); sb.append(" * The class stores the nodes list in an ArrayList.").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeSeqName).append(extendsClause()) .append(" implements ").append(Globals.iNodeListName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The list of nodes */").append(LS); sb.append(" public ArrayList<").append(Globals.iNodeName).append("> nodes;").append(LS) .append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty {@link NodeSequence} with a default allocation.") .append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeSeqName).append("() {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">();").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty {@link NodeSequence} with a given allocation.") .append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeSeqName).append("(final int sz) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty {@link NodeSequence} with a default allocation ") .append("and adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeSeqName).append("(final ").append(Globals.iNodeName) .append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">();").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes an empty {@link NodeSequence} with a given allocation ") .append("and adds a first node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param sz the list size").append(LS); sb.append(" * @param firstNode the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeSeqName).append("(final int sz, final ") .append(Globals.iNodeName).append(" firstNode) {").append(LS); sb.append(" nodes = new ArrayList<").append(Globals.iNodeName).append(">(sz);").append(LS); sb.append(" addNode(firstNode);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a node to the {@link NodeSequence}.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addNode(final ").append(Globals.iNodeName).append(" n) {").append(LS); sb.append(" nodes.add(n);").append(LS); parentPointerSetCall(sb); sb.append(" }").append(LS).append(LS); listMethods(sb); classesAcceptMethods(sb); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /** * Generates the {@link NodeToken} class. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated class */ static StringBuilder genNodeTokenClass(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(5970); packageAndImports(sb); sb.append(LS); sb.append("import java.util.*;").append(LS); if (Globals.javaDocComments) { sb.append("/**").append(LS); sb.append(" * Represents a single token in the grammar.
").append(LS); sb.append(" * If the \"-tk\" option is used, also contains a ArrayList of preceding ") .append("special tokens.
").append(LS); sb.append(" * The class stores the token image, kind and position information, ") .append("and the special tokens list.
").append(LS); sb.append(" */").append(LS); } sb.append("public class ").append(Globals.nodeTokenName).append( extendsClause() + " implements ") .append(Globals.iNodeName).append(" {").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The token image */").append(LS); sb.append(" public String tokenImage;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The list of special tokens */").append(LS); sb.append(" public ArrayList<").append(Globals.nodeTokenName).append("> specialTokens;") .append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The token first line (-1 means not available) */").append(LS); sb.append(" public int beginLine;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The token first column (-1 means not available) */").append(LS); sb.append(" public int beginColumn;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The token last line (-1 means not available) */").append(LS); sb.append(" public int endLine;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The token last column (-1 means not available) */").append(LS); sb.append(" public int endColumn;").append(LS).append(LS); if (Globals.javaDocComments) sb.append(" /** The JavaCC token \"kind\" integer (-1 means not available) */").append(LS); sb.append(" public int kind;").append(LS).append(LS); parentPointerDeclaration(sb); serialUIDDeclaration(sb); lineSeparatorDeclaration(sb); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes a {@link NodeToken} with a given string and ") .append("no position information.").append(LS); sb.append(" *").append(LS); sb.append(" * @param s the token string").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeTokenName).append("(String s) {").append(LS); sb.append(" this(s, -1, -1, -1, -1, -1);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Initializes a {@link NodeToken} with a given string and ") .append("position information.").append(LS); sb.append(" *").append(LS); sb.append(" * @param s the token string").append(LS); sb.append(" * @param kn the token kind").append(LS); sb.append(" * @param bl the first line").append(LS); sb.append(" * @param bc the first column").append(LS); sb.append(" * @param el the last line").append(LS); sb.append(" * @param ec the last column").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeTokenName) .append("(String s, final int kn, final int bl, final int bc, ") .append("final int el, final int ec) {").append(LS); sb.append(" tokenImage = s;").append(LS); sb.append(" specialTokens = null;").append(LS); sb.append(" kind = kn;").append(LS); sb.append(" beginLine = bl;").append(LS); sb.append(" beginColumn = bc;").append(LS); sb.append(" endLine = el;").append(LS); sb.append(" endColumn = ec;").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Gets the special token in the special tokens list at a given position.") .append(LS); sb.append(" *").append(LS); sb.append(" * @param i the special token's position").append(LS); sb.append(" * @return the special token").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.nodeTokenName).append(" getSpecialAt(final int i) {") .append(LS); sb.append(" if (specialTokens == null)").append(LS); sb.append(" throw new NoSuchElementException(\"No specialTokens in token\");").append(LS); sb.append(" return specialTokens.get(i);").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return the number of special tokens").append(LS); sb.append(" */").append(LS); } sb.append(" public int numSpecials() {").append(LS).append(" if (specialTokens == null)") .append(LS); sb.append(" return 0;").append(LS).append(" return specialTokens.size();").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Adds a special token to the special tokens list.").append(LS); sb.append(" *").append(LS); sb.append(" * @param s the special token to add").append(LS); sb.append(" */").append(LS); } sb.append(" public void addSpecial(final ").append(Globals.nodeTokenName).append(" s) {") .append(LS); sb.append(" if (specialTokens == null)").append(LS); sb.append(" specialTokens = new ArrayList<").append(Globals.nodeTokenName).append(">();") .append(LS); sb.append(" specialTokens.add(s);").append(LS); sb.append((Globals.parentPointer ? " s.setParent(this);" : "")); sb.append((Globals.parentPointer ? LS : "")); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Trims the special tokens list.").append(LS); sb.append(" */").append(LS); } sb.append(" public void trimSpecials() {").append(LS); sb.append(" if (specialTokens == null)").append(LS); sb.append(" return;").append(LS); sb.append(" specialTokens.trimToSize();").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * @return the token image").append(LS); sb.append(" */").append(LS); } sb.append(" @Override").append(LS); sb.append(" public String toString() {").append(LS); sb.append(" return tokenImage;").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Returns the list of special tokens of the current {@link NodeToken} ") .append("as a string,
").append(LS); sb.append(" * taking in account a given indentation.").append(LS); sb.append(" *").append(LS); sb.append(" * @param spc the indentation").append(LS); sb.append(" * @return the string representing the special tokens list").append(LS); sb.append(" */").append(LS); } sb.append(" public String getSpecials(final String spc) {").append(LS); sb.append(" if (specialTokens == null)").append(LS); sb.append(" return \"\";").append(LS); sb.append(" StringBuilder buf = new StringBuilder(64);").append(LS); sb.append(" for (final Iterator<").append(Globals.nodeTokenName) .append("> e = specialTokens.iterator(); e.hasNext();) {").append(LS); sb.append(" final String s = e.next().tokenImage;").append(LS); sb.append(" final int p = s.length() - 1;").append(LS); sb.append(" final char c = s.charAt(p);").append(LS); sb.append(" buf.append(s);").append(LS); sb.append(" // TODO modifier specials pour inclure fins de ligne").append(LS); sb.append(" if (c == '\\n' || c == '\\r')").append(LS); sb.append(" buf.append(spc);").append(LS); sb.append(" else").append(LS); sb.append(" buf.append(LS).append(spc);").append(LS); sb.append(" }").append(LS); sb.append(" return buf.toString();").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Returns the list of special tokens of the current {@link NodeToken} ") .append("and the current
").append(LS); sb.append(" * {@link NodeToken} as a string, taking in account a given indentation.") .append(LS); sb.append(" *").append(LS); sb.append(" * @param spc the indentation").append(LS); sb.append(" * @return the string representing the special tokens list and the token") .append(LS); sb.append(" */").append(LS); } sb.append(" public String withSpecials(final String spc) {").append(LS); sb.append(" final String specials = getSpecials(spc);").append(LS); sb.append(" final int len = specials.length();").append(LS); sb.append(" if (len == 0)").append(LS); sb.append(" return tokenImage;").append(LS); sb.append(" StringBuilder buf = new StringBuilder(len + tokenImage.length());").append(LS); sb.append(" buf.append(specials).append(tokenImage);").append(LS); sb.append(" return buf.toString();").append(LS); sb.append(" }").append(LS).append(LS); classesAcceptMethods(sb); parentPointerGetterSetter(sb); sb.append("}").append(LS); return sb; } /* * "RetArgu" visit methods */ /** * Generates the visit method declaration on a {@link NodeList} for a visitor with user Return and * Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetArguVisitNodeList(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(280); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeList} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeListName).append(" n, final ").append(Globals.genArguType) .append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeListOptional} for a visitor with user * Return and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetArguVisitNodeListOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(280); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeListOptional} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeListOptName).append(" n, final ").append(Globals.genArguType) .append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeOptional} for a visitor with user Return * and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetArguVisitNodeOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(280); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeOptional} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeOptName).append(" n, final ").append(Globals.genArguType) .append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeSequence} for a visitor with user Return * and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetArguVisitNodeSeq(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(280); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeSequence} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeSeqName).append(" n, final ").append(Globals.genArguType) .append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeToken} for a visitor with user Return * and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetArguVisitNodeToken(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(280); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeToken} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeTokenName).append(" n, final ").append(Globals.genArguType) .append(" argu);").append(LS); return sb; } /* * "Ret" visit methods */ /** * Generates the visit method declaration on a {@link NodeList} for a visitor with user Return and * no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetVisitNodeList(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(250); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeList} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeListName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeListOptional} for a visitor with user * Return and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetVisitNodeListOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(250); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeListOptional} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeListOptName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeOptional} for a visitor with user Return * and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetVisitNodeOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(250); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeOptional} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeOptName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeSequence} for a visitor with user Return * and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetVisitNodeSeq(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(250); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeSequence} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeSeqName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeToken} for a visitor with user Return * and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genRetVisitNodeToken(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(250); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeToken} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @return the user return information").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.genRetType).append(" visit(final ") .append(Globals.nodeTokenName).append(" n);").append(LS); return sb; } /* * "VoidArgu" visit methods */ /** * Generates the visit method declaration on a {@link NodeList} for a visitor with user no Return * and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidArguVisitNodeList(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(260); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeList} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeListName).append(" n, final ") .append(Globals.genArguType).append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeListOptional} for a visitor with user no * Return and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidArguVisitNodeListOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(260); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeListOptional} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeListOptName).append(" n, final ") .append(Globals.genArguType).append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeOptional} for a visitor with user no * Return and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidArguVisitNodeOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(260); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeOptional} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeOptName).append(" n, final ") .append(Globals.genArguType).append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeSequence} for a visitor with user no * Return and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidArguVisitNodeSeq(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(100); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeSequence} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeSeqName).append(" n, final ") .append(Globals.genArguType).append(" argu);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeToken} for a visitor with user no Return * and Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidArguVisitNodeToken(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(260); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeToken} node, passing it an argument.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" * @param argu the user argument").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeTokenName).append(" n, final ") .append(Globals.genArguType).append(" argu);").append(LS); return sb; } /* * "Void" visit methods */ /** * Generates the visit method declaration on a {@link NodeList} for a visitor with user no Return * and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidVisitNodeList(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(230); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeList} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeListName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeListOptional} for a visitor with user no * Return and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidVisitNodeListOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(230); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeListOptional} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeListOptName).append(" n);") .append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeOptional} for a visitor with user no * Return and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidVisitNodeOpt(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(230); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeOptional} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeOptName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeSequence} for a visitor with user no * Return and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidVisitNodeSeq(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(230); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeSequence} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeSeqName).append(" n);").append(LS); return sb; } /** * Generates the visit method declaration on a {@link NodeToken} for a visitor with user no Return * and no Argument data. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated visit method */ static StringBuilder genVoidVisitNodeToken(final StringBuilder aSB) { StringBuilder sb = aSB; if (sb == null) sb = new StringBuilder(230); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Visits a {@link NodeToken} node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the node to visit").append(LS); sb.append(" */").append(LS); } sb.append(" public void visit(final ").append(Globals.nodeTokenName).append(" n);").append(LS); return sb; } /** * Generates package and visitor classes imports. * * @param aSB a buffer to print into (will be allocated if null) */ static void packageAndImports(final StringBuilder aSB) { aSB.append("package ").append(Globals.nodesPackageName).append(";").append(LS).append(LS); aSB.append("import ").append(Globals.visitorsPackageName).append(".IRetArguVisitor;").append(LS); aSB.append("import ").append(Globals.visitorsPackageName).append(".IRetVisitor;").append(LS); aSB.append("import ").append(Globals.visitorsPackageName).append(".IVoidArguVisitor;").append(LS); aSB.append("import ").append(Globals.visitorsPackageName).append(".IVoidVisitor;").append(LS); } /** * Generates the serial uid member. * * @param aSB a buffer to print into (will be allocated if null) */ static void serialUIDDeclaration(final StringBuilder aSB) { if (Globals.javaDocComments) aSB.append(" /** The serial version uid */").append(LS); aSB.append(" private static final long serialVersionUID = " + Globals.SERIAL_UID + "L;") .append(LS).append(LS); } /** * Generates the line separator member. * * @param aSB a buffer to print into (will be allocated if null) */ static void lineSeparatorDeclaration(final StringBuilder aSB) { if (Globals.javaDocComments) aSB.append(" /** The OS line separator */").append(LS); aSB.append(" public static final String LS = System.getProperty(\"line.separator\");") .append(LS).append(LS); } /** * Generates parent pointer field. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated declaration */ static StringBuilder parentPointerDeclaration(final StringBuilder aSB) { StringBuilder sb = aSB; if (Globals.parentPointer) { if (sb == null) sb = new StringBuilder(50); if (Globals.javaDocComments) aSB.append(" /** The parent node */").append(LS); sb.append(" private ").append(Globals.iNodeName).append(" parent;").append(LS).append(LS); } else if (sb == null) sb = new StringBuilder(0); return sb; } /** * Generates parent pointer getter and setter methods. * * @param aSB a buffer to print into (will be allocated if null) * @return the generated methods */ static StringBuilder parentPointerGetterSetter(final StringBuilder aSB) { StringBuilder sb = aSB; if (Globals.parentPointer) { if (sb == null) sb = new StringBuilder(200); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Sets the parent node.").append(LS); sb.append(" *").append(LS); sb.append(" * @param n the parent node").append(LS); sb.append(" */").append(LS); } sb.append(" public void setParent(final ").append(Globals.iNodeName).append(" n) {") .append(LS); sb.append(" parent = n;").append(LS); sb.append(" }").append(LS).append(LS); if (Globals.javaDocComments) { sb.append(" /**").append(LS); sb.append(" * Gets the parent node.").append(LS); sb.append(" *").append(LS); sb.append(" * @return the parent node").append(LS); sb.append(" */").append(LS); } sb.append(" public ").append(Globals.iNodeName).append(" getParent() {").append(LS); sb.append(" return parent;").append(LS); sb.append(" }").append(LS); } else if (sb == null) sb = new StringBuilder(0); return sb; } /** * Generates parent pointer set call. * * @param aSB a buffer to print into (must be non null) */ static void parentPointerSetCall(final StringBuilder aSB) { aSB.append((Globals.parentPointer ? " n.setParent(this);\n" : "")); aSB.append((Globals.parentPointer ? LS : "")); } /** * Generates the node list methods (for list nodes). * * @param aSB a buffer to print into (must be non null) */ static void listMethods(final StringBuilder aSB) { if (Globals.javaDocComments) { aSB.append(" /**").append(LS); aSB.append(" * Gets the node in the list at a given position.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param i the node's position").append(LS); aSB.append(" * @return the node").append(LS); aSB.append(" */").append(LS); } aSB.append(" public ").append(Globals.iNodeName).append(" elementAt(final int i) {") .append(LS); aSB.append(" return nodes.get(i); }").append(LS).append(LS); if (Globals.javaDocComments) { aSB.append(" /**").append(LS); aSB.append(" * Returns an iterator on the nodes list.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @return the iterator").append(LS); aSB.append(" */").append(LS); } aSB.append(" public Iterator<").append(Globals.iNodeName).append("> elements() {").append(LS); aSB.append(" return nodes.iterator(); }").append(LS).append(LS); if (Globals.javaDocComments) { aSB.append(" /**").append(LS); aSB.append(" * Returns the number of nodes in the list.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @return the list size").append(LS); aSB.append(" */").append(LS); } aSB.append(" public int size() {").append(LS); aSB.append(" return nodes.size(); }").append(LS).append(LS); } /** * Generates the node interfaces accept methods. * * @param aSB a buffer to print into (must be non null) */ static void interfacesAcceptMethods(final StringBuilder aSB) { if (Globals.javaDocComments) genAcceptRetArguComment(aSB); aSB.append(" public ").append(parRetArgu).append(" ").append(begRetArgu) .append(Globals.iRetArguVisitorName).append(parRetArgu).append(endRetArgu).append(";") .append(LS).append(LS); if (Globals.javaDocComments) genAcceptRetComment(aSB); aSB.append(" public ").append(parRet).append(" ").append(begRet) .append(Globals.iRetVisitorName).append(parRet).append(endRet).append(";").append(LS) .append(LS); if (Globals.javaDocComments) genAcceptVoidArguComment(aSB); aSB.append(" public ").append(parVoidArgu).append(" ").append(begVoidArgu) .append(Globals.iVoidArguVisitorName).append(parVoidArgu).append(endVoidArgu).append(";") .append(LS).append(LS); if (Globals.javaDocComments) genAcceptVoidComment(aSB); aSB.append(" public ").append(parVoid).append(begVoid).append(Globals.iVoidVisitorName) .append(parVoid).append(endVoid).append(";").append(LS).append(LS); } /** * Generates the javadoc comment for a method with user Return and Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genAcceptRetArguComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB .append(" * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data.") .append(LS); aSB.append(" *").append(LS); aSB.append(" * @param the user Return type").append(LS); aSB.append(" * @param
the user Argument type").append(LS); aSB.append(" * @param vis the visitor").append(LS); aSB.append(" * @param argu the user Argument data").append(LS); aSB.append(" * @return the user Return data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with Return data. * * @param aSB a buffer to print into (must be non null) */ static void genAcceptRetComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Accepts a {@link IRetVisitor} visitor with user Return data.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param the user Return type").append(LS); aSB.append(" * @param vis the visitor").append(LS); aSB.append(" * @return the user Return data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with user Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genAcceptVoidArguComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Accepts a {@link IVoidArguVisitor} visitor with user Argument data.") .append(LS); aSB.append(" *").append(LS); aSB.append(" * @param the user Argument type").append(LS); aSB.append(" * @param vis the visitor").append(LS); aSB.append(" * @param argu the user Argument data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with no user Return nor Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genAcceptVoidComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB .append(" * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data.") .append(LS); aSB.append(" *").append(LS); aSB.append(" * @param vis the visitor").append(LS); aSB.append(" */").append(LS); } /** * Generates the node classes accept methods. * * @param aSB a buffer to print into (must be non null) */ static void classesAcceptMethods(final StringBuilder aSB) { if (Globals.javaDocComments) genAcceptRetArguComment(aSB); aSB.append(" public ").append(parRetArgu).append(" ").append(begRetArgu) .append(Globals.iRetArguVisitorName).append(parRetArgu).append(endRetArgu).append(" {") .append(LS); aSB.append(" return vis.visit(this, argu);").append(LS); aSB.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptRetComment(aSB); aSB.append(" public ").append(parRet).append(" ").append(begRet) .append(Globals.iRetVisitorName).append(parRet).append(endRet).append(" {").append(LS); aSB.append(" return vis.visit(this);").append(LS); aSB.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptVoidArguComment(aSB); aSB.append(" public ").append(parVoidArgu).append(" ").append(begVoidArgu) .append(Globals.iVoidArguVisitorName).append(parVoidArgu).append(endVoidArgu).append(" {") .append(LS); aSB.append(" vis.visit(this, argu);").append(LS); aSB.append(" }").append(LS).append(LS); if (Globals.javaDocComments) genAcceptVoidComment(aSB); aSB.append(" public ").append(parVoid).append(begVoid).append(Globals.iVoidVisitorName) .append(parVoid).append(endVoid).append(" {").append(LS); aSB.append(" vis.visit(this);").append(LS); aSB.append(" }").append(LS).append(LS); } /** * Generates the javadoc comment for a method with user Return and Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genVisitRetArguComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Visits a node with user Return and Argument data.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param n the node to visit").append(LS); aSB.append(" * @param argu the user Argument data").append(LS); aSB.append(" * @return the user Return data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with user Return data. * * @param aSB a buffer to print into (must be non null) */ static void genVisitRetComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Visits a node with user Return data.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param n the node to visit").append(LS); aSB.append(" * @return the user Return data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with user Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genVisitVoidArguComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Visits a node with user Argument data.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param n the node to visit").append(LS); aSB.append(" * @param argu the user Argument data").append(LS); aSB.append(" */").append(LS); } /** * Generates the javadoc comment for a method with no user Return nor Argument data. * * @param aSB a buffer to print into (must be non null) */ static void genVisitVoidComment(final StringBuilder aSB) { aSB.append(" /**").append(LS); aSB.append(" * Visits a node with a user no user Return nor Argument data.").append(LS); aSB.append(" *").append(LS); aSB.append(" * @param n the node to visit").append(LS); aSB.append(" */").append(LS); } /* * Utility methods */ /** * @return the extends clause. */ static String extendsClause() { return (Globals.nodesSuperclass != null ? " extends " + Globals.nodesSuperclass : ""); } /** * Generates the class parameter type(s). * * @param ret true if with a Return type, false if void * @param arg true if with a user Argument, false otherwise * @return the class parameter(s) string */ static String genClassParamType(final boolean ret, final boolean arg) { if (ret) { if (arg) { return "<" + Globals.genRetType + ", " + Globals.genArguType + ">"; } else { return "<" + Globals.genRetType + ">"; } } else { if (arg) { return "<" + Globals.genArguType + ">"; } else { return ""; } } } /** * @param ret true if with a Return type, false if void * @return the beginning of the argument(s) list */ static String begArgList(final boolean ret) { if (ret) { return Globals.genRetType + " accept(final "; } else { return "void accept(final "; } } /** * @param arg true if with a user Argument, false otherwise * @return the end of the argument(s) list */ static String endArgList(final boolean arg) { if (arg) { return " vis, final " + Globals.genArguType + " argu)"; } else { return " vis)"; } } } jtb-1.4.4/EDU/purdue/jtb/visitor/0000755000175000017500000000000011420623644016320 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/visitor/ClassGenerator.java0000644000175000017500000004422011360636742022107 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. All rights reserved. Redistribution and use in * source and binary forms, with or without modification, are permitted provided that the following * conditions are met: Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. Redistributions in binary form must reproduce * the above copyright notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. Neither UCLA nor the names * of its contributors may be used to endorse or promote products derived from this software without * specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are Copyright 1997, 1998, 1999 by the * Purdue Research Foundation of Purdue University. All rights reserved. Redistribution and use in * source and binary forms are permitted provided that this entire copyright notice is duplicated in * all such copies, and that any documentation, announcements, and other materials related to such * distribution and use acknowledge that the software was developed at Purdue University, West * Lafayette, Indiana by Kevin Tao and Jens Palsberg. No charge may be made for copies, derivations, * or distributions of this material without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author may be used to endorse or promote * products derived from this material without specific prior written permission. THIS SOFTWARE IS * PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import EDU.purdue.jtb.misc.ClassInfo; import EDU.purdue.jtb.misc.FieldNameGenerator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.syntaxtree.BNFProduction; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.JavaCCInput; import EDU.purdue.jtb.syntaxtree.JavaCodeProduction; import EDU.purdue.jtb.syntaxtree.LocalLookahead; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.syntaxtree.Production; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.StringLiteral; import EDU.purdue.jtb.syntaxtree.TokenManagerDecls; /** * The ClassGenerator visitor creates a list of ClassInfo objects describing every class to be * generated.
{@link Annotator} and ClassGenerator depend on each other to create and use classes.
* Programming note: we do not continue down the tree once a new field has been added to curClass, * as we only worry about top-level expansions.
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class ClassGenerator extends DepthFirstVoidVisitor { /** Visitor for finding return variables declarations */ final GlobalDataFinder gdfv = new GlobalDataFinder(); /** Flag to print the token or not */ private boolean printToken = false; /** The table used to generate default constructors if a token has a constant regexpr */ private Hashtable tokenTable; /** The current generated class */ private ClassInfo curClass; /** The list of generated classes */ private final ArrayList classList = new ArrayList(); /** The field names generator (descriptive or not, depending on -f option) */ private final FieldNameGenerator nameGen = new FieldNameGenerator(); /** Global variable to pass RegularExpression info between methods (as they are recursive) */ String regExpr = ""; /** Global variable to pass Identifier info between methods (as they are recursive) */ String ident = ""; /** The JavaCodeProductions table */ Hashtable jcpHT = new Hashtable(); /** * Getter for the class list. * * @return the class list */ public ArrayList getClassList() { return classList; } /* * User generated visitor methods below */ /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // find first global data n.accept(gdfv); // build the token table and visit only Production final TokenTableBuilder builder = new TokenTableBuilder(); n.accept(builder); tokenTable = builder.getTokenTable(); n.f10.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final JavaCodeProduction n) { // Don't visit } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ @Override public void visit(final BNFProduction n) { nameGen.reset(); printToken = true; curClass = new ClassInfo(n.f8, n.f2.f0.tokenImage); classList.add(curClass); n.f8.accept(this); printToken = false; } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final RegularExprProduction n) { // Don't visit : don't want to generate NodeTokens inside RegularExpression // if it's visited from a RegularExpressionProduction } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final TokenManagerDecls n) { // Don't visit } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { if (!n.f1.present()) n.f0.accept(this); else curClass .addField(Globals.nodeChoiceName, nameGen.genCommentFieldName(Globals.nodeChoiceName)); } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // don't visit LocalLookahead n.f1.accept(this); } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final LocalLookahead n) { // Don't visit...ignore lookaheads } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { NodeSequence seq; NodeChoice ch; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" return; case 1: // %1 Block() return; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" curClass.addField(Globals.nodeOptName, nameGen.genCommentFieldName(Globals.nodeOptName)); return; case 3: // %3 ExpansionUnitInTCF() n.f0.choice.accept(this); return; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) seq = (NodeSequence) n.f0.choice; ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; if (ch.which == 0) { // &0 $0 Identifier() $1 Arguments() // ident will be set further down the tree seq1.elementAt(0).accept(this); // add the field if not a JavaCodeProduction if (!jcpHT.containsKey(ident)) { curClass.addField(ident, nameGen.genCommentFieldName(ident)); } } else { // &1 $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] ) seq1.elementAt(0).accept(this); } return; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? seq = (NodeSequence) n.f0.choice; final NodeOptional opt = (NodeOptional) seq.elementAt(3); if (opt.present()) { ch = (NodeChoice) opt.node; final String name = getNodeNameForMod(ch.which); curClass.addField(name, nameGen.genCommentFieldName(name)); } else { if (((ExpansionChoices) seq.elementAt(1)).f1.present()) // f1 -> ( "|" Expansion(c2) )* curClass.addField(Globals.nodeChoiceName, nameGen.genCommentFieldName(Globals.nodeChoiceName)); else // f0 -> Expansion(c1) curClass .addField(Globals.nodeSeqName, nameGen.genCommentFieldName(Globals.nodeSeqName)); } return; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); return; } } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f2 -> ExpansionChoices() n.f2.accept(this); } /** * Returns the base node name for a given modifier. * * @param mod the modifier * @return the corresponding base node name */ private String getNodeNameForMod(final int mod) { if (mod == 0) return Globals.nodeListName; else if (mod == 1) return Globals.nodeListOptName; else if (mod == 2) return Globals.nodeOptName; else { Messages.hardErr("Illegal EBNF modifier in " + "ExpansionUnit: mod = " + mod); return ""; } } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(final RegularExpression n) { regExpr = ""; String initialValue = null; boolean isEOF = false; if (!printToken) return; switch (n.f0.which) { case 0: // StringLiteral() n.f0.choice.accept(this); break; case 1: // [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) "> regExpr = ""; break; case 2: // "<" Identifier() ">" final NodeSequence seq = (NodeSequence) n.f0.choice; // ident will be set further down the tree seq.elementAt(1).accept(this); regExpr = tokenTable.get(ident); if (regExpr == null) { final NodeToken ident_nt = ((Identifier) seq.elementAt(1)).f0; Messages.softErr("Undefined token \"" + ident_nt + "\".", ident_nt.beginLine); regExpr = ""; ident = ""; } break; case 3: // "<" "EOF" ">" regExpr = ""; isEOF = true; break; default: Messages.hardErr("Unreachable code executed!"); } if (isEOF) initialValue = "new " + Globals.nodeTokenName + "(\"\")"; else if (regExpr.length() != 0) initialValue = "new " + Globals.nodeTokenName + "(" + regExpr + ")"; curClass.addField(Globals.nodeTokenName, nameGen.genCommentFieldName(Globals.nodeTokenName), initialValue); } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { ident = n.f0.tokenImage; } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { regExpr = n.f0.tokenImage; } /** * The GlobalDataFinder visitor finds:
* all "void" JavaCodeProductions and adds them to a Hashtable (which will be used to avoid * creating later invalid child nodes). */ class GlobalDataFinder extends DepthFirstVoidVisitor { /** * Constructor, with a given buffer and a default indentation. */ GlobalDataFinder() { super(); } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // visits only Productions // f10 -> ( Production() )+ for (final Iterator e = n.f10.elements(); e.hasNext();) { e.next().accept(this); } } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ @Override public void visit(final Production n) { // visits only JavaCodeProduction if (n.f0.which == 0) n.f0.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(final JavaCodeProduction n) { // store it in the hashtable // f3 -> Identifier() final String id = n.f3.f0.tokenImage; jcpHT.put(id, id); } } } jtb-1.4.4/EDU/purdue/jtb/visitor/SemanticChecker.java0000644000175000017500000006420211360636742022225 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import java.util.Iterator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.syntaxtree.BNFProduction; import EDU.purdue.jtb.syntaxtree.Block; import EDU.purdue.jtb.syntaxtree.BlockStatement; import EDU.purdue.jtb.syntaxtree.ClassOrInterfaceType; import EDU.purdue.jtb.syntaxtree.DoStatement; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.ForStatement; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.IfStatement; import EDU.purdue.jtb.syntaxtree.JavaCCInput; import EDU.purdue.jtb.syntaxtree.JavaCCOptions; import EDU.purdue.jtb.syntaxtree.JavaCodeProduction; import EDU.purdue.jtb.syntaxtree.LocalLookahead; import EDU.purdue.jtb.syntaxtree.LocalVariableDeclaration; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.syntaxtree.OptionBinding; import EDU.purdue.jtb.syntaxtree.PrimitiveType; import EDU.purdue.jtb.syntaxtree.Production; import EDU.purdue.jtb.syntaxtree.ReferenceType; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.ResultType; import EDU.purdue.jtb.syntaxtree.ReturnStatement; import EDU.purdue.jtb.syntaxtree.Statement; import EDU.purdue.jtb.syntaxtree.SwitchStatement; import EDU.purdue.jtb.syntaxtree.SynchronizedStatement; import EDU.purdue.jtb.syntaxtree.TokenManagerDecls; import EDU.purdue.jtb.syntaxtree.TryStatement; import EDU.purdue.jtb.syntaxtree.Type; import EDU.purdue.jtb.syntaxtree.VariableDeclarator; import EDU.purdue.jtb.syntaxtree.WhileStatement; /** * SemanticChecker visitor checks and report informations, warnings or errors for the following * conditions}
*

*

* Note: the warning}
* "No blocks of Java code must exist within ExpansionUnit" (since the JTB first authors believed * they are generally unnecessary in JTB grammars)
* has been replaced by the following new information}
*"Return statement in a Java block in production '...' . It will be transformed in an assign * statement to the corresponding new parser class variable."
* These blocks are now allowed - as for example JavaCC 4.2 grammar has a lot of Java code blocks -
* but as JTB generates return statements to create and return the nodes corresponding to the * productions and changes the production return types, JTB now creates an additional parser class * variable to store the user return information and changes the corresponding return statements. *

* Note: the warning}
* "JavaCodeProduction blocks must be specially handled."
* has been replaced by the following new information}
* "Non "void" JavaCodeProduction. Result type '...' will be changed into '...', and a parser class * variable 'jtbrt_...' of type '...'will be added to hold the return value."
* JTB now creates an additional parser class variable to store the user return information and * changes the corresponding return statements. *

* Note: the warning}
* "Non initialized user variable '...'. May lead to compiler error(s). Check in generated parser."
* has been added (it may lead to unnecessary warnings). *

* To be Done: check that the JTB generated return variables do not collide with user variables. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.1 : 02/2010 : MMa : fixed unprocessed n.f0.which == 0 case in visit(ExpansionUnit) */ public class SemanticChecker extends DepthFirstVoidVisitor { /** The name of the current production */ String prod; /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // only visit production subtree n.f10.accept(this); } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final JavaCCOptions n) { // should not be called ! } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final OptionBinding n) { // should not be called ! } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ @Override public void visit(final Production n) { // visit only JavaCodeProduction() and BNFProduction if (n.f0.which == 0 || n.f0.which == 3) n.f0.choice.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(final JavaCodeProduction n) { // f3 -> Identifier() final String ident = n.f3.f0.tokenImage; final String resType = getResultType(n.f2); if (!"void".equals(resType)) { Messages.info("Non \"void\" JavaCodeProduction. Result type '" + resType + "' will be changed into '" + ident + "', and a parser class variable 'jtbrt_" + resType + "' of type '" + resType + "'will be added to hold the return value.", n.f0.beginLine); } } /** * Gets the ResultType. Walks down the tree to find the first token. *

* {@link ResultType}
* f0 -> ( "void" | Type() )
*

* {@link Type}
* f0 -> ReferenceType()
* | PrimitiveType()
*

* {@link ReferenceType}
* f0 -> PrimitiveType() ( "[" "]" )+
* | ClassOrInterfaceType() ( "[" "]" )*
*

* {@link PrimitiveType}
* f0 -> "boolean"
* | "char"
* | "byte"
* | "short"
* | "int"
* | "long"
* | "float"
* | "double"
*

* {@link ClassOrInterfaceType}
* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( "." < IDENTIFIER > [ TypeArguments() ] )*
* * @param rt the node to process * @return the result type token image */ String getResultType(final ResultType rt) { NodeToken tk; final INode n = rt.f0.choice; if (rt.f0.which == 0) { // "void" tk = (NodeToken) n; } else { // Type( final NodeChoice ch = ((Type) n).f0; if (ch.which == 0) { // ReferenceType() final NodeChoice ch1 = ((ReferenceType) ch.choice).f0; if (ch1.which == 0) { // PrimitiveType() ( "[" "]" )+ tk = (NodeToken) ((PrimitiveType) ch1.choice).f0.choice; } else { // ClassOrInterfaceType() ( "[" "]" )* tk = ((ClassOrInterfaceType) ((NodeSequence) ch1.choice).elementAt(0)).f0; } } else { // PrimitiveType() tk = (NodeToken) ((PrimitiveType) ch.choice).f0.choice; } } return tk.tokenImage; } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final RegularExprProduction n) { // should not be called ! } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final TokenManagerDecls n) { // should not be called ! } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ @Override public void visit(final BNFProduction n) { // f1 -> ResultType(p.getReturnTypeTokens()) final ResultType rt = n.f1; NodeToken tk; final INode in = rt.f0.choice; if (rt.f0.which == 0) { // "void" : no need for return variable, but need to check variable initialization } else { // Type( final NodeChoice ch = ((Type) in).f0; if (ch.which == 0) { // ReferenceType() final NodeChoice ch1 = ((ReferenceType) ch.choice).f0; if (ch1.which == 0) { // PrimitiveType() ( "[" "]" )+ tk = (NodeToken) ((PrimitiveType) ch1.choice).f0.choice; } else { // ClassOrInterfaceType() ( "[" "]" )* tk = ((ClassOrInterfaceType) ((NodeSequence) ch1.choice).elementAt(0)).f0; } } else { // PrimitiveType() tk = (NodeToken) ((PrimitiveType) ch.choice).f0.choice; } final String resType = tk.tokenImage; final String ident = n.f2.f0.tokenImage; Messages.info("Non \"void\" BNFProduction. Result type '" + resType + "' will be changed into '" + ident + "', and a parser class variable '" + Globals.JTBRT_PREFIX + ident + "' of type '" + resType + "' will be added to hold the return values.", tk.beginLine); prod = n.f2.f0.tokenImage; if (prod.equals(Globals.iNodeName) || prod.equals(Globals.iNodeListName) || prod.equals(Globals.nodeListName) || prod.equals(Globals.nodeListOptName) || prod.equals(Globals.nodeOptName) || prod.equals(Globals.nodeSeqName) || prod.equals(Globals.nodeTokenName) || prod.equals(Globals.nodeChoiceName)) Messages.softErr("Production \"" + prod + "\" has the same name as a JTB generated class.", n.f2.f0.beginLine); } // f6 -> Block(p.getDeclarationTokens()) if (n.f6.f1.present()) { // visit block declarations only if non empty for (final Iterator e = n.f6.f1.elements(); e.hasNext();) // BlockStatement(), not Block() ! e.next().accept(this); } // f8 -> ExpansionChoices(c) n.f8.accept(this); } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final Block n) { // f1 -> ( BlockStatement() )* if (n.f1.present()) for (final Iterator e = n.f1.elements(); e.hasNext();) // BlockStatement() e.next().accept(this); } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit */ @Override public void visit(final BlockStatement n) { if (n.f0.which <= 1) // LocalVariableDeclaration() ";" or Statement() n.f0.choice.accept(this); } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit */ @Override public void visit(final LocalVariableDeclaration n) { // f2 -> VariableDeclarator() n.f2.accept(this); // f3 -> ( "," VariableDeclarator() )* if (n.f3.present()) { for (final Iterator e = n.f3.elements(); e.hasNext();) { // VariableDeclarator() ((NodeSequence) e.next()).elementAt(1).accept(this); } } } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit */ @Override public void visit(final VariableDeclarator n) { // f1 -> [ "=" VariableInitializer() ] if (!n.f1.present()) { final String var = n.f0.f0.tokenImage; Messages.warning("Non initialized user variable '" + var + "'. May lead to compiler error(s)" + " (specially for 'Token' variables). Check in generated parser.", n.f0.f0.beginLine); } } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit */ @Override public void visit(final Statement n) { switch (n.f0.which) { case 0: // LabeledStatement() : f2 -> Statement() ((NodeSequence) n.f0.choice).elementAt(2).accept(this); break; case 2: // Block(null) : f1 -> ( BlockStatement() )* if (((Block) n.f0.choice).f1.present()) ((Block) n.f0.choice).f1.accept(this); break; case 5: // SwitchStatement() : f5 -> ( SwitchLabel() ( BlockStatement() )* )*
final NodeListOptional nlo5 = ((SwitchStatement) n.f0.choice).f5; if (nlo5.present()) { for (final Iterator e = nlo5.elements(); e.hasNext();) { final NodeSequence seq5 = (NodeSequence) e.next(); if (((NodeListOptional) seq5.elementAt(1)).present()) seq5.elementAt(1).accept(this); } } break; case 6: // IfStatement() : f4 -> Statement() and f5 -> [ "else" Statement() ] ((IfStatement) n.f0.choice).f4.accept(this); final NodeOptional opt6 = ((IfStatement) n.f0.choice).f5; if (opt6.present()) { ((NodeSequence) opt6.node).elementAt(1).accept(this); } break; case 7: // WhileStatement() ((WhileStatement) n.f0.choice).f4.accept(this); break; case 8: // DoStatement() ((DoStatement) n.f0.choice).f1.accept(this); break; case 9: // ForStatement() ((ForStatement) n.f0.choice).f4.accept(this); break; case 12: // ReturnStatement() Messages.info("Return statement in a Java block in production '" + prod + "()'. It will " + "be transformed in an assign statement to the corresponding new parser " + "class variable.", ((ReturnStatement) n.f0.choice).f0.beginLine); break; case 14: // SynchronizedStatement() ((SynchronizedStatement) n.f0.choice).f4.accept(this); break; case 15: // TryStatement() // f1 -> Block(null) ((TryStatement) n.f0.choice).f1.accept(this); // f2 -> ( "catch" "(" FormalParameter() ")" Block(null) )* final NodeListOptional nlo15 = ((TryStatement) n.f0.choice).f2; if (nlo15.present()) { for (final Iterator e = nlo15.elements(); e.hasNext();) { ((NodeSequence) e.next()).elementAt(4).accept(this); } } // f3 -> [ "finally" Block(null) ] final NodeOptional opt15 = ((TryStatement) n.f0.choice).f3; if (opt15.present()) { ((NodeSequence) opt15.node).elementAt(1).accept(this); } break; default: break; } } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { // f0 -> Expansion(c1) n.f0.accept(this); // f1 -> ( "|" Expansion(c2) )* final NodeListOptional nlo = n.f1; if (nlo.present()) { for (final Iterator e = nlo.elements(); e.hasNext();) { ((NodeSequence) e.next()).elementAt(1).accept(this); } } } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // visit only ExpansionUnit n.f1.accept(this); } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { NodeSequence seq; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" return; case 1: // %1 Block() n.f0.choice.accept(this); return; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" ((NodeSequence) n.f0.choice).elementAt(1).accept(this); return; case 3: // ExpansionUnitInTCF() n.f0.choice.accept(this); return; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) return; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? seq = (NodeSequence) n.f0.choice; final ExpansionChoices choice = (ExpansionChoices) seq.elementAt(1); final NodeOptional mod = (NodeOptional) seq.elementAt(3); if (!mod.present() && !choice.f1.present()) Messages.warning("Extra parentheses in " + prod + "().", ((NodeToken) ((NodeSequence) n.f0.choice).elementAt(0)).beginLine); return; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); return; } } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f2 -> ExpansionChoices() n.f2.accept(this); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* if (n.f4.present()) { for (int i = 0; i < n.f4.size(); i++) { // #5 Block() ((NodeSequence) n.f4.elementAt(i)).elementAt(5).accept(this); } } // f5 -> [ #0 "finally" #1 Block() ] if (n.f5.present()) { // #1 Block() ((NodeSequence) n.f5.node).elementAt(1).accept(this); } } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final LocalLookahead n) { // should not be called ! } /** * Visits the {@link RegularExpression node}
* f0 -> StringLiteral()
* | < LANGLE: "<" > [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) < RANGLE: ">" * >
* | "<" Identifier() ">"
* | "<" "EOF" ">"
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final RegularExpression n) { // should not be called ! } }jtb-1.4.4/EDU/purdue/jtb/visitor/JavaPrinter.java0000644000175000017500000026720311416555562021432 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ // // Modified for use with JTB bootstrap. // // Pretty printer for the Java grammar. // Author: Kevin Tao, taokr@cs // // (reminders for myself): // - spc.spc should be printed after every LS or println(). // - println() should not be the last thing printed in a visit method. // - always copy this file from the JTB source and remove the comments around // Spacing at the bottom. Remove the import for misc.Spacing. // package EDU.purdue.jtb.visitor; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Iterator; import EDU.purdue.jtb.misc.FileExistsException; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.Spacing; import EDU.purdue.jtb.misc.UnicodeConverter; import EDU.purdue.jtb.syntaxtree.*; /** * The JavaPrinter visitor reprints (with indentation) JavaCC grammar Java specific productions.
* (The JavaCC grammar JavaCC productions are handled by the JavaCCPrinter visitor superclass.) *

* Notes : *

    *
  • sb.append(spc.spc), sb.append(" ") and sb.append(LS) are done at the highest (calling) level * (except for Modifiers() which prints the last space if not empty) *
  • sb.append(spc.spc) is done after sb.append(LS) *
  • sb.append(" ") is not merged with printing punctuation / operators (to prepare evolutions for * other formatting preferences), but is indeed merged with printing keywords *
* To be Done : extract methods for custom formatting
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.3 : 03/2010 : MMa : fixed output of else in IfStatement * @version 1.4.4 : 07/2010 : MMa : fixed output after throws in MethodDeclaration, * ConstructorDeclaration, and wrong index in TypeArguments */ public class JavaPrinter extends DepthFirstVoidVisitor { /** The buffer to print into */ protected StringBuilder sb; /** Indentation object */ protected Spacing spc; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Constructor with a given buffer and indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) * @param aSPC the Spacing indentation object (will be allocated and set to a default if null) */ public JavaPrinter(final StringBuilder aSB, final Spacing aSPC) { reset(aSB, aSPC); } /** * Resets the buffer and the indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) * @param aSPC the Spacing indentation object (will be allocated and set to a default if null) */ public void reset(final StringBuilder aSB, final Spacing aSPC) { sb = aSB; if (sb == null) sb = new StringBuilder(2048); spc = aSPC; if (spc == null) spc = new Spacing(Globals.INDENT_AMT); } /** * Constructor which will allocate a default buffer and indentation. */ public JavaPrinter() { this(null, null); } /** * Constructor with a given buffer and which will allocate a default indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) */ public JavaPrinter(final StringBuilder aSB) { this(aSB, null); } /** * Constructor with a given indentation which will allocate a default buffer. * * @param aSPC the Spacing indentation object */ public JavaPrinter(final Spacing aSPC) { this(null, aSPC); } /** * Saves the current buffer to an output file. * * @param outFile the output file * @throws FileExistsException if the file exists and the noOverwrite flag is set */ public void saveToFile(final String outFile) throws FileExistsException { try { final File file = new File(outFile); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFile); else { final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), sb.length())); out.print(sb); out.close(); } } catch (final IOException e) { Messages.hardErr(e); } } /* * Base classes visit methods */ /** * Visits a NodeToken. * * @param n the node to visit */ @Override public void visit(final NodeToken n) { if (Globals.keepSpecialTokens) { sb.append(n.withSpecials(spc.spc)); } else { sb.append(n.tokenImage); } } /* * Convenience methods */ /** * Prints into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void oneNewLine(final INode n) { sb.append(nodeClassComment(n)).append(LS); } /** * Prints into the current buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment */ void oneNewLine(final INode n, final String str) { sb.append(nodeClassComment(n, str)).append(LS); } /** * Prints twice into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void twoNewLines(final INode n) { oneNewLine(n); oneNewLine(n); } /** * Prints three times into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void threeNewLines(final INode n) { oneNewLine(n); oneNewLine(n); oneNewLine(n); } /** * Returns a comment including the node class name. * * @param n the node to process * @return the comment */ private String nodeClassComment(final INode n) { if (Globals.PRINT_CLASS_COMMENT) { final String s = n.toString(); final int b = s.lastIndexOf('.') + 1; final int e = s.indexOf('@'); if (b == -1 || e == -1) return " //.. " + s; else return " //.. " + s.substring(b, e); } else return ""; } /** * Returns a comment including the node class name and a suffix. * * @param n the node to process * @param str the string to add to the comment * @return the comment */ private String nodeClassComment(final INode n, final String str) { if (Globals.PRINT_CLASS_COMMENT) return nodeClassComment(n) + " " + str; else return ""; } /* * User grammar generated and overridden visit methods below */ /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit */ @Override public void visit(final CompilationUnit n) { // we do not use out.print(spc.spc) as indent level should be 0 at this point if (n.f0.present()) { // package n.f0.accept(this); oneNewLine(n); } if (n.f1.present()) { // import for (final Iterator e = n.f1.elements(); e.hasNext();) { e.next().accept(this); oneNewLine(n); } oneNewLine(n); } if (n.f2.present()) { // type for (final Iterator e = n.f2.elements(); e.hasNext();) { e.next().accept(this); oneNewLine(n); } oneNewLine(n); } } /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit */ @Override public void visit(final PackageDeclaration n) { // f0 -> ( Annotation() )* if (n.f0.present()) { for (final Iterator e = n.f0.elements(); e.hasNext();) { ((NodeSequence) e.next()).elementAt(0).accept(this); if (e.hasNext()) sb.append(" "); } } // f1 -> "package" n.f1.accept(this); sb.append(" "); // f2 -> Name(null) n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit */ @Override public void visit(final ImportDeclaration n) { // f0 -> "import" n.f0.accept(this); sb.append(" "); // f1 -> [ "static" ] if (n.f1.present()) { n.f1.accept(this); sb.append(" "); } // f2 -> Name(null) n.f2.accept(this); // f3 -> [ "." "*" ] if (n.f3.present()) n.f3.accept(this); // f4 -> ";" n.f4.accept(this); } /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
*/ @Override public void visit(final Modifiers n) { if (n.f0.present()) { for (final Iterator e = n.f0.elements(); e.hasNext();) { e.next().accept(this); // Modifiers print the last space if not empty sb.append(" "); } } } /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit */ @Override public void visit(final TypeDeclaration n) { if (n.f0.which == 0) { // ";" n.f0.choice.accept(this); } else { final NodeSequence seq = (NodeSequence) n.f0.choice; // Modifiers() seq.elementAt(0).accept(this); // Modifiers print the last space if not empty // ( ClassOrInterfaceDeclaration() | EnumDeclaration() | AnnotationTypeDeclaration() ) seq.elementAt(1).accept(this); } } /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit */ @Override public void visit(final ClassOrInterfaceDeclaration n) { // f0 -> ( "class" | "interface" ) n.f0.accept(this); sb.append(" "); // f1 -> < IDENTIFIER > n.f1.accept(this); sb.append(" "); // f2 -> [ TypeParameters() ] if (n.f2.present()) { n.f2.accept(this); sb.append(" "); } // f3 -> [ ExtendsList(isInterface) ] if (n.f3.present()) { n.f3.accept(this); sb.append(" "); } // f4 -> [ ImplementsList(isInterface) ] if (n.f4.present()) { n.f4.accept(this); sb.append(" "); } // f5 -> ClassOrInterfaceBody(isInterface,null) n.f5.accept(this); } /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ @Override public void visit(final ExtendsList n) { // f0 -> "extends" n.f0.accept(this); sb.append(" "); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( "&" ClassOrInterfaceType() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { sb.append(" "); final NodeSequence seq = (NodeSequence) e.next(); // "&" seq.elementAt(0).accept(this); sb.append(" "); // ClassOrInterfaceType() seq.elementAt(1).accept(this); } } } /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ @Override public void visit(final ImplementsList n) { // f0 -> "implements" n.f0.accept(this); sb.append(" "); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( "&" ClassOrInterfaceType() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { sb.append(" "); final NodeSequence seq = (NodeSequence) e.next(); // "&" seq.elementAt(0).accept(this); sb.append(" "); // ClassOrInterfaceType() seq.elementAt(1).accept(this); } } } /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit */ @Override public void visit(final EnumDeclaration n) { // f0 -> "enum" n.f0.accept(this); sb.append(" "); // f1 -> < IDENTIFIER > n.f1.accept(this); sb.append(" "); // f2 -> [ ImplementsList(false) ] if (n.f2.present()) { n.f2.accept(this); sb.append(" "); } // f3 -> EnumBody() n.f3.accept(this); } /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit */ @Override public void visit(final EnumBody n) { // f0 -> "{" n.f0.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f1 -> [ EnumConstant() ( "," EnumConstant() )* ] if (n.f1.present()) { final NodeSequence seq = (NodeSequence) n.f1.node; // EnumConstant() seq.elementAt(0).accept(this); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(1); if (nlo.present()) { for (final Iterator e = nlo.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "," seq1.elementAt(0).accept(this); sb.append(" "); // EnumConstant() seq1.elementAt(1).accept(this); } } } // f2 -> [ "," ] if (n.f2.present()) { n.f2.accept(this); sb.append(" "); } // f3 -> [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] if (n.f3.present()) { // ";" ((NodeSequence) n.f3.node).elementAt(0).accept(this); oneNewLine(n); sb.append(spc.spc); final NodeListOptional nlo = (NodeListOptional) ((NodeSequence) n.f3.node).elementAt(1); if (nlo.present()) { for (final Iterator e = nlo.elements(); e.hasNext();) { // ClassOrInterfaceBodyDeclaration(false) e.next().accept(this); } } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); // f4 -> "}" n.f4.accept(this); } /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit */ @Override public void visit(final EnumConstant n) { // f0 -> Modifiers() n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ Arguments(null) ] if (n.f2.present()) n.f2.accept(this); // f3 -> [ ClassOrInterfaceBody(false, null) ] if (n.f3.present()) n.f3.accept(this); } /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit */ @Override public void visit(final TypeParameters n) { // f0 -> "<" n.f0.accept(this); // f1 -> TypeParameter() n.f1.accept(this); // f2 -> ( "," TypeParameter() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // TypeParameter() seq.elementAt(1).accept(this); } } // f3 -> ">" n.f3.accept(this); } /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit */ @Override public void visit(final TypeParameter n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeBound() ] if (n.f1.present()) { n.f1.accept(this); } } /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ @Override public void visit(final TypeBound n) { // f0 -> "extends" n.f0.accept(this); sb.append(" "); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( "&" ClassOrInterfaceType() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { sb.append(" "); final NodeSequence seq = (NodeSequence) e.next(); // "&" seq.elementAt(0).accept(this); sb.append(" "); // ClassOrInterfaceType() seq.elementAt(1).accept(this); } } } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final ClassOrInterfaceBody n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( ClassOrInterfaceBodyDeclaration(isInterface) )* if (n.f1.present()) { oneNewLine(n, "a"); spc.updateSpc(+1); oneNewLine(n, "b"); sb.append(spc.spc); for (final Iterator e = n.f1.elements(); e.hasNext();) { e.next().accept(this); oneNewLine(n, "c"); if (e.hasNext()) { oneNewLine(n, "d"); sb.append(spc.spc); } } spc.updateSpc(-1); } sb.append(spc.spc); // f2 -> "}" n.f2.accept(this); oneNewLine(n, "e"); } /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
*/ @Override public void visit(final ClassOrInterfaceBodyDeclaration n) { if (n.f0.which != 1) { // Initializer() or ";" n.f0.choice.accept(this); } else { final NodeSequence seq = (NodeSequence) n.f0.choice; // Modifiers print the last space if not empty seq.elementAt(0).accept(this); // ClassOrInterfaceDeclaration() | EnumDeclaration() | ConstructorDeclaration() | FieldDeclaration() | MethodDeclaration() ((NodeChoice) seq.elementAt(1)).accept(this); } } /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit */ @Override public void visit(final FieldDeclaration n) { // f0 -> Type() n.f0.accept(this); sb.append(" "); // f1 -> VariableDeclarator() n.f1.accept(this); // f2 -> ( "," VariableDeclarator() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { // "," final NodeSequence seq = (NodeSequence) e.next(); seq.elementAt(0).accept(this); sb.append(" "); // VariableDeclarator() seq.elementAt(1).accept(this); } } // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit */ @Override public void visit(final VariableDeclarator n) { // f0 -> VariableDeclaratorId() n.f0.accept(this); // f1 -> [ "=" VariableInitializer() ] if (n.f1.present()) { sb.append(" "); // VariableInitializer() ((NodeSequence) n.f1.node).elementAt(0).accept(this); sb.append(" "); ((NodeSequence) n.f1.node).elementAt(1).accept(this); } } /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ @Override public void visit(final VariableDeclaratorId n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ( "[" "]" )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "[" "]" seq.elementAt(0).accept(this); seq.elementAt(1).accept(this); } } } /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit */ @Override public void visit(final VariableInitializer n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit */ @Override public void visit(final ArrayInitializer n) { // f0 -> "{" n.f0.accept(this); sb.append(" "); // f1 -> [ VariableInitializer() ( "," VariableInitializer() )* ] n.f1.accept(this); // f2 -> [ "," ] if (n.f2.present()) { n.f2.accept(this); sb.append(" "); } sb.append(" "); // f3 -> "}" n.f3.accept(this); } /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit */ @Override public void visit(final MethodDeclaration n) { // f0 -> [ TypeParameters() ] if (n.f0.present()) { n.f0.accept(this); sb.append(" "); } // f1 -> ResultType(null) n.f1.accept(this); sb.append(" "); // f2 -> MethodDeclarator() n.f2.accept(this); sb.append(" "); // f3 -> [ "throws" NameList() ] if (n.f3.present()) { // "throws" ((NodeSequence) n.f3.node).elementAt(0).accept(this); sb.append(" "); // NameList() ((NodeSequence) n.f3.node).elementAt(1).accept(this); } // f4 -> ( Block(null) | ";" ) n.f4.accept(this); } /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ @Override public void visit(final MethodDeclarator n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> FormalParameters(null) n.f1.accept(this); // f2 -> ( "[" "]" )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { // "[" "]" ((NodeSequence) e).elementAt(0).accept(this); ((NodeSequence) e).elementAt(1).accept(this); } } } /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit */ @Override public void visit(final FormalParameters n) { // f0 -> "(" n.f0.accept(this); // f1 -> [ FormalParameter() ( "," FormalParameter() )* ] if (n.f1.present()) { final NodeSequence seq = (NodeSequence) n.f1.node; seq.elementAt(0).accept(this); for (final Iterator e = ((NodeListOptional) seq.elementAt(1)).elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "," seq1.elementAt(0).accept(this); sb.append(" "); // FormalParameter() seq1.elementAt(1).accept(this); } } // f2 -> ")" n.f2.accept(this); } /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit */ @Override public void visit(final FormalParameter n) { // f0 -> Modifiers() n.f0.accept(this); // Modifiers print the last space if not empty // f1 -> Type() n.f1.accept(this); // f2 -> [ "..." ] if (n.f2.present()) n.f2.accept(this); sb.append(" "); // f3 -> VariableDeclaratorId() n.f3.accept(this); } /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(final ConstructorDeclaration n) { // f0 -> [ TypeParameters() ] if (n.f0.present()) { n.f0.accept(this); sb.append(" "); } // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> FormalParameters(null) n.f2.accept(this); sb.append(" "); // f3 -> [ "throws" NameList() ] if (n.f3.present()) { // "throws" ((NodeSequence) n.f3.node).elementAt(0).accept(this); sb.append(" "); // NameList() ((NodeSequence) n.f3.node).elementAt(1).accept(this); } sb.append(" "); // f4 -> "{" n.f4.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f5 -> [ ExplicitConstructorInvocation() ] if (n.f5.present()) { n.f5.accept(this); oneNewLine(n); sb.append(spc.spc); } // f6 -> ( BlockStatement() )* if (n.f6.present()) { for (final Iterator e = n.f6.elements(); e.hasNext();) { e.next().accept(this); if (e.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); // f7 -> "}" n.f7.accept(this); } /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit */ @Override public void visit(final ExplicitConstructorInvocation n) { final NodeSequence seq = (NodeSequence) n.f0.choice; if (n.f0.which == 0) { // "this" Arguments(null) ";" seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); seq.elementAt(2).accept(this); } else { // [ PrimaryExpression() "." ] "super" Arguments(null) ";" final NodeOptional opt = (NodeOptional) seq.elementAt(0); if (opt.present()) { // PrimaryExpression() ((NodeSequence) opt.node).elementAt(0).accept(this); // "." ((NodeSequence) opt.node).elementAt(1).accept(this); } // "super" seq.elementAt(1).accept(this); // Arguments(null) seq.elementAt(2).accept(this); // ";" seq.elementAt(3).accept(this); } } /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit */ @Override public void visit(final Initializer n) { // f0 -> [ "static" ] if (n.f0.present()) { n.f0.accept(this); sb.append(" "); } // f1 -> Block(null) n.f1.accept(this); } /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit */ @Override public void visit(final Type n) { n.f0.accept(this); } /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit */ @Override public void visit(final ReferenceType n) { final NodeSequence seq = (NodeSequence) n.f0.choice; if (n.f0.which == 0) { // PrimitiveType() ( "[" "]" )+ seq.elementAt(0).accept(this); final NodeList nl = (NodeList) seq.elementAt(1); for (final Iterator e = nl.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "[" seq1.elementAt(0).accept(this); // "]" seq1.elementAt(1).accept(this); } } else { // ClassOrInterfaceType() ( "[" "]" )* seq.elementAt(0).accept(this); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(1); if (nlo.present()) for (final Iterator e = nlo.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "[" seq1.elementAt(0).accept(this); // "]" seq1.elementAt(1).accept(this); } } } /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit */ @Override public void visit(final ClassOrInterfaceType n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeArguments() ] if (n.f1.present()) n.f1.accept(this); // f2 -> ( "." < IDENTIFIER > [ TypeArguments() ] )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "." seq.elementAt(0).accept(this); // < IDENTIFIER > seq.elementAt(1).accept(this); // TypeArguments() seq.elementAt(2).accept(this); } } } /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit */ @Override public void visit(final TypeArguments n) { // f0 -> "<" n.f0.accept(this); // f1 -> TypeArgument() n.f1.accept(this); // f2 -> ( "," TypeArgument() )* if (n.f2.present()) { sb.append(" "); for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // TypeArgument() seq.elementAt(1).accept(this); } } // f3 -> ">" n.f3.accept(this); } /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit */ @Override public void visit(final TypeArgument n) { if (n.f0.which == 0) { // ReferenceType() n.f0.choice.accept(this); } else { // "?" [ WildcardBounds() ] final NodeSequence seq = (NodeSequence) n.f0.choice; // "?" seq.elementAt(0).accept(this); // [ WildcardBounds() ] final NodeOptional opt = (NodeOptional) seq.elementAt(1); if (opt.present()) { sb.append(" "); opt.node.accept(this); } } } /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit */ @Override public void visit(final WildcardBounds n) { final NodeSequence seq = (NodeSequence) n.f0.choice; // "extends" or "super" seq.elementAt(0).accept(this); sb.append(" "); // ReferenceType() seq.elementAt(1).accept(this); } /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit */ @Override public void visit(final PrimitiveType n) { // no difference with superclass n.f0.accept(this); } /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit */ @Override public void visit(final ResultType n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit */ @Override public void visit(final Name n) { // f0 -> JavaIdentifier() n.f0.accept(this); // f1 -> ( "." JavaIdentifier() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); seq.elementAt(0).accept(this); seq.elementAt(1).accept(this); } } } /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit */ @Override public void visit(final NameList n) { // f0 -> Name(null) n.f0.accept(this); // f1 -> ( "," Name(null) )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { // "," final NodeSequence seq = (NodeSequence) e.next(); seq.elementAt(0).accept(this); sb.append(" "); // Name(null) seq.elementAt(1).accept(this); } } } /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit */ @Override public void visit(final Expression n) { // f0 -> ConditionalExpression() n.f0.accept(this); // f1 -> [ AssignmentOperator() Expression(null) ] if (n.f1.present()) { final NodeSequence seq = (NodeSequence) n.f1.node; sb.append(" "); seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); } } /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit */ @Override public void visit(final AssignmentOperator n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit */ @Override public void visit(final ConditionalExpression n) { // f0 -> ConditionalOrExpression() n.f0.accept(this); // f1 -> [ "?" Expression(null) ":" Expression(null) ] if (n.f1.present()) { final NodeSequence seq = (NodeSequence) n.f1.node; sb.append(" "); // "?" seq.elementAt(0).accept(this); sb.append(" "); // Expression(null) seq.elementAt(1).accept(this); sb.append(" "); // ":" seq.elementAt(2).accept(this); sb.append(" "); // Expression(null) seq.elementAt(3).accept(this); } } /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit */ @Override public void visit(final ConditionalOrExpression n) { // f0 -> ConditionalAndExpression() n.f0.accept(this); // f1 -> ( "||" ConditionalAndExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "||" seq.elementAt(0).accept(this); sb.append(" "); // ConditionalAndExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit */ @Override public void visit(final ConditionalAndExpression n) { // f0 -> InclusiveOrExpression() n.f0.accept(this); // f1 -> ( "&&" InclusiveOrExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "&&" seq.elementAt(0).accept(this); sb.append(" "); // InclusiveOrExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit */ @Override public void visit(final InclusiveOrExpression n) { // f0 -> ExclusiveOrExpression() n.f0.accept(this); // f1 -> ( "|" ExclusiveOrExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "|" seq.elementAt(0).accept(this); sb.append(" "); // ExclusiveOrExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit */ @Override public void visit(final ExclusiveOrExpression n) { // f0 -> AndExpression() n.f0.accept(this); // f1 -> ( "^" AndExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "^" seq.elementAt(0).accept(this); sb.append(" "); // AndExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit */ @Override public void visit(final AndExpression n) { // f0 -> EqualityExpression() n.f0.accept(this); // f1 -> ( "&" EqualityExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "&" seq.elementAt(0).accept(this); sb.append(" "); // EqualityExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit */ @Override public void visit(final EqualityExpression n) { // f0 -> InstanceOfExpression() n.f0.accept(this); // f1 -> ( ( "==" | "!=" ) InstanceOfExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "==" | "!=" seq.elementAt(0).accept(this); sb.append(" "); // InstanceOfExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit */ @Override public void visit(final InstanceOfExpression n) { // f0 -> RelationalExpression() n.f0.accept(this); // f1 -> [ "instanceof" Type() ] if (n.f1.present()) { sb.append(" "); // "instanceof" ((NodeSequence) n.f1.node).elementAt(0).accept(this); sb.append(" "); // Type() ((NodeSequence) n.f1.node).elementAt(1).accept(this); } } /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit */ @Override public void visit(final RelationalExpression n) { // f0 -> ShiftExpression() n.f0.accept(this); // f1 -> ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "<" | ">" | "<=" | ">=" seq.elementAt(0).accept(this); sb.append(" "); // ShiftExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit */ @Override public void visit(final ShiftExpression n) { // f0 -> AdditiveExpression() n.f0.accept(this); // f1 -> ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() seq.elementAt(0).accept(this); sb.append(" "); // AdditiveExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit */ @Override public void visit(final AdditiveExpression n) { // f0 -> MultiplicativeExpression() n.f0.accept(this); // f1 -> ( ( "+" | "-" ) MultiplicativeExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "+" | "-" seq.elementAt(0).accept(this); sb.append(" "); // MultiplicativeExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit */ @Override public void visit(final MultiplicativeExpression n) { // f0 -> UnaryExpression() n.f0.accept(this); // f1 -> ( ( "*" | "/" | "%" ) UnaryExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); sb.append(" "); // "*" | "/" | "%" seq.elementAt(0).accept(this); sb.append(" "); // UnaryExpression() seq.elementAt(1).accept(this); } } } /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ @Override public void visit(final UnaryExpression n) { if (n.f0.which == 0) { // ( "+" | "-" ) UnaryExpression() final NodeSequence seq = (NodeSequence) n.f0.choice; // "+" | "-" seq.elementAt(0).accept(this); // UnaryExpression() seq.elementAt(1).accept(this); } else // others n.f0.accept(this); } /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ @Override public void visit(final PreIncrementExpression n) { // f0 -> "++" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); } /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ @Override public void visit(final PreDecrementExpression n) { // f0 -> "--" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); } /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit */ @Override public void visit(final UnaryExpressionNotPlusMinus n) { if (n.f0.which == 0) { // ( "~" | "!" ) UnaryExpression() final NodeSequence seq = (NodeSequence) n.f0.choice; // "~" | "!" seq.elementAt(0).accept(this); // UnaryExpression() seq.elementAt(1).accept(this); } else // others n.f0.accept(this); } /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit */ @Override public void visit(@SuppressWarnings("unused") final CastLookahead n) { sb.append("/* !!! CastLookahead visited but should not !!! */"); } /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit */ @Override public void visit(final PostfixExpression n) { // f0 -> PrimaryExpression() n.f0.accept(this); // f1 -> [ "++" | "--" ] n.f1.accept(this); } /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ @Override public void visit(final CastExpression n) { final NodeSequence seq = (NodeSequence) n.f0.choice; // "(" seq.elementAt(0).accept(this); // Type() seq.elementAt(1).accept(this); // ")" seq.elementAt(2).accept(this); // UnaryExpression() or UnaryExpressionNotPlusMinus() seq.elementAt(3).accept(this); } /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit */ @Override public void visit(final PrimaryExpression n) { // f0 -> PrimaryPrefix() n.f0.accept(this); // f1 -> ( PrimarySuffix() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { e.next().accept(this); } } } /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final MemberSelector n) { // f0 -> "." n.f0.accept(this); // f1 -> TypeArguments() n.f1.accept(this); // f2 -> < IDENTIFIER > n.f2.accept(this); } /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit */ @Override public void visit(final PrimaryPrefix n) { if (n.f0.which == 2 || n.f0.which == 3 || n.f0.which == 5) { // "super" or "(" or ResultType(null) (((NodeSequence) n.f0.choice).elementAt(0)).accept(this); // "." or Expression(null or "." (((NodeSequence) n.f0.choice).elementAt(1)).accept(this); // < IDENTIFIER > or ")" or "class" (((NodeSequence) n.f0.choice).elementAt(2)).accept(this); } else // Literal() or "this" or AllocationExpression() or Name(null) n.f0.choice.accept(this); } /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit */ @Override public void visit(final PrimarySuffix n) { // n.f0.accept(this); if (n.f0.which == 0 || n.f0.which == 1 || n.f0.which == 4) { // "." ((NodeSequence) n.f0.choice).elementAt(0).accept(this); // "this" or AllocationExpression() or < IDENTIFIER > ((NodeSequence) n.f0.choice).elementAt(1).accept(this); } else if (n.f0.which == 3) { // "[" ((NodeSequence) n.f0.choice).elementAt(0).accept(this); // Expression(null) ((NodeSequence) n.f0.choice).elementAt(1).accept(this); // "]" ((NodeSequence) n.f0.choice).elementAt(2).accept(this); } else // MemberSelector() n.f0.accept(this); } /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit */ @Override public void visit(final Literal n) { if (n.f0.which <= 3) { sb .append(UnicodeConverter.addUnicodeEscapes(((NodeToken) n.f0.choice).withSpecials(spc.spc))); } else { // BooleanLiteral() or NullLiteral() n.f0.choice.accept(this); } } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit */ @Override public void visit(final IntegerLiteral n) { sb.append(n.f0.withSpecials(spc.spc)); } /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit */ @Override public void visit(final BooleanLiteral n) { sb.append(((NodeToken) n.f0.choice).withSpecials(spc.spc)); } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { sb.append(n.f0.withSpecials(spc.spc)); } /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit */ @Override public void visit(final NullLiteral n) { sb.append(n.f0.withSpecials(spc.spc)); } /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit */ @Override public void visit(final Arguments n) { // f0 -> "(" n.f0.accept(this); // f1 -> [ ArgumentList() ] if (n.f1.present()) n.f1.accept(this); // f2 -> ")" n.f2.accept(this); } /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit */ @Override public void visit(final ArgumentList n) { // f0 -> Expression(null) n.f0.accept(this); // f1 -> ( "," Expression(null) )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // Expression(null) seq.elementAt(1).accept(this); } } } /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit */ @Override public void visit(final AllocationExpression n) { final NodeSequence seq = (NodeSequence) n.f0.choice; if (n.f0.which == 0) { // "new" PrimitiveType() ArrayDimsAndInits() seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); seq.elementAt(2).accept(this); } else { // "new" ClassOrInterfaceType() [ TypeArguments() ] ( ArrayDimsAndInits() | Arguments(null) [ ClassOrInterfaceBody(false,null) ] ) seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); // TypeArguments() if (((NodeOptional) seq.elementAt(2)).present()) { seq.elementAt(2).accept(this); } // ( ArrayDimsAndInits() | Arguments(null) [ ClassOrInterfaceBody(false,null) ] ) final NodeChoice ch = (NodeChoice) seq.elementAt(3); if (ch.which == 0) { // ArrayDimsAndInits() ch.choice.accept(this); } else { final NodeSequence seq1 = (NodeSequence) ch.choice; // Arguments(null) seq1.elementAt(0).accept(this); if (((NodeOptional) seq1.elementAt(1)).present()) // ClassOrInterfaceBody(false,null) seq1.elementAt(1).accept(this); } } } /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit */ @Override public void visit(final ArrayDimsAndInits n) { final NodeSequence seq = (NodeSequence) n.f0.choice; if (n.f0.which == 0) { // ( "[" Expression(null) "]" )+ ( "[" "]" )* final NodeList nl1 = (NodeList) seq.elementAt(0); for (final Iterator e = nl1.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "[" seq1.elementAt(0).accept(this); // Expression(null) seq1.elementAt(1).accept(this); // "]" seq1.elementAt(2).accept(this); } final NodeListOptional nlo2 = (NodeListOptional) seq.elementAt(1); if (nlo2.present()) { for (final Iterator e = nlo2.elements(); e.hasNext();) { final NodeSequence seq2 = (NodeSequence) e.next(); // "[" seq2.elementAt(0).accept(this); // "]" seq2.elementAt(1).accept(this); } } } else { // ( "[" "]" )+ ArrayInitializer() final NodeList nl3 = (NodeList) seq.elementAt(0); for (final Iterator e = nl3.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "[" seq1.elementAt(0).accept(this); // "]" seq1.elementAt(1).accept(this); } // ArrayInitializer() seq.elementAt(1).accept(this); } } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit */ @Override public void visit(final Statement n) { if (n.f0.which == 4) { // StatementExpression() ";" ((NodeSequence) n.f0.choice).elementAt(0).accept(this); ((NodeSequence) n.f0.choice).elementAt(1).accept(this); } else { // others n.f0.choice.accept(this); } } /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit */ @Override public void visit(final AssertStatement n) { // f0 -> "assert" n.f0.accept(this); sb.append(" "); // f1 -> Expression(null) n.f1.accept(this); sb.append(" "); // f2 -> [ ":" Expression(null) ] if (n.f2.present()) { final NodeSequence seq = (NodeSequence) n.f2.node; seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); } // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit */ @Override public void visit(final LabeledStatement n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ":" n.f1.accept(this); oneNewLine(n); sb.append(spc.spc); // f2 -> Statement() n.f2.accept(this); } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final Block n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( BlockStatement() )* if (n.f1.present()) { spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); for (final Iterator e = n.f1.elements(); e.hasNext();) { // BlockStatement() e.next().accept(this); if (e.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } // f2 -> "}" n.f2.accept(this); } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit */ @Override public void visit(final BlockStatement n) { if (n.f0.which == 0) { // LocalVariableDeclaration() ";" ((NodeSequence) n.f0.choice).elementAt(0).accept(this); ((NodeSequence) n.f0.choice).elementAt(1).accept(this); } else { // others n.f0.choice.accept(this); } } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit */ @Override public void visit(final LocalVariableDeclaration n) { // f0 -> Modifiers() n.f0.accept(this); // Modifiers print the last space if not empty // f1 -> Type() n.f1.accept(this); sb.append(" "); // f2 -> VariableDeclarator() n.f2.accept(this); // f3 -> ( "," VariableDeclarator() )* if (n.f3.present()) { for (final Iterator e = n.f3.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // VariableDeclarator() seq.elementAt(1).accept(this); } } } /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit */ @Override public void visit(final EmptyStatement n) { // no difference with superclass n.f0.accept(this); } /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit */ @Override public void visit(final StatementExpression n) { if (n.f0.which < 2) // PreIncrementExpression() or PreDecrementExpression() n.f0.accept(this); else { // PrimaryExpression() [ "++" | "--" | AssignmentOperator() Expression(null) ] // PrimaryExpression() ((NodeSequence) n.f0.choice).elementAt(0).accept(this); final NodeOptional opt = (NodeOptional) ((NodeSequence) n.f0.choice).elementAt(1); if (opt.present()) { // "++" | "--" | AssignmentOperator() Expression(null) final NodeChoice ch = (NodeChoice) opt.node; if (ch.which <= 1) // "++" | "--" ch.choice.accept(this); else { final NodeSequence seq1 = (NodeSequence) ch.choice; sb.append(" "); // AssignmentOperator() seq1.elementAt(0).accept(this); sb.append(" "); // Expression(null) seq1.elementAt(1).accept(this); } } } } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit */ @Override public void visit(final SwitchStatement n) { // f0 -> "switch" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); sb.append(" "); // f4 -> "{" n.f4.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // ( SwitchLabel() ( BlockStatement() )* )* for (final Iterator e = n.f5.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // SwitchLabel() seq.elementAt(0).accept(this); spc.updateSpc(+1); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(1); if ((nlo).present()) { if (nlo.size() == 1) sb.append(" "); else { oneNewLine(n); sb.append(spc.spc); } for (final Iterator e1 = nlo.elements(); e1.hasNext();) { // BlockStatement() e1.next().accept(this); if (e1.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } } oneNewLine(n); spc.updateSpc(-1); } spc.updateSpc(-1); sb.append(spc.spc); // f6 -> "}" n.f6.accept(this); oneNewLine(n); } /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit */ @Override public void visit(final SwitchLabel n) { final NodeSequence seq = (NodeSequence) n.f0.choice; if (n.f0.which == 0) { // "case" Expression(null) ":" seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); sb.append(" "); seq.elementAt(2).accept(this); } else { // "default" ":" seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); } } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit */ @Override public void visit(final IfStatement n) { // f0 -> "if" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() if (n.f4.f0.which != 2) { // if Statement() not a Block spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); } else { // if Statement() is a Block sb.append(" "); } n.f4.accept(this); if (n.f4.f0.which != 2) // if Statement() not a Block spc.updateSpc(-1); // f5 -> [ #0 "else" #1 Statement() ] if (n.f5.present()) { if (n.f4.f0.which != 2) { // if Statement() not a Block oneNewLine(n); sb.append(spc.spc); } else { // if Statement() is a Block sb.append(" "); } // "else" ((NodeSequence) n.f5.node).elementAt(0).accept(this); // Statement() final Statement st = (Statement) ((NodeSequence) n.f5.node).elementAt(1); if (st.f0.which != 2) { // else Statement() is not a Block() spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // Statement() st.f0.choice.accept(this); spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } else { // else Statement() is a Block() sb.append(" "); // Statement() st.f0.choice.accept(this); } } } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ @Override public void visit(final WhileStatement n) { // f0 -> "while" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() genStatement(n.f4); } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit */ @Override public void visit(final DoStatement n) { // f0 -> "do" n.f0.accept(this); // f1 -> Statement() genStatement(n.f1); // f2 -> "while" n.f2.accept(this); sb.append(" "); // f3 -> "(" n.f3.accept(this); // f4 -> Expression(null) n.f4.accept(this); // f5 -> ")" n.f5.accept(this); // f6 -> ";" n.f6.accept(this); } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ @Override public void visit(final ForStatement n) { // f0 -> "for" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> ( Modifiers() Type() < IDENTIFIER > ":" Expression(null) | [ ForInit() ] ";" [ Expression(null) ] ";" [ ForUpdate() ] ) final NodeSequence seq = (NodeSequence) n.f2.choice; if (n.f2.which == 0) { // Modifiers() Type() < IDENTIFIER > ":" Expression(null) seq.elementAt(0).accept(this); // Modifiers print the last space if not empty // Type() seq.elementAt(1).accept(this); sb.append(" "); // < IDENTIFIER > seq.elementAt(2).accept(this); sb.append(" "); // Expression(null) seq.elementAt(3).accept(this); } else { NodeOptional opt; // [ ForInit() ] ";" [ Expression(null) ] ";" [ ForUpdate() ] ) // [ ForInit() ] opt = (NodeOptional) seq.elementAt(0); if (opt.present()) opt.node.accept(this); // ";" seq.elementAt(1).accept(this); sb.append(" "); // [ Expression(null) ] opt = (NodeOptional) seq.elementAt(2); if (opt.present()) opt.node.accept(this); // ";" seq.elementAt(3).accept(this); sb.append(" "); // [ ForUpdate() ] opt = (NodeOptional) seq.elementAt(4); if (opt.present()) opt.node.accept(this); } // f3 -> ")" n.f3.accept(this); // f4 -> Statement() genStatement(n.f4); } /** * Generates the source code corresponding to a Statement. * * @param n the Statement node */ void genStatement(final Statement n) { if (n.f0.which != 2) { // case Statement is not a Block spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // Statement() n.accept(this); spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } else { // case Statement is a Block sb.append(" "); // Statement() n.accept(this); sb.append(" "); } } /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit */ @Override public void visit(final ForInit n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit */ @Override public void visit(final StatementExpressionList n) { // f0 -> StatementExpression() n.f0.accept(this); // f1 -> ( "," StatementExpression() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { // "," ((NodeSequence) e.next()).elementAt(0).accept(this); sb.append(" "); // StatementExpression() ((NodeSequence) e).elementAt(1).accept(this); } } } /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit */ @Override public void visit(final ForUpdate n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ @Override public void visit(final BreakStatement n) { // f0 -> "break" n.f0.accept(this); if (n.f1.present()) { sb.append(" "); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); } // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ @Override public void visit(final ContinueStatement n) { // f0 -> "continue" n.f0.accept(this); if (n.f1.present()) { sb.append(" "); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); } // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit */ @Override public void visit(final ReturnStatement n) { // f0 -> "return" n.f0.accept(this); if (n.f1.present()) { sb.append(" "); // f1 -> [ Expression(null) ] n.f1.accept(this); } // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit */ @Override public void visit(final ThrowStatement n) { // f0 -> "throw" n.f0.accept(this); sb.append(" "); // f1 -> Expression(null) n.f1.accept(this); // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit */ @Override public void visit(final SynchronizedStatement n) { // f0 -> "synchronized" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f4 -> Block(null) n.f4.accept(this); spc.updateSpc(-1); } /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final TryStatement n) { // f0 -> "try" n.f0.accept(this); sb.append(" "); // f1 -> Block(null) n.f1.accept(this); // f2 -> ( "catch" "(" FormalParameter() ")" Block(null) )* for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); oneNewLine(n); sb.append(spc.spc); // "catch" seq.elementAt(0).accept(this); sb.append(" "); // "(" seq.elementAt(1).accept(this); // FormalParameter() seq.elementAt(2).accept(this); // ")" seq.elementAt(3).accept(this); sb.append(" "); // Block(null) seq.elementAt(4).accept(this); } // f3 -> [ "finally" Block(null) ] if (n.f3.present()) { final NodeSequence seq = (NodeSequence) n.f3.node; oneNewLine(n); sb.append(spc.spc); // "finally" seq.elementAt(0).accept(this); sb.append(" "); // Block(null seq.elementAt(1).accept(this); } } /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit */ @Override public void visit(final RUNSIGNEDSHIFT n) { // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); // f2 -> ">" n.f2.accept(this); } /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit */ @Override public void visit(final RSIGNEDSHIFT n) { // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); } /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit */ @Override public void visit(final Annotation n) { // no difference with superclass n.f0.accept(this); } /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit */ @Override public void visit(final NormalAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name(null) n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> [ MemberValuePairs() ] if (n.f3.present()) n.f3.node.accept(this); // f4 -> ")" n.f4.accept(this); } /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit */ @Override public void visit(final MarkerAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name(null) n.f1.accept(this); } /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit */ @Override public void visit(final SingleMemberAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name(null) n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> MemberValue() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); } /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit */ @Override public void visit(final MemberValuePairs n) { // f0 -> MemberValuePair() n.f0.accept(this); // f1 -> ( "," MemberValuePair() )* if (n.f1.present()) { for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // MemberValuePair() seq.elementAt(1).accept(this); } } } /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit */ @Override public void visit(final MemberValuePair n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> "=" sb.append(" "); n.f1.accept(this); sb.append(" "); // f2 -> MemberValue() n.f2.accept(this); } /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit */ @Override public void visit(final MemberValue n) { n.f0.choice.accept(this); } /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit */ @Override public void visit(final MemberValueArrayInitializer n) { // f0 -> "{" n.f0.accept(this); sb.append(" "); // f1 -> MemberValue() n.f1.accept(this); // f2 -> ( "," MemberValue() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "," seq.elementAt(0).accept(this); sb.append(" "); // MemberValuePair() seq.elementAt(1).accept(this); } } // f3 -> [ "," ] if (n.f3.present()) n.f3.node.accept(this); // f4 -> "}" sb.append(" "); n.f4.accept(this); } /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit */ @Override public void visit(final AnnotationTypeDeclaration n) { // f0 -> "@" n.f0.accept(this); // f1 -> "interface" n.f1.accept(this); sb.append(" "); // f2 -> < IDENTIFIER > n.f2.accept(this); sb.append(" "); // f3 -> AnnotationTypeBody() n.f3.accept(this); } /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final AnnotationTypeBody n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( AnnotationTypeMemberDeclaration() )* if (n.f1.present()) { oneNewLine(n, "a"); spc.updateSpc(+1); oneNewLine(n, "b"); sb.append(spc.spc); for (final Iterator e = n.f1.elements(); e.hasNext();) { e.next().accept(this); oneNewLine(n, "c"); if (e.hasNext()) { oneNewLine(n, "d"); sb.append(spc.spc); } } spc.updateSpc(-1); } sb.append(spc.spc); // f2 -> "}" n.f2.accept(this); oneNewLine(n, "e"); } /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit */ @Override public void visit(final AnnotationTypeMemberDeclaration n) { if (n.f0.which == 0) { final NodeSequence seq = (NodeSequence) n.f0.choice; // Modifiers print the last space if not empty seq.elementAt(0).accept(this); // ( Type() < IDENTIFIER > "(" ")" [ DefaultValue() ] ";" | ClassOrInterfaceDeclaration() | EnumDeclaration() | AnnotationTypeDeclaration() | FieldDeclaration() ) final NodeChoice ch = (NodeChoice) seq.elementAt(1); if (ch.which == 0) { // Type() < IDENTIFIER > "(" ")" [ DefaultValue() ] ";" final NodeSequence seq1 = (NodeSequence) ch.choice; // Type() seq1.elementAt(0).accept(this); sb.append(" "); // < IDENTIFIER > seq1.elementAt(1).accept(this); // "(" seq1.elementAt(2).accept(this); // ")" seq1.elementAt(3).accept(this); // [ DefaultValue() ] final NodeOptional opt = (NodeOptional) seq1.elementAt(3); if (opt.present()) { sb.append(" "); opt.node.accept(this); } // ";" seq1.elementAt(5).accept(this); } else { // ClassOrInterfaceDeclaration() or EnumDeclaration() or AnnotationTypeDeclaration() or FieldDeclaration() ch.choice.accept(this); } } else { // ";" n.f0.choice.accept(this); } } /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit */ @Override public void visit(final DefaultValue n) { // f0 -> "default" n.f0.accept(this); // f1 -> MemberValue() n.f1.accept(this); } } jtb-1.4.4/EDU/purdue/jtb/visitor/DepthFirstRetArguVisitor.java0000644000175000017500000027735511416555700024136 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; import java.util.*; /** * Provides default methods which visit each node in the tree in depth-first order.
* In your "RetArgu" visitors extend this class and override part or all of these methods. * * @param The user return information type * @param
The user argument type */ public class DepthFirstRetArguVisitor implements IRetArguVisitor { /* * Base nodes classes visit methods (to be overridden if necessary) */ /** * Visits a {@link NodeChoice} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeChoice n, final A argu) { final R nRes = n.choice.accept(this, argu); return nRes; } /** * Visits a {@link NodeList} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeList n, final A argu) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") final R sRes = e.next().accept(this, argu); } return nRes; } /** * Visits a {@link NodeListOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeListOptional n, final A argu) { if (n.present()) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") R sRes = e.next().accept(this, argu); } return nRes; } else return null; } /** * Visits a {@link NodeOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeOptional n, final A argu) { if (n.present()) { final R nRes = n.node.accept(this, argu); return nRes; } else return null; } /** * Visits a {@link NodeSequence} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeSequence n, final A argu) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") R subRet = e.next().accept(this, argu); } return nRes; } /** * Visits a {@link NodeToken} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeToken n, @SuppressWarnings("unused") final A argu) { R nRes = null; @SuppressWarnings("unused") final String tkIm = n.tokenImage; return nRes; } /* * User grammar generated visit methods (to be overridden if necessary) */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AFancyProduction n, final A argu) { R nRes = null; // try { // f0 -> ( #0 ( Annotation() )* // .. .. . #1 ( %0 LabeledStatement() // .. .. . .. | %1 AssertStatement() // .. .. . .. | %2 Block() // .. .. . .. | %3 EmptyStatement() // .. .. . .. | %4 $0 StatementExpression() $1 ";" // .. .. . .. | %5 SwitchStatement() // .. .. . .. | %6 TryStatement() ) // .. .. . #2 [ MarkerAnnotation() ] ) // } // catch (Name() < IDENTIFIER >) Block() // catch (Name() < IDENTIFIER >) Block() // finally Block() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCCInput n, final A argu) { R nRes = null; // f0 -> JavaCCOptions() n.f0.accept(this, argu); // f1 -> "PARSER_BEGIN" n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> Identifier() n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); // f5 -> CompilationUnit() n.f5.accept(this, argu); // f6 -> "PARSER_END" n.f6.accept(this, argu); // f7 -> "(" n.f7.accept(this, argu); // f8 -> Identifier() n.f8.accept(this, argu); // f9 -> ")" n.f9.accept(this, argu); // f10 -> ( Production() )+ n.f10.accept(this, argu); return nRes; } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCCOptions n, final A argu) { R nRes = null; // f0 -> [ #0 "options" #1 "{" // .. .. . #2 ( OptionBinding() )* #3 "}" ] n.f0.accept(this, argu); return nRes; } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final OptionBinding n, final A argu) { R nRes = null; // f0 -> ( %0 < IDENTIFIER > // .. .. | %1 "LOOKAHEAD" // .. .. | %2 "IGNORE_CASE" // .. .. | %3 "static" ) n.f0.accept(this, argu); // f1 -> "=" n.f1.accept(this, argu); // f2 -> ( %0 IntegerLiteral() // .. .. | %1 BooleanLiteral() // .. .. | %2 StringLiteral() ) n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Production n, final A argu) { R nRes = null; // f0 -> . %0 JavaCodeProduction() // .. .. | %1 RegularExprProduction() // .. .. | %2 TokenManagerDecls() // .. .. | %3 BNFProduction() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCodeProduction n, final A argu) { R nRes = null; // f0 -> "JAVACODE" n.f0.accept(this, argu); // f1 -> AccessModifier() n.f1.accept(this, argu); // f2 -> ResultType() n.f2.accept(this, argu); // f3 -> Identifier() n.f3.accept(this, argu); // f4 -> FormalParameters() n.f4.accept(this, argu); // f5 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f5.accept(this, argu); // f6 -> Block() n.f6.accept(this, argu); return nRes; } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BNFProduction n, final A argu) { R nRes = null; // f0 -> AccessModifier() n.f0.accept(this, argu); // f1 -> ResultType() n.f1.accept(this, argu); // f2 -> Identifier() n.f2.accept(this, argu); // f3 -> FormalParameters() n.f3.accept(this, argu); // f4 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f4.accept(this, argu); // f5 -> ":" n.f5.accept(this, argu); // f6 -> Block() n.f6.accept(this, argu); // f7 -> "{" n.f7.accept(this, argu); // f8 -> ExpansionChoices() n.f8.accept(this, argu); // f9 -> "}" n.f9.accept(this, argu); return nRes; } /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AccessModifier n, final A argu) { R nRes = null; // f0 -> ( %0 "public" // .. .. | %1 "protected" // .. .. | %2 "private" )? n.f0.accept(this, argu); return nRes; } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegularExprProduction n, final A argu) { R nRes = null; // f0 -> [ %0 #0 "<" #1 "*" #2 ">" // .. .. | %1 #0 "<" #1 < IDENTIFIER > // .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ] n.f0.accept(this, argu); // f1 -> RegExprKind() n.f1.accept(this, argu); // f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ] n.f2.accept(this, argu); // f3 -> ":" n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> RegExprSpec() n.f5.accept(this, argu); // f6 -> ( #0 "|" #1 RegExprSpec() )* n.f6.accept(this, argu); // f7 -> "}" n.f7.accept(this, argu); return nRes; } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TokenManagerDecls n, final A argu) { R nRes = null; // f0 -> "TOKEN_MGR_DECLS" n.f0.accept(this, argu); // f1 -> ":" n.f1.accept(this, argu); // f2 -> ClassOrInterfaceBody() n.f2.accept(this, argu); return nRes; } /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegExprKind n, final A argu) { R nRes = null; // f0 -> . %0 "TOKEN" // .. .. | %1 "SPECIAL_TOKEN" // .. .. | %2 "SKIP" // .. .. | %3 "MORE" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegExprSpec n, final A argu) { R nRes = null; // f0 -> RegularExpression() n.f0.accept(this, argu); // f1 -> [ Block() ] n.f1.accept(this, argu); // f2 -> [ #0 ":" #1 < IDENTIFIER > ] n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionChoices n, final A argu) { R nRes = null; // f0 -> Expansion() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 Expansion() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Expansion n, final A argu) { R nRes = null; // f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )? n.f0.accept(this, argu); // f1 -> ( ExpansionUnit() )+ n.f1.accept(this, argu); return nRes; } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LocalLookahead n, final A argu) { R nRes = null; // f0 -> [ IntegerLiteral() ] n.f0.accept(this, argu); // f1 -> [ "," ] n.f1.accept(this, argu); // f2 -> [ ExpansionChoices() ] n.f2.accept(this, argu); // f3 -> [ "," ] n.f3.accept(this, argu); // f4 -> [ #0 "{" #1 Expression() #2 "}" ] n.f4.accept(this, argu); return nRes; } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionUnit n, final A argu) { R nRes = null; // f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // .. .. | %1 Block() // .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]" // .. .. | %3 ExpansionUnitInTCF() // .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. . .. .. | &1 $0 RegularExpression() // .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) // .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" )? n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionUnitInTCF n, final A argu) { R nRes = null; // f0 -> "try" n.f0.accept(this, argu); // f1 -> "{" n.f1.accept(this, argu); // f2 -> ExpansionChoices() n.f2.accept(this, argu); // f3 -> "}" n.f3.accept(this, argu); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* n.f4.accept(this, argu); // f5 -> [ #0 "finally" #1 Block() ] n.f5.accept(this, argu); return nRes; } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegularExpression n, final A argu) { R nRes = null; // f0 -> . %0 StringLiteral() // .. .. | %1 #0 < LANGLE : "<" > // .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" > // .. .. | %2 #0 "<" #1 Identifier() #2 ">" // .. .. | %3 #0 "<" #1 "EOF" #2 ">" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpressionChoices n, final A argu) { R nRes = null; // f0 -> ComplexRegularExpression() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 ComplexRegularExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpression n, final A argu) { R nRes = null; // f0 -> ( ComplexRegularExpressionUnit() )+ n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpressionUnit n, final A argu) { R nRes = null; // f0 -> . %0 StringLiteral() // .. .. | %1 #0 "<" #1 Identifier() #2 ">" // .. .. | %2 CharacterList() // .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" // .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral() // .. .. . .. .. . .. $2 [ £0 "," // .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )? n.f0.accept(this, argu); return nRes; } /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CharacterList n, final A argu) { R nRes = null; // f0 -> [ "~" ] n.f0.accept(this, argu); // f1 -> "[" n.f1.accept(this, argu); // f2 -> [ #0 CharacterDescriptor() // .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ] n.f2.accept(this, argu); // f3 -> "]" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CharacterDescriptor n, final A argu) { R nRes = null; // f0 -> StringLiteral() n.f0.accept(this, argu); // f1 -> [ #0 "-" #1 StringLiteral() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Identifier n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); return nRes; } /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaIdentifier n, final A argu) { R nRes = null; // f0 -> ( %00 < IDENTIFIER > // .. .. | %01 "LOOKAHEAD" // .. .. | %02 "IGNORE_CASE" // .. .. | %03 "PARSER_BEGIN" // .. .. | %04 "PARSER_END" // .. .. | %05 "JAVACODE" // .. .. | %06 "TOKEN" // .. .. | %07 "SPECIAL_TOKEN" // .. .. | %08 "MORE" // .. .. | %09 "SKIP" // .. .. | %10 "TOKEN_MGR_DECLS" // .. .. | %11 "EOF" ) n.f0.accept(this, argu); return nRes; } /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CompilationUnit n, final A argu) { R nRes = null; // f0 -> [ PackageDeclaration() ] n.f0.accept(this, argu); // f1 -> ( ImportDeclaration() )* n.f1.accept(this, argu); // f2 -> ( TypeDeclaration() )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PackageDeclaration n, final A argu) { R nRes = null; // f0 -> ( Annotation() )* n.f0.accept(this, argu); // f1 -> "package" n.f1.accept(this, argu); // f2 -> Name() n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ImportDeclaration n, final A argu) { R nRes = null; // f0 -> "import" n.f0.accept(this, argu); // f1 -> [ "static" ] n.f1.accept(this, argu); // f2 -> Name() n.f2.accept(this, argu); // f3 -> [ #0 "." #1 "*" ] n.f3.accept(this, argu); // f4 -> ";" n.f4.accept(this, argu); return nRes; } /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Modifiers n, final A argu) { R nRes = null; // f0 -> ( ( %00 "public" // .. .. . | %01 "static" // .. .. . | %02 "protected" // .. .. . | %03 "private" // .. .. . | %04 "final" // .. .. . | %05 "abstract" // .. .. . | %06 "synchronized" // .. .. . | %07 "native" // .. .. . | %08 "transient" // .. .. . | %09 "volatile" // .. .. . | %10 "strictfp" // .. .. . | %11 Annotation() ) )* n.f0.accept(this, argu); return nRes; } /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeDeclaration n, final A argu) { R nRes = null; // f0 -> . %0 ";" // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 AnnotationTypeDeclaration() ) n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceDeclaration n, final A argu) { R nRes = null; // f0 -> ( %0 "class" // .. .. | %1 "interface" ) n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ TypeParameters() ] n.f2.accept(this, argu); // f3 -> [ ExtendsList() ] n.f3.accept(this, argu); // f4 -> [ ImplementsList() ] n.f4.accept(this, argu); // f5 -> ClassOrInterfaceBody() n.f5.accept(this, argu); return nRes; } /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExtendsList n, final A argu) { R nRes = null; // f0 -> "extends" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ImplementsList n, final A argu) { R nRes = null; // f0 -> "implements" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumDeclaration n, final A argu) { R nRes = null; // f0 -> "enum" n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ ImplementsList() ] n.f2.accept(this, argu); // f3 -> EnumBody() n.f3.accept(this, argu); return nRes; } /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumBody n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> [ #0 EnumConstant() // .. .. . #1 ( $0 "," $1 EnumConstant() )* ] n.f1.accept(this, argu); // f2 -> [ "," ] n.f2.accept(this, argu); // f3 -> [ #0 ";" // .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ] n.f3.accept(this, argu); // f4 -> "}" n.f4.accept(this, argu); return nRes; } /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumConstant n, final A argu) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ Arguments() ] n.f2.accept(this, argu); // f3 -> [ ClassOrInterfaceBody() ] n.f3.accept(this, argu); return nRes; } /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeParameters n, final A argu) { R nRes = null; // f0 -> "<" n.f0.accept(this, argu); // f1 -> TypeParameter() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 TypeParameter() )* n.f2.accept(this, argu); // f3 -> ">" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeParameter n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> [ TypeBound() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeBound n, final A argu) { R nRes = null; // f0 -> "extends" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "&" #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceBody n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( ClassOrInterfaceBodyDeclaration() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceBodyDeclaration n, final A argu) { R nRes = null; // f0 -> . %0 Initializer() // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 ConstructorDeclaration() // .. .. . .. .. | &3 FieldDeclaration() // .. .. . .. .. | &4 MethodDeclaration() ) // .. .. | %2 ";" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FieldDeclaration n, final A argu) { R nRes = null; // f0 -> Type() n.f0.accept(this, argu); // f1 -> VariableDeclarator() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 VariableDeclarator() )* n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableDeclarator n, final A argu) { R nRes = null; // f0 -> VariableDeclaratorId() n.f0.accept(this, argu); // f1 -> [ #0 "=" #1 VariableInitializer() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableDeclaratorId n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> ( #0 "[" #1 "]" )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableInitializer n, final A argu) { R nRes = null; // f0 -> . %0 ArrayInitializer() // .. .. | %1 Expression() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArrayInitializer n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> [ #0 VariableInitializer() // .. .. . #1 ( $0 "," $1 VariableInitializer() )* ] n.f1.accept(this, argu); // f2 -> [ "," ] n.f2.accept(this, argu); // f3 -> "}" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MethodDeclaration n, final A argu) { R nRes = null; // f0 -> [ TypeParameters() ] n.f0.accept(this, argu); // f1 -> ResultType() n.f1.accept(this, argu); // f2 -> MethodDeclarator() n.f2.accept(this, argu); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this, argu); // f4 -> ( %0 Block() // .. .. | %1 ";" ) n.f4.accept(this, argu); return nRes; } /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MethodDeclarator n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> FormalParameters() n.f1.accept(this, argu); // f2 -> ( #0 "[" #1 "]" )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FormalParameters n, final A argu) { R nRes = null; // f0 -> "(" n.f0.accept(this, argu); // f1 -> [ #0 FormalParameter() // .. .. . #1 ( $0 "," $1 FormalParameter() )* ] n.f1.accept(this, argu); // f2 -> ")" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FormalParameter n, final A argu) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> Type() n.f1.accept(this, argu); // f2 -> [ "..." ] n.f2.accept(this, argu); // f3 -> VariableDeclaratorId() n.f3.accept(this, argu); return nRes; } /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConstructorDeclaration n, final A argu) { R nRes = null; // f0 -> [ TypeParameters() ] n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> FormalParameters() n.f2.accept(this, argu); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> [ ExplicitConstructorInvocation() ] n.f5.accept(this, argu); // f6 -> ( BlockStatement() )* n.f6.accept(this, argu); // f7 -> "}" n.f7.accept(this, argu); return nRes; } /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExplicitConstructorInvocation n, final A argu) { R nRes = null; // f0 -> . %0 #0 "this" #1 Arguments() #2 ";" // .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Initializer n, final A argu) { R nRes = null; // f0 -> [ "static" ] n.f0.accept(this, argu); // f1 -> Block() n.f1.accept(this, argu); return nRes; } /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Type n, final A argu) { R nRes = null; // f0 -> . %0 ReferenceType() // .. .. | %1 PrimitiveType() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ReferenceType n, final A argu) { R nRes = null; // f0 -> . %0 #0 PrimitiveType() // .. .. . .. #1 ( $0 "[" $1 "]" )+ // .. .. | %1 #0 ClassOrInterfaceType() // .. .. . .. #1 ( $0 "[" $1 "]" )* n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceType n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> [ TypeArguments() ] n.f1.accept(this, argu); // f2 -> ( #0 "." #1 < IDENTIFIER > // .. .. . #2 [ TypeArguments() ] )* n.f2.accept(this, argu); return nRes; } /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeArguments n, final A argu) { R nRes = null; // f0 -> "<" n.f0.accept(this, argu); // f1 -> TypeArgument() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 TypeArgument() )* n.f2.accept(this, argu); // f3 -> ">" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeArgument n, final A argu) { R nRes = null; // f0 -> . %0 ReferenceType() // .. .. | %1 #0 "?" // .. .. . .. #1 [ WildcardBounds() ] n.f0.accept(this, argu); return nRes; } /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final WildcardBounds n, final A argu) { R nRes = null; // f0 -> . %0 #0 "extends" #1 ReferenceType() // .. .. | %1 #0 "super" #1 ReferenceType() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimitiveType n, final A argu) { R nRes = null; // f0 -> . %0 "boolean" // .. .. | %1 "char" // .. .. | %2 "byte" // .. .. | %3 "short" // .. .. | %4 "int" // .. .. | %5 "long" // .. .. | %6 "float" // .. .. | %7 "double" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ResultType n, final A argu) { R nRes = null; // f0 -> ( %0 "void" // .. .. | %1 Type() ) n.f0.accept(this, argu); return nRes; } /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Name n, final A argu) { R nRes = null; // f0 -> JavaIdentifier() n.f0.accept(this, argu); // f1 -> ( #0 "." #1 JavaIdentifier() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NameList n, final A argu) { R nRes = null; // f0 -> Name() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 Name() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Expression n, final A argu) { R nRes = null; // f0 -> ConditionalExpression() n.f0.accept(this, argu); // f1 -> [ #0 AssignmentOperator() #1 Expression() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AssignmentOperator n, final A argu) { R nRes = null; // f0 -> . %00 "=" // .. .. | %01 "*=" // .. .. | %02 "/=" // .. .. | %03 "%=" // .. .. | %04 "+=" // .. .. | %05 "-=" // .. .. | %06 "<<=" // .. .. | %07 ">>=" // .. .. | %08 ">>>=" // .. .. | %09 "&=" // .. .. | %10 "^=" // .. .. | %11 "|=" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalExpression n, final A argu) { R nRes = null; // f0 -> ConditionalOrExpression() n.f0.accept(this, argu); // f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalOrExpression n, final A argu) { R nRes = null; // f0 -> ConditionalAndExpression() n.f0.accept(this, argu); // f1 -> ( #0 "||" #1 ConditionalAndExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalAndExpression n, final A argu) { R nRes = null; // f0 -> InclusiveOrExpression() n.f0.accept(this, argu); // f1 -> ( #0 "&&" #1 InclusiveOrExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final InclusiveOrExpression n, final A argu) { R nRes = null; // f0 -> ExclusiveOrExpression() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 ExclusiveOrExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExclusiveOrExpression n, final A argu) { R nRes = null; // f0 -> AndExpression() n.f0.accept(this, argu); // f1 -> ( #0 "^" #1 AndExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AndExpression n, final A argu) { R nRes = null; // f0 -> EqualityExpression() n.f0.accept(this, argu); // f1 -> ( #0 "&" #1 EqualityExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EqualityExpression n, final A argu) { R nRes = null; // f0 -> InstanceOfExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "==" // .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final InstanceOfExpression n, final A argu) { R nRes = null; // f0 -> RelationalExpression() n.f0.accept(this, argu); // f1 -> [ #0 "instanceof" #1 Type() ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RelationalExpression n, final A argu) { R nRes = null; // f0 -> ShiftExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "<" // .. .. . .. | %1 ">" // .. .. . .. | %2 "<=" // .. .. . .. | %3 ">=" ) #1 ShiftExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ShiftExpression n, final A argu) { R nRes = null; // f0 -> AdditiveExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "<<" // .. .. . .. | %1 RSIGNEDSHIFT() // .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AdditiveExpression n, final A argu) { R nRes = null; // f0 -> MultiplicativeExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "+" // .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MultiplicativeExpression n, final A argu) { R nRes = null; // f0 -> UnaryExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "*" // .. .. . .. | %1 "/" // .. .. . .. | %2 "%" ) #1 UnaryExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final UnaryExpression n, final A argu) { R nRes = null; // f0 -> . %0 #0 ( &0 "+" // .. .. . .. .. | &1 "-" ) #1 UnaryExpression() // .. .. | %1 PreIncrementExpression() // .. .. | %2 PreDecrementExpression() // .. .. | %3 UnaryExpressionNotPlusMinus() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PreIncrementExpression n, final A argu) { R nRes = null; // f0 -> "++" n.f0.accept(this, argu); // f1 -> PrimaryExpression() n.f1.accept(this, argu); return nRes; } /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PreDecrementExpression n, final A argu) { R nRes = null; // f0 -> "--" n.f0.accept(this, argu); // f1 -> PrimaryExpression() n.f1.accept(this, argu); return nRes; } /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final UnaryExpressionNotPlusMinus n, final A argu) { R nRes = null; // f0 -> . %0 #0 ( &0 "~" // .. .. . .. .. | &1 "!" ) #1 UnaryExpression() // .. .. | %1 CastExpression() // .. .. | %2 PostfixExpression() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CastLookahead n, final A argu) { R nRes = null; // f0 -> . %0 #0 "(" #1 PrimitiveType() // .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]" // .. .. | %2 #0 "(" #1 Type() #2 ")" // .. .. . .. #3 ( &0 "~" // .. .. . .. .. | &1 "!" // .. .. . .. .. | &2 "(" // .. .. . .. .. | &3 < IDENTIFIER > // .. .. . .. .. | &4 "this" // .. .. . .. .. | &5 "super" // .. .. . .. .. | &6 "new" // .. .. . .. .. | &7 Literal() ) n.f0.accept(this, argu); return nRes; } /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PostfixExpression n, final A argu) { R nRes = null; // f0 -> PrimaryExpression() n.f0.accept(this, argu); // f1 -> [ %0 "++" // .. .. | %1 "--" ] n.f1.accept(this, argu); return nRes; } /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CastExpression n, final A argu) { R nRes = null; // f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression() // .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimaryExpression n, final A argu) { R nRes = null; // f0 -> PrimaryPrefix() n.f0.accept(this, argu); // f1 -> ( PrimarySuffix() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberSelector n, final A argu) { R nRes = null; // f0 -> "." n.f0.accept(this, argu); // f1 -> TypeArguments() n.f1.accept(this, argu); // f2 -> < IDENTIFIER > n.f2.accept(this, argu); return nRes; } /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimaryPrefix n, final A argu) { R nRes = null; // f0 -> . %0 Literal() // .. .. | %1 "this" // .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER > // .. .. | %3 #0 "(" #1 Expression() #2 ")" // .. .. | %4 AllocationExpression() // .. .. | %5 #0 ResultType() #1 "." #2 "class" // .. .. | %6 Name() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimarySuffix n, final A argu) { R nRes = null; // f0 -> . %0 #0 "." #1 "this" // .. .. | %1 #0 "." #1 AllocationExpression() // .. .. | %2 MemberSelector() // .. .. | %3 #0 "[" #1 Expression() #2 "]" // .. .. | %4 #0 "." #1 < IDENTIFIER > // .. .. | %5 Arguments() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Literal n, final A argu) { R nRes = null; // f0 -> . %0 < INTEGER_LITERAL > // .. .. | %1 < FLOATING_POINT_LITERAL > // .. .. | %2 < CHARACTER_LITERAL > // .. .. | %3 < STRING_LITERAL > // .. .. | %4 BooleanLiteral() // .. .. | %5 NullLiteral() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final IntegerLiteral n, final A argu) { R nRes = null; // f0 -> < INTEGER_LITERAL > n.f0.accept(this, argu); return nRes; } /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BooleanLiteral n, final A argu) { R nRes = null; // f0 -> . %0 "true" // .. .. | %1 "false" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StringLiteral n, final A argu) { R nRes = null; // f0 -> < STRING_LITERAL > n.f0.accept(this, argu); return nRes; } /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NullLiteral n, final A argu) { R nRes = null; // f0 -> "null" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Arguments n, final A argu) { R nRes = null; // f0 -> "(" n.f0.accept(this, argu); // f1 -> [ ArgumentList() ] n.f1.accept(this, argu); // f2 -> ")" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArgumentList n, final A argu) { R nRes = null; // f0 -> Expression() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 Expression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AllocationExpression n, final A argu) { R nRes = null; // f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits() // .. .. | %1 #0 "new" #1 ClassOrInterfaceType() // .. .. . .. #2 [ TypeArguments() ] // .. .. . .. #3 ( &0 ArrayDimsAndInits() // .. .. . .. .. | &1 $0 Arguments() // .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] ) n.f0.accept(this, argu); return nRes; } /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArrayDimsAndInits n, final A argu) { R nRes = null; // f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+ // .. .. . .. #1 ( $0 "[" $1 "]" )* // .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Statement n, final A argu) { R nRes = null; // f0 -> . %00 LabeledStatement() // .. .. | %01 AssertStatement() // .. .. | %02 Block() // .. .. | %03 EmptyStatement() // .. .. | %04 #0 StatementExpression() #1 ";" // .. .. | %05 SwitchStatement() // .. .. | %06 IfStatement() // .. .. | %07 WhileStatement() // .. .. | %08 DoStatement() // .. .. | %09 ForStatement() // .. .. | %10 BreakStatement() // .. .. | %11 ContinueStatement() // .. .. | %12 ReturnStatement() // .. .. | %13 ThrowStatement() // .. .. | %14 SynchronizedStatement() // .. .. | %15 TryStatement() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AssertStatement n, final A argu) { R nRes = null; // f0 -> "assert" n.f0.accept(this, argu); // f1 -> Expression() n.f1.accept(this, argu); // f2 -> [ #0 ":" #1 Expression() ] n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); return nRes; } /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LabeledStatement n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> ":" n.f1.accept(this, argu); // f2 -> Statement() n.f2.accept(this, argu); return nRes; } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Block n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( BlockStatement() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BlockStatement n, final A argu) { R nRes = null; // f0 -> . %0 #0 LocalVariableDeclaration() #1 ";" // .. .. | %1 Statement() // .. .. | %2 ClassOrInterfaceDeclaration() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LocalVariableDeclaration n, final A argu) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> Type() n.f1.accept(this, argu); // f2 -> VariableDeclarator() n.f2.accept(this, argu); // f3 -> ( #0 "," #1 VariableDeclarator() )* n.f3.accept(this, argu); return nRes; } /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EmptyStatement n, final A argu) { R nRes = null; // f0 -> ";" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StatementExpression n, final A argu) { R nRes = null; // f0 -> . %0 PreIncrementExpression() // .. .. | %1 PreDecrementExpression() // .. .. | %2 #0 PrimaryExpression() // .. .. . .. #1 [ &0 "++" // .. .. . .. .. | &1 "--" // .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ] n.f0.accept(this, argu); return nRes; } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SwitchStatement n, final A argu) { R nRes = null; // f0 -> "switch" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> ( #0 SwitchLabel() // .. .. . #1 ( BlockStatement() )* )* n.f5.accept(this, argu); // f6 -> "}" n.f6.accept(this, argu); return nRes; } /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SwitchLabel n, final A argu) { R nRes = null; // f0 -> . %0 #0 "case" #1 Expression() #2 ":" // .. .. | %1 #0 "default" #1 ":" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final IfStatement n, final A argu) { R nRes = null; // f0 -> "if" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); // f5 -> [ #0 "else" #1 Statement() ] n.f5.accept(this, argu); return nRes; } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final WhileStatement n, final A argu) { R nRes = null; // f0 -> "while" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); return nRes; } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final DoStatement n, final A argu) { R nRes = null; // f0 -> "do" n.f0.accept(this, argu); // f1 -> Statement() n.f1.accept(this, argu); // f2 -> "while" n.f2.accept(this, argu); // f3 -> "(" n.f3.accept(this, argu); // f4 -> Expression() n.f4.accept(this, argu); // f5 -> ")" n.f5.accept(this, argu); // f6 -> ";" n.f6.accept(this, argu); return nRes; } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForStatement n, final A argu) { R nRes = null; // f0 -> "for" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression() // .. .. | %1 #0 [ ForInit() ] #1 ";" // .. .. . .. #2 [ Expression() ] #3 ";" // .. .. . .. #4 [ ForUpdate() ] ) n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); return nRes; } /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForInit n, final A argu) { R nRes = null; // f0 -> . %0 LocalVariableDeclaration() // .. .. | %1 StatementExpressionList() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StatementExpressionList n, final A argu) { R nRes = null; // f0 -> StatementExpression() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 StatementExpression() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForUpdate n, final A argu) { R nRes = null; // f0 -> StatementExpressionList() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BreakStatement n, final A argu) { R nRes = null; // f0 -> "break" n.f0.accept(this, argu); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ContinueStatement n, final A argu) { R nRes = null; // f0 -> "continue" n.f0.accept(this, argu); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ReturnStatement n, final A argu) { R nRes = null; // f0 -> "return" n.f0.accept(this, argu); // f1 -> [ Expression() ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ThrowStatement n, final A argu) { R nRes = null; // f0 -> "throw" n.f0.accept(this, argu); // f1 -> Expression() n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SynchronizedStatement n, final A argu) { R nRes = null; // f0 -> "synchronized" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Block() n.f4.accept(this, argu); return nRes; } /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TryStatement n, final A argu) { R nRes = null; // f0 -> "try" n.f0.accept(this, argu); // f1 -> Block() n.f1.accept(this, argu); // f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )* n.f2.accept(this, argu); // f3 -> [ #0 "finally" #1 Block() ] n.f3.accept(this, argu); return nRes; } /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RUNSIGNEDSHIFT n, final A argu) { R nRes = null; // f0 -> ">" n.f0.accept(this, argu); // f1 -> ">" n.f1.accept(this, argu); // f2 -> ">" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RSIGNEDSHIFT n, final A argu) { R nRes = null; // f0 -> ">" n.f0.accept(this, argu); // f1 -> ">" n.f1.accept(this, argu); return nRes; } /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Annotation n, final A argu) { R nRes = null; // f0 -> . %0 NormalAnnotation() // .. .. | %1 SingleMemberAnnotation() // .. .. | %2 MarkerAnnotation() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NormalAnnotation n, final A argu) { R nRes = null; // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> [ MemberValuePairs() ] n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); return nRes; } /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MarkerAnnotation n, final A argu) { R nRes = null; // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); return nRes; } /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SingleMemberAnnotation n, final A argu) { R nRes = null; // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> MemberValue() n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); return nRes; } /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValuePairs n, final A argu) { R nRes = null; // f0 -> MemberValuePair() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 MemberValuePair() )* n.f1.accept(this, argu); return nRes; } /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValuePair n, final A argu) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> "=" n.f1.accept(this, argu); // f2 -> MemberValue() n.f2.accept(this, argu); return nRes; } /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValue n, final A argu) { R nRes = null; // f0 -> . %0 Annotation() // .. .. | %1 MemberValueArrayInitializer() // .. .. | %2 ConditionalExpression() n.f0.accept(this, argu); return nRes; } /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValueArrayInitializer n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> MemberValue() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 MemberValue() )* n.f2.accept(this, argu); // f3 -> [ "," ] n.f3.accept(this, argu); // f4 -> "}" n.f4.accept(this, argu); return nRes; } /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeDeclaration n, final A argu) { R nRes = null; // f0 -> "@" n.f0.accept(this, argu); // f1 -> "interface" n.f1.accept(this, argu); // f2 -> < IDENTIFIER > n.f2.accept(this, argu); // f3 -> AnnotationTypeBody() n.f3.accept(this, argu); return nRes; } /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeBody n, final A argu) { R nRes = null; // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( AnnotationTypeMemberDeclaration() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); return nRes; } /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeMemberDeclaration n, final A argu) { R nRes = null; // f0 -> . %0 #0 Modifiers() // .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")" // .. .. . .. .. $4 [ DefaultValue() ] $5 ";" // .. .. . .. .. | &1 ClassOrInterfaceDeclaration() // .. .. . .. .. | &2 EnumDeclaration() // .. .. . .. .. | &3 AnnotationTypeDeclaration() // .. .. . .. .. | &4 FieldDeclaration() ) // .. .. | %1 ";" n.f0.accept(this, argu); return nRes; } /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final DefaultValue n, final A argu) { R nRes = null; // f0 -> "default" n.f0.accept(this, argu); // f1 -> MemberValue() n.f1.accept(this, argu); return nRes; } } jtb-1.4.4/EDU/purdue/jtb/visitor/DepthFirstVoidVisitor.java0000644000175000017500000022764411416555700023462 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; import java.util.*; /** * Provides default methods which visit each node in the tree in depth-first order.
* In your "Void" visitors extend this class and override part or all of these methods. * */ public class DepthFirstVoidVisitor implements IVoidVisitor { /* * Base nodes classes visit methods (to be overridden if necessary) */ /** * Visits a {@link NodeChoice} node. * * @param n the node to visit */ public void visit(final NodeChoice n) { n.choice.accept(this); return; } /** * Visits a {@link NodeList} node. * * @param n the node to visit */ public void visit(final NodeList n) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this); } return; } /** * Visits a {@link NodeListOptional} node. * * @param n the node to visit */ public void visit(final NodeListOptional n) { if (n.present()) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this); } return; } else return; } /** * Visits a {@link NodeOptional} node. * * @param n the node to visit */ public void visit(final NodeOptional n) { if (n.present()) { n.node.accept(this); return; } else return; } /** * Visits a {@link NodeSequence} node. * * @param n the node to visit */ public void visit(final NodeSequence n) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this); } return; } /** * Visits a {@link NodeToken} node. * * @param n the node to visit */ public void visit(final NodeToken n) { @SuppressWarnings("unused") final String tkIm = n.tokenImage; return; } /* * User grammar generated visit methods (to be overridden if necessary) */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit */ public void visit(final AFancyProduction n) { // try { // f0 -> ( #0 ( Annotation() )* // .. .. . #1 ( %0 LabeledStatement() // .. .. . .. | %1 AssertStatement() // .. .. . .. | %2 Block() // .. .. . .. | %3 EmptyStatement() // .. .. . .. | %4 $0 StatementExpression() $1 ";" // .. .. . .. | %5 SwitchStatement() // .. .. . .. | %6 TryStatement() ) // .. .. . #2 [ MarkerAnnotation() ] ) // } // catch (Name() < IDENTIFIER >) Block() // catch (Name() < IDENTIFIER >) Block() // finally Block() n.f0.accept(this); } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ public void visit(final JavaCCInput n) { // f0 -> JavaCCOptions() n.f0.accept(this); // f1 -> "PARSER_BEGIN" n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); // f5 -> CompilationUnit() n.f5.accept(this); // f6 -> "PARSER_END" n.f6.accept(this); // f7 -> "(" n.f7.accept(this); // f8 -> Identifier() n.f8.accept(this); // f9 -> ")" n.f9.accept(this); // f10 -> ( Production() )+ n.f10.accept(this); } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit */ public void visit(final JavaCCOptions n) { // f0 -> [ #0 "options" #1 "{" // .. .. . #2 ( OptionBinding() )* #3 "}" ] n.f0.accept(this); } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit */ public void visit(final OptionBinding n) { // f0 -> ( %0 < IDENTIFIER > // .. .. | %1 "LOOKAHEAD" // .. .. | %2 "IGNORE_CASE" // .. .. | %3 "static" ) n.f0.accept(this); // f1 -> "=" n.f1.accept(this); // f2 -> ( %0 IntegerLiteral() // .. .. | %1 BooleanLiteral() // .. .. | %2 StringLiteral() ) n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ public void visit(final Production n) { // f0 -> . %0 JavaCodeProduction() // .. .. | %1 RegularExprProduction() // .. .. | %2 TokenManagerDecls() // .. .. | %3 BNFProduction() n.f0.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ public void visit(final JavaCodeProduction n) { // f0 -> "JAVACODE" n.f0.accept(this); // f1 -> AccessModifier() n.f1.accept(this); // f2 -> ResultType() n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> FormalParameters() n.f4.accept(this); // f5 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f5.accept(this); // f6 -> Block() n.f6.accept(this); } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ public void visit(final BNFProduction n) { // f0 -> AccessModifier() n.f0.accept(this); // f1 -> ResultType() n.f1.accept(this); // f2 -> Identifier() n.f2.accept(this); // f3 -> FormalParameters() n.f3.accept(this); // f4 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f4.accept(this); // f5 -> ":" n.f5.accept(this); // f6 -> Block() n.f6.accept(this); // f7 -> "{" n.f7.accept(this); // f8 -> ExpansionChoices() n.f8.accept(this); // f9 -> "}" n.f9.accept(this); } /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit */ public void visit(final AccessModifier n) { // f0 -> ( %0 "public" // .. .. | %1 "protected" // .. .. | %2 "private" )? n.f0.accept(this); } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ public void visit(final RegularExprProduction n) { // f0 -> [ %0 #0 "<" #1 "*" #2 ">" // .. .. | %1 #0 "<" #1 < IDENTIFIER > // .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ] n.f0.accept(this); // f1 -> RegExprKind() n.f1.accept(this); // f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ] n.f2.accept(this); // f3 -> ":" n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> RegExprSpec() n.f5.accept(this); // f6 -> ( #0 "|" #1 RegExprSpec() )* n.f6.accept(this); // f7 -> "}" n.f7.accept(this); } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit */ public void visit(final TokenManagerDecls n) { // f0 -> "TOKEN_MGR_DECLS" n.f0.accept(this); // f1 -> ":" n.f1.accept(this); // f2 -> ClassOrInterfaceBody() n.f2.accept(this); } /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit */ public void visit(final RegExprKind n) { // f0 -> . %0 "TOKEN" // .. .. | %1 "SPECIAL_TOKEN" // .. .. | %2 "SKIP" // .. .. | %3 "MORE" n.f0.accept(this); } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit */ public void visit(final RegExprSpec n) { // f0 -> RegularExpression() n.f0.accept(this); // f1 -> [ Block() ] n.f1.accept(this); // f2 -> [ #0 ":" #1 < IDENTIFIER > ] n.f2.accept(this); } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ public void visit(final ExpansionChoices n) { // f0 -> Expansion() n.f0.accept(this); // f1 -> ( #0 "|" #1 Expansion() )* n.f1.accept(this); } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ public void visit(final Expansion n) { // f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )? n.f0.accept(this); // f1 -> ( ExpansionUnit() )+ n.f1.accept(this); } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit */ public void visit(final LocalLookahead n) { // f0 -> [ IntegerLiteral() ] n.f0.accept(this); // f1 -> [ "," ] n.f1.accept(this); // f2 -> [ ExpansionChoices() ] n.f2.accept(this); // f3 -> [ "," ] n.f3.accept(this); // f4 -> [ #0 "{" #1 Expression() #2 "}" ] n.f4.accept(this); } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ public void visit(final ExpansionUnit n) { // f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // .. .. | %1 Block() // .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]" // .. .. | %3 ExpansionUnitInTCF() // .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. . .. .. | &1 $0 RegularExpression() // .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) // .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" )? n.f0.accept(this); } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ public void visit(final ExpansionUnitInTCF n) { // f0 -> "try" n.f0.accept(this); // f1 -> "{" n.f1.accept(this); // f2 -> ExpansionChoices() n.f2.accept(this); // f3 -> "}" n.f3.accept(this); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* n.f4.accept(this); // f5 -> [ #0 "finally" #1 Block() ] n.f5.accept(this); } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ public void visit(final RegularExpression n) { // f0 -> . %0 StringLiteral() // .. .. | %1 #0 < LANGLE : "<" > // .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" > // .. .. | %2 #0 "<" #1 Identifier() #2 ">" // .. .. | %3 #0 "<" #1 "EOF" #2 ">" n.f0.accept(this); } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit */ public void visit(final ComplexRegularExpressionChoices n) { // f0 -> ComplexRegularExpression() n.f0.accept(this); // f1 -> ( #0 "|" #1 ComplexRegularExpression() )* n.f1.accept(this); } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit */ public void visit(final ComplexRegularExpression n) { // f0 -> ( ComplexRegularExpressionUnit() )+ n.f0.accept(this); } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit */ public void visit(final ComplexRegularExpressionUnit n) { // f0 -> . %0 StringLiteral() // .. .. | %1 #0 "<" #1 Identifier() #2 ">" // .. .. | %2 CharacterList() // .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" // .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral() // .. .. . .. .. . .. $2 [ £0 "," // .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )? n.f0.accept(this); } /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit */ public void visit(final CharacterList n) { // f0 -> [ "~" ] n.f0.accept(this); // f1 -> "[" n.f1.accept(this); // f2 -> [ #0 CharacterDescriptor() // .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ] n.f2.accept(this); // f3 -> "]" n.f3.accept(this); } /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit */ public void visit(final CharacterDescriptor n) { // f0 -> StringLiteral() n.f0.accept(this); // f1 -> [ #0 "-" #1 StringLiteral() ] n.f1.accept(this); } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ public void visit(final Identifier n) { // f0 -> < IDENTIFIER > n.f0.accept(this); } /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit */ public void visit(final JavaIdentifier n) { // f0 -> ( %00 < IDENTIFIER > // .. .. | %01 "LOOKAHEAD" // .. .. | %02 "IGNORE_CASE" // .. .. | %03 "PARSER_BEGIN" // .. .. | %04 "PARSER_END" // .. .. | %05 "JAVACODE" // .. .. | %06 "TOKEN" // .. .. | %07 "SPECIAL_TOKEN" // .. .. | %08 "MORE" // .. .. | %09 "SKIP" // .. .. | %10 "TOKEN_MGR_DECLS" // .. .. | %11 "EOF" ) n.f0.accept(this); } /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit */ public void visit(final CompilationUnit n) { // f0 -> [ PackageDeclaration() ] n.f0.accept(this); // f1 -> ( ImportDeclaration() )* n.f1.accept(this); // f2 -> ( TypeDeclaration() )* n.f2.accept(this); } /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit */ public void visit(final PackageDeclaration n) { // f0 -> ( Annotation() )* n.f0.accept(this); // f1 -> "package" n.f1.accept(this); // f2 -> Name() n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit */ public void visit(final ImportDeclaration n) { // f0 -> "import" n.f0.accept(this); // f1 -> [ "static" ] n.f1.accept(this); // f2 -> Name() n.f2.accept(this); // f3 -> [ #0 "." #1 "*" ] n.f3.accept(this); // f4 -> ";" n.f4.accept(this); } /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit */ public void visit(final Modifiers n) { // f0 -> ( ( %00 "public" // .. .. . | %01 "static" // .. .. . | %02 "protected" // .. .. . | %03 "private" // .. .. . | %04 "final" // .. .. . | %05 "abstract" // .. .. . | %06 "synchronized" // .. .. . | %07 "native" // .. .. . | %08 "transient" // .. .. . | %09 "volatile" // .. .. . | %10 "strictfp" // .. .. . | %11 Annotation() ) )* n.f0.accept(this); } /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit */ public void visit(final TypeDeclaration n) { // f0 -> . %0 ";" // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 AnnotationTypeDeclaration() ) n.f0.accept(this); } /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit */ public void visit(final ClassOrInterfaceDeclaration n) { // f0 -> ( %0 "class" // .. .. | %1 "interface" ) n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ TypeParameters() ] n.f2.accept(this); // f3 -> [ ExtendsList() ] n.f3.accept(this); // f4 -> [ ImplementsList() ] n.f4.accept(this); // f5 -> ClassOrInterfaceBody() n.f5.accept(this); } /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final ExtendsList n) { // f0 -> "extends" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this); } /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final ImplementsList n) { // f0 -> "implements" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this); } /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit */ public void visit(final EnumDeclaration n) { // f0 -> "enum" n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ ImplementsList() ] n.f2.accept(this); // f3 -> EnumBody() n.f3.accept(this); } /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit */ public void visit(final EnumBody n) { // f0 -> "{" n.f0.accept(this); // f1 -> [ #0 EnumConstant() // .. .. . #1 ( $0 "," $1 EnumConstant() )* ] n.f1.accept(this); // f2 -> [ "," ] n.f2.accept(this); // f3 -> [ #0 ";" // .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ] n.f3.accept(this); // f4 -> "}" n.f4.accept(this); } /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit */ public void visit(final EnumConstant n) { // f0 -> Modifiers() n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ Arguments() ] n.f2.accept(this); // f3 -> [ ClassOrInterfaceBody() ] n.f3.accept(this); } /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit */ public void visit(final TypeParameters n) { // f0 -> "<" n.f0.accept(this); // f1 -> TypeParameter() n.f1.accept(this); // f2 -> ( #0 "," #1 TypeParameter() )* n.f2.accept(this); // f3 -> ">" n.f3.accept(this); } /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit */ public void visit(final TypeParameter n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeBound() ] n.f1.accept(this); } /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final TypeBound n) { // f0 -> "extends" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "&" #1 ClassOrInterfaceType() )* n.f2.accept(this); } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final ClassOrInterfaceBody n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( ClassOrInterfaceBodyDeclaration() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); } /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit */ public void visit(final ClassOrInterfaceBodyDeclaration n) { // f0 -> . %0 Initializer() // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 ConstructorDeclaration() // .. .. . .. .. | &3 FieldDeclaration() // .. .. . .. .. | &4 MethodDeclaration() ) // .. .. | %2 ";" n.f0.accept(this); } /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit */ public void visit(final FieldDeclaration n) { // f0 -> Type() n.f0.accept(this); // f1 -> VariableDeclarator() n.f1.accept(this); // f2 -> ( #0 "," #1 VariableDeclarator() )* n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit */ public void visit(final VariableDeclarator n) { // f0 -> VariableDeclaratorId() n.f0.accept(this); // f1 -> [ #0 "=" #1 VariableInitializer() ] n.f1.accept(this); } /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ public void visit(final VariableDeclaratorId n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ( #0 "[" #1 "]" )* n.f1.accept(this); } /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit */ public void visit(final VariableInitializer n) { // f0 -> . %0 ArrayInitializer() // .. .. | %1 Expression() n.f0.accept(this); } /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit */ public void visit(final ArrayInitializer n) { // f0 -> "{" n.f0.accept(this); // f1 -> [ #0 VariableInitializer() // .. .. . #1 ( $0 "," $1 VariableInitializer() )* ] n.f1.accept(this); // f2 -> [ "," ] n.f2.accept(this); // f3 -> "}" n.f3.accept(this); } /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit */ public void visit(final MethodDeclaration n) { // f0 -> [ TypeParameters() ] n.f0.accept(this); // f1 -> ResultType() n.f1.accept(this); // f2 -> MethodDeclarator() n.f2.accept(this); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this); // f4 -> ( %0 Block() // .. .. | %1 ";" ) n.f4.accept(this); } /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ public void visit(final MethodDeclarator n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> FormalParameters() n.f1.accept(this); // f2 -> ( #0 "[" #1 "]" )* n.f2.accept(this); } /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit */ public void visit(final FormalParameters n) { // f0 -> "(" n.f0.accept(this); // f1 -> [ #0 FormalParameter() // .. .. . #1 ( $0 "," $1 FormalParameter() )* ] n.f1.accept(this); // f2 -> ")" n.f2.accept(this); } /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit */ public void visit(final FormalParameter n) { // f0 -> Modifiers() n.f0.accept(this); // f1 -> Type() n.f1.accept(this); // f2 -> [ "..." ] n.f2.accept(this); // f3 -> VariableDeclaratorId() n.f3.accept(this); } /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit */ public void visit(final ConstructorDeclaration n) { // f0 -> [ TypeParameters() ] n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> FormalParameters() n.f2.accept(this); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> [ ExplicitConstructorInvocation() ] n.f5.accept(this); // f6 -> ( BlockStatement() )* n.f6.accept(this); // f7 -> "}" n.f7.accept(this); } /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit */ public void visit(final ExplicitConstructorInvocation n) { // f0 -> . %0 #0 "this" #1 Arguments() #2 ";" // .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";" n.f0.accept(this); } /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit */ public void visit(final Initializer n) { // f0 -> [ "static" ] n.f0.accept(this); // f1 -> Block() n.f1.accept(this); } /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit */ public void visit(final Type n) { // f0 -> . %0 ReferenceType() // .. .. | %1 PrimitiveType() n.f0.accept(this); } /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit */ public void visit(final ReferenceType n) { // f0 -> . %0 #0 PrimitiveType() // .. .. . .. #1 ( $0 "[" $1 "]" )+ // .. .. | %1 #0 ClassOrInterfaceType() // .. .. . .. #1 ( $0 "[" $1 "]" )* n.f0.accept(this); } /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit */ public void visit(final ClassOrInterfaceType n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeArguments() ] n.f1.accept(this); // f2 -> ( #0 "." #1 < IDENTIFIER > // .. .. . #2 [ TypeArguments() ] )* n.f2.accept(this); } /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit */ public void visit(final TypeArguments n) { // f0 -> "<" n.f0.accept(this); // f1 -> TypeArgument() n.f1.accept(this); // f2 -> ( #0 "," #1 TypeArgument() )* n.f2.accept(this); // f3 -> ">" n.f3.accept(this); } /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit */ public void visit(final TypeArgument n) { // f0 -> . %0 ReferenceType() // .. .. | %1 #0 "?" // .. .. . .. #1 [ WildcardBounds() ] n.f0.accept(this); } /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit */ public void visit(final WildcardBounds n) { // f0 -> . %0 #0 "extends" #1 ReferenceType() // .. .. | %1 #0 "super" #1 ReferenceType() n.f0.accept(this); } /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit */ public void visit(final PrimitiveType n) { // f0 -> . %0 "boolean" // .. .. | %1 "char" // .. .. | %2 "byte" // .. .. | %3 "short" // .. .. | %4 "int" // .. .. | %5 "long" // .. .. | %6 "float" // .. .. | %7 "double" n.f0.accept(this); } /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit */ public void visit(final ResultType n) { // f0 -> ( %0 "void" // .. .. | %1 Type() ) n.f0.accept(this); } /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit */ public void visit(final Name n) { // f0 -> JavaIdentifier() n.f0.accept(this); // f1 -> ( #0 "." #1 JavaIdentifier() )* n.f1.accept(this); } /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit */ public void visit(final NameList n) { // f0 -> Name() n.f0.accept(this); // f1 -> ( #0 "," #1 Name() )* n.f1.accept(this); } /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit */ public void visit(final Expression n) { // f0 -> ConditionalExpression() n.f0.accept(this); // f1 -> [ #0 AssignmentOperator() #1 Expression() ] n.f1.accept(this); } /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit */ public void visit(final AssignmentOperator n) { // f0 -> . %00 "=" // .. .. | %01 "*=" // .. .. | %02 "/=" // .. .. | %03 "%=" // .. .. | %04 "+=" // .. .. | %05 "-=" // .. .. | %06 "<<=" // .. .. | %07 ">>=" // .. .. | %08 ">>>=" // .. .. | %09 "&=" // .. .. | %10 "^=" // .. .. | %11 "|=" n.f0.accept(this); } /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit */ public void visit(final ConditionalExpression n) { // f0 -> ConditionalOrExpression() n.f0.accept(this); // f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ] n.f1.accept(this); } /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit */ public void visit(final ConditionalOrExpression n) { // f0 -> ConditionalAndExpression() n.f0.accept(this); // f1 -> ( #0 "||" #1 ConditionalAndExpression() )* n.f1.accept(this); } /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit */ public void visit(final ConditionalAndExpression n) { // f0 -> InclusiveOrExpression() n.f0.accept(this); // f1 -> ( #0 "&&" #1 InclusiveOrExpression() )* n.f1.accept(this); } /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit */ public void visit(final InclusiveOrExpression n) { // f0 -> ExclusiveOrExpression() n.f0.accept(this); // f1 -> ( #0 "|" #1 ExclusiveOrExpression() )* n.f1.accept(this); } /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit */ public void visit(final ExclusiveOrExpression n) { // f0 -> AndExpression() n.f0.accept(this); // f1 -> ( #0 "^" #1 AndExpression() )* n.f1.accept(this); } /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit */ public void visit(final AndExpression n) { // f0 -> EqualityExpression() n.f0.accept(this); // f1 -> ( #0 "&" #1 EqualityExpression() )* n.f1.accept(this); } /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit */ public void visit(final EqualityExpression n) { // f0 -> InstanceOfExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "==" // .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )* n.f1.accept(this); } /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit */ public void visit(final InstanceOfExpression n) { // f0 -> RelationalExpression() n.f0.accept(this); // f1 -> [ #0 "instanceof" #1 Type() ] n.f1.accept(this); } /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit */ public void visit(final RelationalExpression n) { // f0 -> ShiftExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "<" // .. .. . .. | %1 ">" // .. .. . .. | %2 "<=" // .. .. . .. | %3 ">=" ) #1 ShiftExpression() )* n.f1.accept(this); } /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit */ public void visit(final ShiftExpression n) { // f0 -> AdditiveExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "<<" // .. .. . .. | %1 RSIGNEDSHIFT() // .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )* n.f1.accept(this); } /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit */ public void visit(final AdditiveExpression n) { // f0 -> MultiplicativeExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "+" // .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )* n.f1.accept(this); } /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit */ public void visit(final MultiplicativeExpression n) { // f0 -> UnaryExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "*" // .. .. . .. | %1 "/" // .. .. . .. | %2 "%" ) #1 UnaryExpression() )* n.f1.accept(this); } /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ public void visit(final UnaryExpression n) { // f0 -> . %0 #0 ( &0 "+" // .. .. . .. .. | &1 "-" ) #1 UnaryExpression() // .. .. | %1 PreIncrementExpression() // .. .. | %2 PreDecrementExpression() // .. .. | %3 UnaryExpressionNotPlusMinus() n.f0.accept(this); } /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ public void visit(final PreIncrementExpression n) { // f0 -> "++" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); } /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ public void visit(final PreDecrementExpression n) { // f0 -> "--" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); } /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit */ public void visit(final UnaryExpressionNotPlusMinus n) { // f0 -> . %0 #0 ( &0 "~" // .. .. . .. .. | &1 "!" ) #1 UnaryExpression() // .. .. | %1 CastExpression() // .. .. | %2 PostfixExpression() n.f0.accept(this); } /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit */ public void visit(final CastLookahead n) { // f0 -> . %0 #0 "(" #1 PrimitiveType() // .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]" // .. .. | %2 #0 "(" #1 Type() #2 ")" // .. .. . .. #3 ( &0 "~" // .. .. . .. .. | &1 "!" // .. .. . .. .. | &2 "(" // .. .. . .. .. | &3 < IDENTIFIER > // .. .. . .. .. | &4 "this" // .. .. . .. .. | &5 "super" // .. .. . .. .. | &6 "new" // .. .. . .. .. | &7 Literal() ) n.f0.accept(this); } /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit */ public void visit(final PostfixExpression n) { // f0 -> PrimaryExpression() n.f0.accept(this); // f1 -> [ %0 "++" // .. .. | %1 "--" ] n.f1.accept(this); } /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ public void visit(final CastExpression n) { // f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression() // .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus() n.f0.accept(this); } /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit */ public void visit(final PrimaryExpression n) { // f0 -> PrimaryPrefix() n.f0.accept(this); // f1 -> ( PrimarySuffix() )* n.f1.accept(this); } /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit */ public void visit(final MemberSelector n) { // f0 -> "." n.f0.accept(this); // f1 -> TypeArguments() n.f1.accept(this); // f2 -> < IDENTIFIER > n.f2.accept(this); } /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit */ public void visit(final PrimaryPrefix n) { // f0 -> . %0 Literal() // .. .. | %1 "this" // .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER > // .. .. | %3 #0 "(" #1 Expression() #2 ")" // .. .. | %4 AllocationExpression() // .. .. | %5 #0 ResultType() #1 "." #2 "class" // .. .. | %6 Name() n.f0.accept(this); } /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit */ public void visit(final PrimarySuffix n) { // f0 -> . %0 #0 "." #1 "this" // .. .. | %1 #0 "." #1 AllocationExpression() // .. .. | %2 MemberSelector() // .. .. | %3 #0 "[" #1 Expression() #2 "]" // .. .. | %4 #0 "." #1 < IDENTIFIER > // .. .. | %5 Arguments() n.f0.accept(this); } /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit */ public void visit(final Literal n) { // f0 -> . %0 < INTEGER_LITERAL > // .. .. | %1 < FLOATING_POINT_LITERAL > // .. .. | %2 < CHARACTER_LITERAL > // .. .. | %3 < STRING_LITERAL > // .. .. | %4 BooleanLiteral() // .. .. | %5 NullLiteral() n.f0.accept(this); } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit */ public void visit(final IntegerLiteral n) { // f0 -> < INTEGER_LITERAL > n.f0.accept(this); } /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit */ public void visit(final BooleanLiteral n) { // f0 -> . %0 "true" // .. .. | %1 "false" n.f0.accept(this); } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ public void visit(final StringLiteral n) { // f0 -> < STRING_LITERAL > n.f0.accept(this); } /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit */ public void visit(final NullLiteral n) { // f0 -> "null" n.f0.accept(this); } /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit */ public void visit(final Arguments n) { // f0 -> "(" n.f0.accept(this); // f1 -> [ ArgumentList() ] n.f1.accept(this); // f2 -> ")" n.f2.accept(this); } /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit */ public void visit(final ArgumentList n) { // f0 -> Expression() n.f0.accept(this); // f1 -> ( #0 "," #1 Expression() )* n.f1.accept(this); } /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit */ public void visit(final AllocationExpression n) { // f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits() // .. .. | %1 #0 "new" #1 ClassOrInterfaceType() // .. .. . .. #2 [ TypeArguments() ] // .. .. . .. #3 ( &0 ArrayDimsAndInits() // .. .. . .. .. | &1 $0 Arguments() // .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] ) n.f0.accept(this); } /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit */ public void visit(final ArrayDimsAndInits n) { // f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+ // .. .. . .. #1 ( $0 "[" $1 "]" )* // .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer() n.f0.accept(this); } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit */ public void visit(final Statement n) { // f0 -> . %00 LabeledStatement() // .. .. | %01 AssertStatement() // .. .. | %02 Block() // .. .. | %03 EmptyStatement() // .. .. | %04 #0 StatementExpression() #1 ";" // .. .. | %05 SwitchStatement() // .. .. | %06 IfStatement() // .. .. | %07 WhileStatement() // .. .. | %08 DoStatement() // .. .. | %09 ForStatement() // .. .. | %10 BreakStatement() // .. .. | %11 ContinueStatement() // .. .. | %12 ReturnStatement() // .. .. | %13 ThrowStatement() // .. .. | %14 SynchronizedStatement() // .. .. | %15 TryStatement() n.f0.accept(this); } /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit */ public void visit(final AssertStatement n) { // f0 -> "assert" n.f0.accept(this); // f1 -> Expression() n.f1.accept(this); // f2 -> [ #0 ":" #1 Expression() ] n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit */ public void visit(final LabeledStatement n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ":" n.f1.accept(this); // f2 -> Statement() n.f2.accept(this); } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final Block n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( BlockStatement() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit */ public void visit(final BlockStatement n) { // f0 -> . %0 #0 LocalVariableDeclaration() #1 ";" // .. .. | %1 Statement() // .. .. | %2 ClassOrInterfaceDeclaration() n.f0.accept(this); } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit */ public void visit(final LocalVariableDeclaration n) { // f0 -> Modifiers() n.f0.accept(this); // f1 -> Type() n.f1.accept(this); // f2 -> VariableDeclarator() n.f2.accept(this); // f3 -> ( #0 "," #1 VariableDeclarator() )* n.f3.accept(this); } /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit */ public void visit(final EmptyStatement n) { // f0 -> ";" n.f0.accept(this); } /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit */ public void visit(final StatementExpression n) { // f0 -> . %0 PreIncrementExpression() // .. .. | %1 PreDecrementExpression() // .. .. | %2 #0 PrimaryExpression() // .. .. . .. #1 [ &0 "++" // .. .. . .. .. | &1 "--" // .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ] n.f0.accept(this); } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit */ public void visit(final SwitchStatement n) { // f0 -> "switch" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> ( #0 SwitchLabel() // .. .. . #1 ( BlockStatement() )* )* n.f5.accept(this); // f6 -> "}" n.f6.accept(this); } /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit */ public void visit(final SwitchLabel n) { // f0 -> . %0 #0 "case" #1 Expression() #2 ":" // .. .. | %1 #0 "default" #1 ":" n.f0.accept(this); } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit */ public void visit(final IfStatement n) { // f0 -> "if" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); // f5 -> [ #0 "else" #1 Statement() ] n.f5.accept(this); } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ public void visit(final WhileStatement n) { // f0 -> "while" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit */ public void visit(final DoStatement n) { // f0 -> "do" n.f0.accept(this); // f1 -> Statement() n.f1.accept(this); // f2 -> "while" n.f2.accept(this); // f3 -> "(" n.f3.accept(this); // f4 -> Expression() n.f4.accept(this); // f5 -> ")" n.f5.accept(this); // f6 -> ";" n.f6.accept(this); } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ public void visit(final ForStatement n) { // f0 -> "for" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression() // .. .. | %1 #0 [ ForInit() ] #1 ";" // .. .. . .. #2 [ Expression() ] #3 ";" // .. .. . .. #4 [ ForUpdate() ] ) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); } /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit */ public void visit(final ForInit n) { // f0 -> . %0 LocalVariableDeclaration() // .. .. | %1 StatementExpressionList() n.f0.accept(this); } /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit */ public void visit(final StatementExpressionList n) { // f0 -> StatementExpression() n.f0.accept(this); // f1 -> ( #0 "," #1 StatementExpression() )* n.f1.accept(this); } /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit */ public void visit(final ForUpdate n) { // f0 -> StatementExpressionList() n.f0.accept(this); } /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final BreakStatement n) { // f0 -> "break" n.f0.accept(this); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ContinueStatement n) { // f0 -> "continue" n.f0.accept(this); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ReturnStatement n) { // f0 -> "return" n.f0.accept(this); // f1 -> [ Expression() ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ThrowStatement n) { // f0 -> "throw" n.f0.accept(this); // f1 -> Expression() n.f1.accept(this); // f2 -> ";" n.f2.accept(this); } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit */ public void visit(final SynchronizedStatement n) { // f0 -> "synchronized" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Block() n.f4.accept(this); } /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ public void visit(final TryStatement n) { // f0 -> "try" n.f0.accept(this); // f1 -> Block() n.f1.accept(this); // f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )* n.f2.accept(this); // f3 -> [ #0 "finally" #1 Block() ] n.f3.accept(this); } /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit */ public void visit(final RUNSIGNEDSHIFT n) { // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); // f2 -> ">" n.f2.accept(this); } /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit */ public void visit(final RSIGNEDSHIFT n) { // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); } /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit */ public void visit(final Annotation n) { // f0 -> . %0 NormalAnnotation() // .. .. | %1 SingleMemberAnnotation() // .. .. | %2 MarkerAnnotation() n.f0.accept(this); } /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit */ public void visit(final NormalAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> [ MemberValuePairs() ] n.f3.accept(this); // f4 -> ")" n.f4.accept(this); } /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit */ public void visit(final MarkerAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); } /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit */ public void visit(final SingleMemberAnnotation n) { // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> MemberValue() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); } /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit */ public void visit(final MemberValuePairs n) { // f0 -> MemberValuePair() n.f0.accept(this); // f1 -> ( #0 "," #1 MemberValuePair() )* n.f1.accept(this); } /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit */ public void visit(final MemberValuePair n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> "=" n.f1.accept(this); // f2 -> MemberValue() n.f2.accept(this); } /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit */ public void visit(final MemberValue n) { // f0 -> . %0 Annotation() // .. .. | %1 MemberValueArrayInitializer() // .. .. | %2 ConditionalExpression() n.f0.accept(this); } /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit */ public void visit(final MemberValueArrayInitializer n) { // f0 -> "{" n.f0.accept(this); // f1 -> MemberValue() n.f1.accept(this); // f2 -> ( #0 "," #1 MemberValue() )* n.f2.accept(this); // f3 -> [ "," ] n.f3.accept(this); // f4 -> "}" n.f4.accept(this); } /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit */ public void visit(final AnnotationTypeDeclaration n) { // f0 -> "@" n.f0.accept(this); // f1 -> "interface" n.f1.accept(this); // f2 -> < IDENTIFIER > n.f2.accept(this); // f3 -> AnnotationTypeBody() n.f3.accept(this); } /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final AnnotationTypeBody n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( AnnotationTypeMemberDeclaration() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); } /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit */ public void visit(final AnnotationTypeMemberDeclaration n) { // f0 -> . %0 #0 Modifiers() // .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")" // .. .. . .. .. $4 [ DefaultValue() ] $5 ";" // .. .. . .. .. | &1 ClassOrInterfaceDeclaration() // .. .. . .. .. | &2 EnumDeclaration() // .. .. . .. .. | &3 AnnotationTypeDeclaration() // .. .. . .. .. | &4 FieldDeclaration() ) // .. .. | %1 ";" n.f0.accept(this); } /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit */ public void visit(final DefaultValue n) { // f0 -> "default" n.f0.accept(this); // f1 -> MemberValue() n.f1.accept(this); } } jtb-1.4.4/EDU/purdue/jtb/visitor/ExpansionUnitTypeCounter.java0000644000175000017500000001612311360636742024202 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; /** * The ExpansionUnitTypeCounter visitor counts the different types of the ExpansionUnits found in an * ExpansionChoices subtree, without descending further into the tree than the first ExpansionUnit * level.
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class ExpansionUnitTypeCounter extends DepthFirstVoidVisitor { /** Number of lookaheads counter */ private int numLookaheads = 0; /** Number of blocks counter */ private int numBlocks = 0; /** Number of options counter */ private int numBrackets = 0; /** Number of trys counter */ private int numTrys = 0; /** Number of BNF modifiers counter */ private int numModifiers = 0; /** Number of terms counter */ private int numTerms = 0; /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { // f0 -> Expansion() n.f0.accept(this); // f1 -> ( #0 "|" #1 Expansion() )* final NodeListOptional nlo = n.f1; if (nlo.present()) { for (int i = 0; i < nlo.size(); i++) { final NodeSequence seq = (NodeSequence) nlo.elementAt(i); seq.elementAt(0).accept(this); seq.elementAt(1).accept(this); } } } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )? // don't visit // f1 -> ( ExpansionUnit() )+ for (int i = 0; i < n.f1.size(); i++) { n.f1.elementAt(i).accept(this); } } /** * Visits the {@link ExpansionUnit}
* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { switch (n.f0.which) { case 0: ++numLookaheads; break; case 1: ++numBlocks; break; case 2: ++numBrackets; break; case 3: ++numTrys; break; case 4: ++numTerms; break; case 5: ++numModifiers; break; default: Messages.hardErr("which = " + String.valueOf(n.f0.which)); } } /** * Resets the counters. */ public void reset() { numLookaheads = numBlocks = numBrackets = numTrys = numTerms = numModifiers = 0; } /** * @return the number of goupings (brackets, trys and modifiers) plus the number of terms */ public int getNumNormals() { return numBrackets + numTrys + numModifiers + numTerms; } /** * @return the number of goupings (brackets, trys and modifiers) */ public int getNumGroupings() { return numBrackets + numTrys + numModifiers; } /** * @return the number of lookaheads */ public int getNumLookaheads() { return numLookaheads; } /** * @return the number of blocks */ public int getNumBlocks() { return numBlocks; } /** * @return the number of brackets */ public int getNumBrackets() { return numBrackets; } /** * @return the number of trys */ public int getNumTrys() { return numTrys; } /** * @return the number of terms */ public int getNumTerms() { return numTerms; } /** * @return the number of modifiers */ public int getNumModifiers() { return numModifiers; } } jtb-1.4.4/EDU/purdue/jtb/visitor/DepthFirstVoidArguVisitor.java0000644000175000017500000025213411416555700024271 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; import java.util.*; /** * Provides default methods which visit each node in the tree in depth-first order.
* In your "VoidArgu" visitors extend this class and override part or all of these methods. * * @param
The user argument type */ public class DepthFirstVoidArguVisitor implements IVoidArguVisitor { /* * Base nodes classes visit methods (to be overridden if necessary) */ /** * Visits a {@link NodeChoice} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeChoice n, final A argu) { n.choice.accept(this, argu); return; } /** * Visits a {@link NodeList} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeList n, final A argu) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this, argu); } return; } /** * Visits a {@link NodeListOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeListOptional n, final A argu) { if (n.present()) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this, argu); } return; } else return; } /** * Visits a {@link NodeOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeOptional n, final A argu) { if (n.present()) { n.node.accept(this, argu); return; } else return; } /** * Visits a {@link NodeSequence} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeSequence n, final A argu) { for (final Iterator e = n.elements(); e.hasNext();) { e.next().accept(this, argu); } return; } /** * Visits a {@link NodeToken} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeToken n, @SuppressWarnings("unused") final A argu) { @SuppressWarnings("unused") final String tkIm = n.tokenImage; return; } /* * User grammar generated visit methods (to be overridden if necessary) */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final AFancyProduction n, final A argu) { // try { // f0 -> ( #0 ( Annotation() )* // .. .. . #1 ( %0 LabeledStatement() // .. .. . .. | %1 AssertStatement() // .. .. . .. | %2 Block() // .. .. . .. | %3 EmptyStatement() // .. .. . .. | %4 $0 StatementExpression() $1 ";" // .. .. . .. | %5 SwitchStatement() // .. .. . .. | %6 TryStatement() ) // .. .. . #2 [ MarkerAnnotation() ] ) // } // catch (Name() < IDENTIFIER >) Block() // catch (Name() < IDENTIFIER >) Block() // finally Block() n.f0.accept(this, argu); } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCCInput n, final A argu) { // f0 -> JavaCCOptions() n.f0.accept(this, argu); // f1 -> "PARSER_BEGIN" n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> Identifier() n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); // f5 -> CompilationUnit() n.f5.accept(this, argu); // f6 -> "PARSER_END" n.f6.accept(this, argu); // f7 -> "(" n.f7.accept(this, argu); // f8 -> Identifier() n.f8.accept(this, argu); // f9 -> ")" n.f9.accept(this, argu); // f10 -> ( Production() )+ n.f10.accept(this, argu); } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCCOptions n, final A argu) { // f0 -> [ #0 "options" #1 "{" // .. .. . #2 ( OptionBinding() )* #3 "}" ] n.f0.accept(this, argu); } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final OptionBinding n, final A argu) { // f0 -> ( %0 < IDENTIFIER > // .. .. | %1 "LOOKAHEAD" // .. .. | %2 "IGNORE_CASE" // .. .. | %3 "static" ) n.f0.accept(this, argu); // f1 -> "=" n.f1.accept(this, argu); // f2 -> ( %0 IntegerLiteral() // .. .. | %1 BooleanLiteral() // .. .. | %2 StringLiteral() ) n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Production n, final A argu) { // f0 -> . %0 JavaCodeProduction() // .. .. | %1 RegularExprProduction() // .. .. | %2 TokenManagerDecls() // .. .. | %3 BNFProduction() n.f0.accept(this, argu); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCodeProduction n, final A argu) { // f0 -> "JAVACODE" n.f0.accept(this, argu); // f1 -> AccessModifier() n.f1.accept(this, argu); // f2 -> ResultType() n.f2.accept(this, argu); // f3 -> Identifier() n.f3.accept(this, argu); // f4 -> FormalParameters() n.f4.accept(this, argu); // f5 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f5.accept(this, argu); // f6 -> Block() n.f6.accept(this, argu); } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BNFProduction n, final A argu) { // f0 -> AccessModifier() n.f0.accept(this, argu); // f1 -> ResultType() n.f1.accept(this, argu); // f2 -> Identifier() n.f2.accept(this, argu); // f3 -> FormalParameters() n.f3.accept(this, argu); // f4 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f4.accept(this, argu); // f5 -> ":" n.f5.accept(this, argu); // f6 -> Block() n.f6.accept(this, argu); // f7 -> "{" n.f7.accept(this, argu); // f8 -> ExpansionChoices() n.f8.accept(this, argu); // f9 -> "}" n.f9.accept(this, argu); } /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final AccessModifier n, final A argu) { // f0 -> ( %0 "public" // .. .. | %1 "protected" // .. .. | %2 "private" )? n.f0.accept(this, argu); } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegularExprProduction n, final A argu) { // f0 -> [ %0 #0 "<" #1 "*" #2 ">" // .. .. | %1 #0 "<" #1 < IDENTIFIER > // .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ] n.f0.accept(this, argu); // f1 -> RegExprKind() n.f1.accept(this, argu); // f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ] n.f2.accept(this, argu); // f3 -> ":" n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> RegExprSpec() n.f5.accept(this, argu); // f6 -> ( #0 "|" #1 RegExprSpec() )* n.f6.accept(this, argu); // f7 -> "}" n.f7.accept(this, argu); } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final TokenManagerDecls n, final A argu) { // f0 -> "TOKEN_MGR_DECLS" n.f0.accept(this, argu); // f1 -> ":" n.f1.accept(this, argu); // f2 -> ClassOrInterfaceBody() n.f2.accept(this, argu); } /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegExprKind n, final A argu) { // f0 -> . %0 "TOKEN" // .. .. | %1 "SPECIAL_TOKEN" // .. .. | %2 "SKIP" // .. .. | %3 "MORE" n.f0.accept(this, argu); } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegExprSpec n, final A argu) { // f0 -> RegularExpression() n.f0.accept(this, argu); // f1 -> [ Block() ] n.f1.accept(this, argu); // f2 -> [ #0 ":" #1 < IDENTIFIER > ] n.f2.accept(this, argu); } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionChoices n, final A argu) { // f0 -> Expansion() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 Expansion() )* n.f1.accept(this, argu); } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final Expansion n, final A argu) { // f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )? n.f0.accept(this, argu); // f1 -> ( ExpansionUnit() )+ n.f1.accept(this, argu); } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final LocalLookahead n, final A argu) { // f0 -> [ IntegerLiteral() ] n.f0.accept(this, argu); // f1 -> [ "," ] n.f1.accept(this, argu); // f2 -> [ ExpansionChoices() ] n.f2.accept(this, argu); // f3 -> [ "," ] n.f3.accept(this, argu); // f4 -> [ #0 "{" #1 Expression() #2 "}" ] n.f4.accept(this, argu); } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionUnit n, final A argu) { // f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // .. .. | %1 Block() // .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]" // .. .. | %3 ExpansionUnitInTCF() // .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. . .. .. | &1 $0 RegularExpression() // .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) // .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" )? n.f0.accept(this, argu); } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionUnitInTCF n, final A argu) { // f0 -> "try" n.f0.accept(this, argu); // f1 -> "{" n.f1.accept(this, argu); // f2 -> ExpansionChoices() n.f2.accept(this, argu); // f3 -> "}" n.f3.accept(this, argu); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* n.f4.accept(this, argu); // f5 -> [ #0 "finally" #1 Block() ] n.f5.accept(this, argu); } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegularExpression n, final A argu) { // f0 -> . %0 StringLiteral() // .. .. | %1 #0 < LANGLE : "<" > // .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" > // .. .. | %2 #0 "<" #1 Identifier() #2 ">" // .. .. | %3 #0 "<" #1 "EOF" #2 ">" n.f0.accept(this, argu); } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpressionChoices n, final A argu) { // f0 -> ComplexRegularExpression() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 ComplexRegularExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpression n, final A argu) { // f0 -> ( ComplexRegularExpressionUnit() )+ n.f0.accept(this, argu); } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpressionUnit n, final A argu) { // f0 -> . %0 StringLiteral() // .. .. | %1 #0 "<" #1 Identifier() #2 ">" // .. .. | %2 CharacterList() // .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" // .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral() // .. .. . .. .. . .. $2 [ £0 "," // .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )? n.f0.accept(this, argu); } /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @param argu the user argument */ public void visit(final CharacterList n, final A argu) { // f0 -> [ "~" ] n.f0.accept(this, argu); // f1 -> "[" n.f1.accept(this, argu); // f2 -> [ #0 CharacterDescriptor() // .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ] n.f2.accept(this, argu); // f3 -> "]" n.f3.accept(this, argu); } /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final CharacterDescriptor n, final A argu) { // f0 -> StringLiteral() n.f0.accept(this, argu); // f1 -> [ #0 "-" #1 StringLiteral() ] n.f1.accept(this, argu); } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument */ public void visit(final Identifier n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); } /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaIdentifier n, final A argu) { // f0 -> ( %00 < IDENTIFIER > // .. .. | %01 "LOOKAHEAD" // .. .. | %02 "IGNORE_CASE" // .. .. | %03 "PARSER_BEGIN" // .. .. | %04 "PARSER_END" // .. .. | %05 "JAVACODE" // .. .. | %06 "TOKEN" // .. .. | %07 "SPECIAL_TOKEN" // .. .. | %08 "MORE" // .. .. | %09 "SKIP" // .. .. | %10 "TOKEN_MGR_DECLS" // .. .. | %11 "EOF" ) n.f0.accept(this, argu); } /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final CompilationUnit n, final A argu) { // f0 -> [ PackageDeclaration() ] n.f0.accept(this, argu); // f1 -> ( ImportDeclaration() )* n.f1.accept(this, argu); // f2 -> ( TypeDeclaration() )* n.f2.accept(this, argu); } /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final PackageDeclaration n, final A argu) { // f0 -> ( Annotation() )* n.f0.accept(this, argu); // f1 -> "package" n.f1.accept(this, argu); // f2 -> Name() n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ImportDeclaration n, final A argu) { // f0 -> "import" n.f0.accept(this, argu); // f1 -> [ "static" ] n.f1.accept(this, argu); // f2 -> Name() n.f2.accept(this, argu); // f3 -> [ #0 "." #1 "*" ] n.f3.accept(this, argu); // f4 -> ";" n.f4.accept(this, argu); } /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final Modifiers n, final A argu) { // f0 -> ( ( %00 "public" // .. .. . | %01 "static" // .. .. . | %02 "protected" // .. .. . | %03 "private" // .. .. . | %04 "final" // .. .. . | %05 "abstract" // .. .. . | %06 "synchronized" // .. .. . | %07 "native" // .. .. . | %08 "transient" // .. .. . | %09 "volatile" // .. .. . | %10 "strictfp" // .. .. . | %11 Annotation() ) )* n.f0.accept(this, argu); } /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeDeclaration n, final A argu) { // f0 -> . %0 ";" // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 AnnotationTypeDeclaration() ) n.f0.accept(this, argu); } /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceDeclaration n, final A argu) { // f0 -> ( %0 "class" // .. .. | %1 "interface" ) n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ TypeParameters() ] n.f2.accept(this, argu); // f3 -> [ ExtendsList() ] n.f3.accept(this, argu); // f4 -> [ ImplementsList() ] n.f4.accept(this, argu); // f5 -> ClassOrInterfaceBody() n.f5.accept(this, argu); } /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExtendsList n, final A argu) { // f0 -> "extends" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); } /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ImplementsList n, final A argu) { // f0 -> "implements" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); } /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumDeclaration n, final A argu) { // f0 -> "enum" n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ ImplementsList() ] n.f2.accept(this, argu); // f3 -> EnumBody() n.f3.accept(this, argu); } /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumBody n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> [ #0 EnumConstant() // .. .. . #1 ( $0 "," $1 EnumConstant() )* ] n.f1.accept(this, argu); // f2 -> [ "," ] n.f2.accept(this, argu); // f3 -> [ #0 ";" // .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ] n.f3.accept(this, argu); // f4 -> "}" n.f4.accept(this, argu); } /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumConstant n, final A argu) { // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> [ Arguments() ] n.f2.accept(this, argu); // f3 -> [ ClassOrInterfaceBody() ] n.f3.accept(this, argu); } /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeParameters n, final A argu) { // f0 -> "<" n.f0.accept(this, argu); // f1 -> TypeParameter() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 TypeParameter() )* n.f2.accept(this, argu); // f3 -> ">" n.f3.accept(this, argu); } /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeParameter n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> [ TypeBound() ] n.f1.accept(this, argu); } /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeBound n, final A argu) { // f0 -> "extends" n.f0.accept(this, argu); // f1 -> ClassOrInterfaceType() n.f1.accept(this, argu); // f2 -> ( #0 "&" #1 ClassOrInterfaceType() )* n.f2.accept(this, argu); } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceBody n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( ClassOrInterfaceBodyDeclaration() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); } /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceBodyDeclaration n, final A argu) { // f0 -> . %0 Initializer() // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 ConstructorDeclaration() // .. .. . .. .. | &3 FieldDeclaration() // .. .. . .. .. | &4 MethodDeclaration() ) // .. .. | %2 ";" n.f0.accept(this, argu); } /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final FieldDeclaration n, final A argu) { // f0 -> Type() n.f0.accept(this, argu); // f1 -> VariableDeclarator() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 VariableDeclarator() )* n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableDeclarator n, final A argu) { // f0 -> VariableDeclaratorId() n.f0.accept(this, argu); // f1 -> [ #0 "=" #1 VariableInitializer() ] n.f1.accept(this, argu); } /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableDeclaratorId n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> ( #0 "[" #1 "]" )* n.f1.accept(this, argu); } /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableInitializer n, final A argu) { // f0 -> . %0 ArrayInitializer() // .. .. | %1 Expression() n.f0.accept(this, argu); } /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArrayInitializer n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> [ #0 VariableInitializer() // .. .. . #1 ( $0 "," $1 VariableInitializer() )* ] n.f1.accept(this, argu); // f2 -> [ "," ] n.f2.accept(this, argu); // f3 -> "}" n.f3.accept(this, argu); } /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @param argu the user argument */ public void visit(final MethodDeclaration n, final A argu) { // f0 -> [ TypeParameters() ] n.f0.accept(this, argu); // f1 -> ResultType() n.f1.accept(this, argu); // f2 -> MethodDeclarator() n.f2.accept(this, argu); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this, argu); // f4 -> ( %0 Block() // .. .. | %1 ";" ) n.f4.accept(this, argu); } /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MethodDeclarator n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> FormalParameters() n.f1.accept(this, argu); // f2 -> ( #0 "[" #1 "]" )* n.f2.accept(this, argu); } /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final FormalParameters n, final A argu) { // f0 -> "(" n.f0.accept(this, argu); // f1 -> [ #0 FormalParameter() // .. .. . #1 ( $0 "," $1 FormalParameter() )* ] n.f1.accept(this, argu); // f2 -> ")" n.f2.accept(this, argu); } /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @param argu the user argument */ public void visit(final FormalParameter n, final A argu) { // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> Type() n.f1.accept(this, argu); // f2 -> [ "..." ] n.f2.accept(this, argu); // f3 -> VariableDeclaratorId() n.f3.accept(this, argu); } /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConstructorDeclaration n, final A argu) { // f0 -> [ TypeParameters() ] n.f0.accept(this, argu); // f1 -> < IDENTIFIER > n.f1.accept(this, argu); // f2 -> FormalParameters() n.f2.accept(this, argu); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> [ ExplicitConstructorInvocation() ] n.f5.accept(this, argu); // f6 -> ( BlockStatement() )* n.f6.accept(this, argu); // f7 -> "}" n.f7.accept(this, argu); } /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExplicitConstructorInvocation n, final A argu) { // f0 -> . %0 #0 "this" #1 Arguments() #2 ";" // .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";" n.f0.accept(this, argu); } /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Initializer n, final A argu) { // f0 -> [ "static" ] n.f0.accept(this, argu); // f1 -> Block() n.f1.accept(this, argu); } /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Type n, final A argu) { // f0 -> . %0 ReferenceType() // .. .. | %1 PrimitiveType() n.f0.accept(this, argu); } /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ReferenceType n, final A argu) { // f0 -> . %0 #0 PrimitiveType() // .. .. . .. #1 ( $0 "[" $1 "]" )+ // .. .. | %1 #0 ClassOrInterfaceType() // .. .. . .. #1 ( $0 "[" $1 "]" )* n.f0.accept(this, argu); } /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceType n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> [ TypeArguments() ] n.f1.accept(this, argu); // f2 -> ( #0 "." #1 < IDENTIFIER > // .. .. . #2 [ TypeArguments() ] )* n.f2.accept(this, argu); } /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeArguments n, final A argu) { // f0 -> "<" n.f0.accept(this, argu); // f1 -> TypeArgument() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 TypeArgument() )* n.f2.accept(this, argu); // f3 -> ">" n.f3.accept(this, argu); } /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeArgument n, final A argu) { // f0 -> . %0 ReferenceType() // .. .. | %1 #0 "?" // .. .. . .. #1 [ WildcardBounds() ] n.f0.accept(this, argu); } /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @param argu the user argument */ public void visit(final WildcardBounds n, final A argu) { // f0 -> . %0 #0 "extends" #1 ReferenceType() // .. .. | %1 #0 "super" #1 ReferenceType() n.f0.accept(this, argu); } /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimitiveType n, final A argu) { // f0 -> . %0 "boolean" // .. .. | %1 "char" // .. .. | %2 "byte" // .. .. | %3 "short" // .. .. | %4 "int" // .. .. | %5 "long" // .. .. | %6 "float" // .. .. | %7 "double" n.f0.accept(this, argu); } /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final ResultType n, final A argu) { // f0 -> ( %0 "void" // .. .. | %1 Type() ) n.f0.accept(this, argu); } /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final Name n, final A argu) { // f0 -> JavaIdentifier() n.f0.accept(this, argu); // f1 -> ( #0 "." #1 JavaIdentifier() )* n.f1.accept(this, argu); } /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final NameList n, final A argu) { // f0 -> Name() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 Name() )* n.f1.accept(this, argu); } /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final Expression n, final A argu) { // f0 -> ConditionalExpression() n.f0.accept(this, argu); // f1 -> [ #0 AssignmentOperator() #1 Expression() ] n.f1.accept(this, argu); } /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @param argu the user argument */ public void visit(final AssignmentOperator n, final A argu) { // f0 -> . %00 "=" // .. .. | %01 "*=" // .. .. | %02 "/=" // .. .. | %03 "%=" // .. .. | %04 "+=" // .. .. | %05 "-=" // .. .. | %06 "<<=" // .. .. | %07 ">>=" // .. .. | %08 ">>>=" // .. .. | %09 "&=" // .. .. | %10 "^=" // .. .. | %11 "|=" n.f0.accept(this, argu); } /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalExpression n, final A argu) { // f0 -> ConditionalOrExpression() n.f0.accept(this, argu); // f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ] n.f1.accept(this, argu); } /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalOrExpression n, final A argu) { // f0 -> ConditionalAndExpression() n.f0.accept(this, argu); // f1 -> ( #0 "||" #1 ConditionalAndExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalAndExpression n, final A argu) { // f0 -> InclusiveOrExpression() n.f0.accept(this, argu); // f1 -> ( #0 "&&" #1 InclusiveOrExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final InclusiveOrExpression n, final A argu) { // f0 -> ExclusiveOrExpression() n.f0.accept(this, argu); // f1 -> ( #0 "|" #1 ExclusiveOrExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExclusiveOrExpression n, final A argu) { // f0 -> AndExpression() n.f0.accept(this, argu); // f1 -> ( #0 "^" #1 AndExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final AndExpression n, final A argu) { // f0 -> EqualityExpression() n.f0.accept(this, argu); // f1 -> ( #0 "&" #1 EqualityExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final EqualityExpression n, final A argu) { // f0 -> InstanceOfExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "==" // .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final InstanceOfExpression n, final A argu) { // f0 -> RelationalExpression() n.f0.accept(this, argu); // f1 -> [ #0 "instanceof" #1 Type() ] n.f1.accept(this, argu); } /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final RelationalExpression n, final A argu) { // f0 -> ShiftExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "<" // .. .. . .. | %1 ">" // .. .. . .. | %2 "<=" // .. .. . .. | %3 ">=" ) #1 ShiftExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ShiftExpression n, final A argu) { // f0 -> AdditiveExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "<<" // .. .. . .. | %1 RSIGNEDSHIFT() // .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final AdditiveExpression n, final A argu) { // f0 -> MultiplicativeExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "+" // .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MultiplicativeExpression n, final A argu) { // f0 -> UnaryExpression() n.f0.accept(this, argu); // f1 -> ( #0 ( %0 "*" // .. .. . .. | %1 "/" // .. .. . .. | %2 "%" ) #1 UnaryExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument */ public void visit(final UnaryExpression n, final A argu) { // f0 -> . %0 #0 ( &0 "+" // .. .. . .. .. | &1 "-" ) #1 UnaryExpression() // .. .. | %1 PreIncrementExpression() // .. .. | %2 PreDecrementExpression() // .. .. | %3 UnaryExpressionNotPlusMinus() n.f0.accept(this, argu); } /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PreIncrementExpression n, final A argu) { // f0 -> "++" n.f0.accept(this, argu); // f1 -> PrimaryExpression() n.f1.accept(this, argu); } /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PreDecrementExpression n, final A argu) { // f0 -> "--" n.f0.accept(this, argu); // f1 -> PrimaryExpression() n.f1.accept(this, argu); } /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final UnaryExpressionNotPlusMinus n, final A argu) { // f0 -> . %0 #0 ( &0 "~" // .. .. . .. .. | &1 "!" ) #1 UnaryExpression() // .. .. | %1 CastExpression() // .. .. | %2 PostfixExpression() n.f0.accept(this, argu); } /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final CastLookahead n, final A argu) { // f0 -> . %0 #0 "(" #1 PrimitiveType() // .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]" // .. .. | %2 #0 "(" #1 Type() #2 ")" // .. .. . .. #3 ( &0 "~" // .. .. . .. .. | &1 "!" // .. .. . .. .. | &2 "(" // .. .. . .. .. | &3 < IDENTIFIER > // .. .. . .. .. | &4 "this" // .. .. . .. .. | &5 "super" // .. .. . .. .. | &6 "new" // .. .. . .. .. | &7 Literal() ) n.f0.accept(this, argu); } /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final PostfixExpression n, final A argu) { // f0 -> PrimaryExpression() n.f0.accept(this, argu); // f1 -> [ %0 "++" // .. .. | %1 "--" ] n.f1.accept(this, argu); } /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument */ public void visit(final CastExpression n, final A argu) { // f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression() // .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus() n.f0.accept(this, argu); } /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimaryExpression n, final A argu) { // f0 -> PrimaryPrefix() n.f0.accept(this, argu); // f1 -> ( PrimarySuffix() )* n.f1.accept(this, argu); } /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberSelector n, final A argu) { // f0 -> "." n.f0.accept(this, argu); // f1 -> TypeArguments() n.f1.accept(this, argu); // f2 -> < IDENTIFIER > n.f2.accept(this, argu); } /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimaryPrefix n, final A argu) { // f0 -> . %0 Literal() // .. .. | %1 "this" // .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER > // .. .. | %3 #0 "(" #1 Expression() #2 ")" // .. .. | %4 AllocationExpression() // .. .. | %5 #0 ResultType() #1 "." #2 "class" // .. .. | %6 Name() n.f0.accept(this, argu); } /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimarySuffix n, final A argu) { // f0 -> . %0 #0 "." #1 "this" // .. .. | %1 #0 "." #1 AllocationExpression() // .. .. | %2 MemberSelector() // .. .. | %3 #0 "[" #1 Expression() #2 "]" // .. .. | %4 #0 "." #1 < IDENTIFIER > // .. .. | %5 Arguments() n.f0.accept(this, argu); } /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Literal n, final A argu) { // f0 -> . %0 < INTEGER_LITERAL > // .. .. | %1 < FLOATING_POINT_LITERAL > // .. .. | %2 < CHARACTER_LITERAL > // .. .. | %3 < STRING_LITERAL > // .. .. | %4 BooleanLiteral() // .. .. | %5 NullLiteral() n.f0.accept(this, argu); } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @param argu the user argument */ public void visit(final IntegerLiteral n, final A argu) { // f0 -> < INTEGER_LITERAL > n.f0.accept(this, argu); } /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BooleanLiteral n, final A argu) { // f0 -> . %0 "true" // .. .. | %1 "false" n.f0.accept(this, argu); } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @param argu the user argument */ public void visit(final StringLiteral n, final A argu) { // f0 -> < STRING_LITERAL > n.f0.accept(this, argu); } /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @param argu the user argument */ public void visit(final NullLiteral n, final A argu) { // f0 -> "null" n.f0.accept(this, argu); } /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final Arguments n, final A argu) { // f0 -> "(" n.f0.accept(this, argu); // f1 -> [ ArgumentList() ] n.f1.accept(this, argu); // f2 -> ")" n.f2.accept(this, argu); } /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArgumentList n, final A argu) { // f0 -> Expression() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 Expression() )* n.f1.accept(this, argu); } /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @param argu the user argument */ public void visit(final AllocationExpression n, final A argu) { // f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits() // .. .. | %1 #0 "new" #1 ClassOrInterfaceType() // .. .. . .. #2 [ TypeArguments() ] // .. .. . .. #3 ( &0 ArrayDimsAndInits() // .. .. . .. .. | &1 $0 Arguments() // .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] ) n.f0.accept(this, argu); } /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArrayDimsAndInits n, final A argu) { // f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+ // .. .. . .. #1 ( $0 "[" $1 "]" )* // .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer() n.f0.accept(this, argu); } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Statement n, final A argu) { // f0 -> . %00 LabeledStatement() // .. .. | %01 AssertStatement() // .. .. | %02 Block() // .. .. | %03 EmptyStatement() // .. .. | %04 #0 StatementExpression() #1 ";" // .. .. | %05 SwitchStatement() // .. .. | %06 IfStatement() // .. .. | %07 WhileStatement() // .. .. | %08 DoStatement() // .. .. | %09 ForStatement() // .. .. | %10 BreakStatement() // .. .. | %11 ContinueStatement() // .. .. | %12 ReturnStatement() // .. .. | %13 ThrowStatement() // .. .. | %14 SynchronizedStatement() // .. .. | %15 TryStatement() n.f0.accept(this, argu); } /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AssertStatement n, final A argu) { // f0 -> "assert" n.f0.accept(this, argu); // f1 -> Expression() n.f1.accept(this, argu); // f2 -> [ #0 ":" #1 Expression() ] n.f2.accept(this, argu); // f3 -> ";" n.f3.accept(this, argu); } /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final LabeledStatement n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> ":" n.f1.accept(this, argu); // f2 -> Statement() n.f2.accept(this, argu); } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final Block n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( BlockStatement() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @param argu the user argument */ public void visit(final BlockStatement n, final A argu) { // f0 -> . %0 #0 LocalVariableDeclaration() #1 ";" // .. .. | %1 Statement() // .. .. | %2 ClassOrInterfaceDeclaration() n.f0.accept(this, argu); } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final LocalVariableDeclaration n, final A argu) { // f0 -> Modifiers() n.f0.accept(this, argu); // f1 -> Type() n.f1.accept(this, argu); // f2 -> VariableDeclarator() n.f2.accept(this, argu); // f3 -> ( #0 "," #1 VariableDeclarator() )* n.f3.accept(this, argu); } /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final EmptyStatement n, final A argu) { // f0 -> ";" n.f0.accept(this, argu); } /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final StatementExpression n, final A argu) { // f0 -> . %0 PreIncrementExpression() // .. .. | %1 PreDecrementExpression() // .. .. | %2 #0 PrimaryExpression() // .. .. . .. #1 [ &0 "++" // .. .. . .. .. | &1 "--" // .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ] n.f0.accept(this, argu); } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SwitchStatement n, final A argu) { // f0 -> "switch" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> "{" n.f4.accept(this, argu); // f5 -> ( #0 SwitchLabel() // .. .. . #1 ( BlockStatement() )* )* n.f5.accept(this, argu); // f6 -> "}" n.f6.accept(this, argu); } /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SwitchLabel n, final A argu) { // f0 -> . %0 #0 "case" #1 Expression() #2 ":" // .. .. | %1 #0 "default" #1 ":" n.f0.accept(this, argu); } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final IfStatement n, final A argu) { // f0 -> "if" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); // f5 -> [ #0 "else" #1 Statement() ] n.f5.accept(this, argu); } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final WhileStatement n, final A argu) { // f0 -> "while" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final DoStatement n, final A argu) { // f0 -> "do" n.f0.accept(this, argu); // f1 -> Statement() n.f1.accept(this, argu); // f2 -> "while" n.f2.accept(this, argu); // f3 -> "(" n.f3.accept(this, argu); // f4 -> Expression() n.f4.accept(this, argu); // f5 -> ")" n.f5.accept(this, argu); // f6 -> ";" n.f6.accept(this, argu); } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForStatement n, final A argu) { // f0 -> "for" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression() // .. .. | %1 #0 [ ForInit() ] #1 ";" // .. .. . .. #2 [ Expression() ] #3 ";" // .. .. . .. #4 [ ForUpdate() ] ) n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Statement() n.f4.accept(this, argu); } /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForInit n, final A argu) { // f0 -> . %0 LocalVariableDeclaration() // .. .. | %1 StatementExpressionList() n.f0.accept(this, argu); } /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final StatementExpressionList n, final A argu) { // f0 -> StatementExpression() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 StatementExpression() )* n.f1.accept(this, argu); } /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForUpdate n, final A argu) { // f0 -> StatementExpressionList() n.f0.accept(this, argu); } /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BreakStatement n, final A argu) { // f0 -> "break" n.f0.accept(this, argu); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); } /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ContinueStatement n, final A argu) { // f0 -> "continue" n.f0.accept(this, argu); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ReturnStatement n, final A argu) { // f0 -> "return" n.f0.accept(this, argu); // f1 -> [ Expression() ] n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); } /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ThrowStatement n, final A argu) { // f0 -> "throw" n.f0.accept(this, argu); // f1 -> Expression() n.f1.accept(this, argu); // f2 -> ";" n.f2.accept(this, argu); } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final SynchronizedStatement n, final A argu) { // f0 -> "synchronized" n.f0.accept(this, argu); // f1 -> "(" n.f1.accept(this, argu); // f2 -> Expression() n.f2.accept(this, argu); // f3 -> ")" n.f3.accept(this, argu); // f4 -> Block() n.f4.accept(this, argu); } /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TryStatement n, final A argu) { // f0 -> "try" n.f0.accept(this, argu); // f1 -> Block() n.f1.accept(this, argu); // f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )* n.f2.accept(this, argu); // f3 -> [ #0 "finally" #1 Block() ] n.f3.accept(this, argu); } /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RUNSIGNEDSHIFT n, final A argu) { // f0 -> ">" n.f0.accept(this, argu); // f1 -> ">" n.f1.accept(this, argu); // f2 -> ">" n.f2.accept(this, argu); } /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RSIGNEDSHIFT n, final A argu) { // f0 -> ">" n.f0.accept(this, argu); // f1 -> ">" n.f1.accept(this, argu); } /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Annotation n, final A argu) { // f0 -> . %0 NormalAnnotation() // .. .. | %1 SingleMemberAnnotation() // .. .. | %2 MarkerAnnotation() n.f0.accept(this, argu); } /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final NormalAnnotation n, final A argu) { // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> [ MemberValuePairs() ] n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); } /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MarkerAnnotation n, final A argu) { // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); } /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SingleMemberAnnotation n, final A argu) { // f0 -> "@" n.f0.accept(this, argu); // f1 -> Name() n.f1.accept(this, argu); // f2 -> "(" n.f2.accept(this, argu); // f3 -> MemberValue() n.f3.accept(this, argu); // f4 -> ")" n.f4.accept(this, argu); } /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValuePairs n, final A argu) { // f0 -> MemberValuePair() n.f0.accept(this, argu); // f1 -> ( #0 "," #1 MemberValuePair() )* n.f1.accept(this, argu); } /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValuePair n, final A argu) { // f0 -> < IDENTIFIER > n.f0.accept(this, argu); // f1 -> "=" n.f1.accept(this, argu); // f2 -> MemberValue() n.f2.accept(this, argu); } /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValue n, final A argu) { // f0 -> . %0 Annotation() // .. .. | %1 MemberValueArrayInitializer() // .. .. | %2 ConditionalExpression() n.f0.accept(this, argu); } /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValueArrayInitializer n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> MemberValue() n.f1.accept(this, argu); // f2 -> ( #0 "," #1 MemberValue() )* n.f2.accept(this, argu); // f3 -> [ "," ] n.f3.accept(this, argu); // f4 -> "}" n.f4.accept(this, argu); } /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeDeclaration n, final A argu) { // f0 -> "@" n.f0.accept(this, argu); // f1 -> "interface" n.f1.accept(this, argu); // f2 -> < IDENTIFIER > n.f2.accept(this, argu); // f3 -> AnnotationTypeBody() n.f3.accept(this, argu); } /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeBody n, final A argu) { // f0 -> "{" n.f0.accept(this, argu); // f1 -> ( AnnotationTypeMemberDeclaration() )* n.f1.accept(this, argu); // f2 -> "}" n.f2.accept(this, argu); } /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeMemberDeclaration n, final A argu) { // f0 -> . %0 #0 Modifiers() // .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")" // .. .. . .. .. $4 [ DefaultValue() ] $5 ";" // .. .. . .. .. | &1 ClassOrInterfaceDeclaration() // .. .. . .. .. | &2 EnumDeclaration() // .. .. . .. .. | &3 AnnotationTypeDeclaration() // .. .. . .. .. | &4 FieldDeclaration() ) // .. .. | %1 ";" n.f0.accept(this, argu); } /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @param argu the user argument */ public void visit(final DefaultValue n, final A argu) { // f0 -> "default" n.f0.accept(this, argu); // f1 -> MemberValue() n.f1.accept(this, argu); } } jtb-1.4.4/EDU/purdue/jtb/visitor/TokenTableBuilder.java0000644000175000017500000002244411360636742022536 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import java.util.Hashtable; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpression; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpressionChoices; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpressionUnit; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.JavaCCInput; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.Production; import EDU.purdue.jtb.syntaxtree.RegExprSpec; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.StringLiteral; /** * Generates a symbol lookup table of tokens which have a constant regular expression, e.g. < PLUS : * "+" >, which will be used to generate a default constructor. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 */ public class TokenTableBuilder extends DepthFirstVoidVisitor { /** The Hashtable keys = token names, values = regular expressions */ private final Hashtable table = new Hashtable(); /** Stores the current name */ private String name = ""; /** Stores the current regular expression */ private String regExpr = ""; /** * The returned Hashtable has the names of the tokens as the keys and the constant regular * expressions as the values or "" if the regular expression is not constant. * * @return the Hashtable */ public Hashtable getTokenTable() { return table; } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // visit only Production n.f10.accept(this); } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ @Override public void visit(final Production n) { // visit only RegularExprProduction if (n.f0.which == 1) n.f0.accept(this); } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(final RegularExprProduction n) { // visit only RegExprSpec n.f5.accept(this); n.f6.accept(this); } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit */ @Override public void visit(final RegExprSpec n) { // visit only RegularExpression n.f0.accept(this); } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(final RegularExpression n) { if (n.f0.which == 1) { // [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) "> final NodeSequence seq = (NodeSequence) n.f0.choice; final NodeOptional opt = (NodeOptional) seq.elementAt(1); if (opt.present()) { // name is set further down the tree seq.elementAt(1).accept(this); // regExpr is set further down the tree seq.elementAt(2).accept(this); table.put(name, regExpr); // reset for next pass name = ""; regExpr = ""; } } } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpressionChoices n) { if (n.f1.present()) // if f1 is present, this isn't a constant regexpr regExpr = ""; else n.f0.accept(this); } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpression n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpressionUnit n) { if (n.f0.which == 0) // StringLiteral() n.f0.accept(this); else // others regExpr = ""; } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { name = n.f0.tokenImage; } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { regExpr = n.f0.tokenImage; } } jtb-1.4.4/EDU/purdue/jtb/visitor/IRetVisitor.java0000644000175000017500000014765011416555700021425 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; /** * All "Ret" visitors must implement this interface. * @param The user return information type */ public interface IRetVisitor { /* * Base "Ret" visit methods */ /** * Visits a {@link NodeList} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeList n); /** * Visits a {@link NodeListOptional} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeListOptional n); /** * Visits a {@link NodeOptional} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeOptional n); /** * Visits a {@link NodeSequence} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeSequence n); /** * Visits a {@link NodeToken} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeToken n); /* * User grammar generated visit methods */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @return the user return information */ public R visit(final AFancyProduction n); /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCCInput n); /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCCOptions n); /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final OptionBinding n); /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @return the user return information */ public R visit(final Production n); /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCodeProduction n); /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final BNFProduction n); /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @return the user return information */ public R visit(final AccessModifier n); /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final RegularExprProduction n); /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @return the user return information */ public R visit(final TokenManagerDecls n); /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @return the user return information */ public R visit(final RegExprKind n); /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @return the user return information */ public R visit(final RegExprSpec n); /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionChoices n); /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @return the user return information */ public R visit(final Expansion n); /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @return the user return information */ public R visit(final LocalLookahead n); /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionUnit n); /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionUnitInTCF n); /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RegularExpression n); /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpressionChoices n); /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpression n); /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpressionUnit n); /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @return the user return information */ public R visit(final CharacterList n); /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @return the user return information */ public R visit(final CharacterDescriptor n); /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @return the user return information */ public R visit(final Identifier n); /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @return the user return information */ public R visit(final JavaIdentifier n); /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @return the user return information */ public R visit(final CompilationUnit n); /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final PackageDeclaration n); /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ImportDeclaration n); /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @return the user return information */ public R visit(final Modifiers n); /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @return the user return information */ public R visit(final TypeDeclaration n); /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceDeclaration n); /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExtendsList n); /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ImplementsList n); /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @return the user return information */ public R visit(final EnumDeclaration n); /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final EnumBody n); /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @return the user return information */ public R visit(final EnumConstant n); /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final TypeParameters n); /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TypeParameter n); /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final TypeBound n); /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceBody n); /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceBodyDeclaration n); /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final FieldDeclaration n); /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @return the user return information */ public R visit(final VariableDeclarator n); /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final VariableDeclaratorId n); /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @return the user return information */ public R visit(final VariableInitializer n); /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ArrayInitializer n); /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @return the user return information */ public R visit(final MethodDeclaration n); /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final MethodDeclarator n); /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final FormalParameters n); /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @return the user return information */ public R visit(final FormalParameter n); /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ConstructorDeclaration n); /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ExplicitConstructorInvocation n); /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final Initializer n); /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @return the user return information */ public R visit(final Type n); /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final ReferenceType n); /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceType n); /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final TypeArguments n); /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TypeArgument n); /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @return the user return information */ public R visit(final WildcardBounds n); /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @return the user return information */ public R visit(final PrimitiveType n); /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @return the user return information */ public R visit(final ResultType n); /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @return the user return information */ public R visit(final Name n); /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @return the user return information */ public R visit(final NameList n); /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final Expression n); /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @return the user return information */ public R visit(final AssignmentOperator n); /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalExpression n); /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalOrExpression n); /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalAndExpression n); /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final InclusiveOrExpression n); /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExclusiveOrExpression n); /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final AndExpression n); /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final EqualityExpression n); /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @return the user return information */ public R visit(final InstanceOfExpression n); /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final RelationalExpression n); /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ShiftExpression n); /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final AdditiveExpression n); /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final MultiplicativeExpression n); /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @return the user return information */ public R visit(final UnaryExpression n); /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final PreIncrementExpression n); /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final PreDecrementExpression n); /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final UnaryExpressionNotPlusMinus n); /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @return the user return information */ public R visit(final CastLookahead n); /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @return the user return information */ public R visit(final PostfixExpression n); /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @return the user return information */ public R visit(final CastExpression n); /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @return the user return information */ public R visit(final PrimaryExpression n); /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @return the user return information */ public R visit(final MemberSelector n); /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @return the user return information */ public R visit(final PrimaryPrefix n); /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @return the user return information */ public R visit(final PrimarySuffix n); /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @return the user return information */ public R visit(final Literal n); /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @return the user return information */ public R visit(final IntegerLiteral n); /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @return the user return information */ public R visit(final BooleanLiteral n); /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @return the user return information */ public R visit(final StringLiteral n); /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @return the user return information */ public R visit(final NullLiteral n); /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final Arguments n); /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ArgumentList n); /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @return the user return information */ public R visit(final AllocationExpression n); /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @return the user return information */ public R visit(final ArrayDimsAndInits n); /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @return the user return information */ public R visit(final Statement n); /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final AssertStatement n); /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final LabeledStatement n); /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final Block n); /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @return the user return information */ public R visit(final BlockStatement n); /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @return the user return information */ public R visit(final LocalVariableDeclaration n); /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final EmptyStatement n); /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final StatementExpression n); /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final SwitchStatement n); /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @return the user return information */ public R visit(final SwitchLabel n); /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @return the user return information */ public R visit(final IfStatement n); /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final WhileStatement n); /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final DoStatement n); /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final ForStatement n); /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @return the user return information */ public R visit(final ForInit n); /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final StatementExpressionList n); /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @return the user return information */ public R visit(final ForUpdate n); /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final BreakStatement n); /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ContinueStatement n); /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ReturnStatement n); /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ThrowStatement n); /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final SynchronizedStatement n); /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TryStatement n); /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RUNSIGNEDSHIFT n); /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RSIGNEDSHIFT n); /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @return the user return information */ public R visit(final Annotation n); /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final NormalAnnotation n); /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @return the user return information */ public R visit(final MarkerAnnotation n); /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final SingleMemberAnnotation n); /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValuePairs n); /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValuePair n); /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValue n); /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValueArrayInitializer n); /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeDeclaration n); /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeBody n); /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeMemberDeclaration n); /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @return the user return information */ public R visit(final DefaultValue n); } jtb-1.4.4/EDU/purdue/jtb/visitor/JavaCCPrinter.java0000644000175000017500000011515111364243676021634 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Iterator; import EDU.purdue.jtb.misc.FileExistsException; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.JavaBranchPrinter; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.Spacing; import EDU.purdue.jtb.misc.UnicodeConverter; import EDU.purdue.jtb.syntaxtree.AccessModifier; import EDU.purdue.jtb.syntaxtree.BNFProduction; import EDU.purdue.jtb.syntaxtree.CharacterDescriptor; import EDU.purdue.jtb.syntaxtree.CharacterList; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpression; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpressionChoices; import EDU.purdue.jtb.syntaxtree.ComplexRegularExpressionUnit; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.IntegerLiteral; import EDU.purdue.jtb.syntaxtree.JavaCCInput; import EDU.purdue.jtb.syntaxtree.JavaCCOptions; import EDU.purdue.jtb.syntaxtree.JavaCodeProduction; import EDU.purdue.jtb.syntaxtree.LocalLookahead; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.syntaxtree.OptionBinding; import EDU.purdue.jtb.syntaxtree.Production; import EDU.purdue.jtb.syntaxtree.RegExprKind; import EDU.purdue.jtb.syntaxtree.RegExprSpec; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.StringLiteral; import EDU.purdue.jtb.syntaxtree.TokenManagerDecls; /** * The JavaCCPrinter visitor reprints (with indentation) the JavaCC grammar JavaCC specific * productions.
* (The JavaCC grammar Java productions are handled by the JavaPrinter visitor.) *

* Implementation notes : *

* To be Done : extract methods for custom formatting
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5
* 1.4.0 : 11/2009 : MMa : output commented JTB options */ public class JavaCCPrinter extends DepthFirstVoidVisitor { /** The buffer to print into */ protected StringBuilder sb; /** Indentation object */ protected Spacing spc; /** BNF nesting level, starts at 0 (in BNFProduction), incremented for each new level */ protected int bnfLvl = 0; /** Visitor to print a java node and its subtree */ protected JavaBranchPrinter jbpv; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /* * Constructors */ /** * Constructor with a given buffer and indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) * @param aSPC the Spacing indentation object (will be allocated and set to a default if null) */ public JavaCCPrinter(final StringBuilder aSB, final Spacing aSPC) { sb = aSB; if (sb == null) sb = new StringBuilder(2048); spc = aSPC; if (spc == null) spc = new Spacing(Globals.INDENT_AMT); jbpv = new JavaBranchPrinter(spc); } /** * Constructor which will allocate a default buffer and indentation. */ public JavaCCPrinter() { this(null, null); } /** * Constructor with a given buffer and which will allocate a default indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) */ public JavaCCPrinter(final StringBuilder aSB) { this(aSB, null); } /** * Constructor with a given indentation which will allocate a default buffer. * * @param aSPC the Spacing indentation object */ public JavaCCPrinter(final Spacing aSPC) { this(null, aSPC); } /** * Saves the current buffer to an output file. * * @param outFile the output file * @throws FileExistsException if the file exists and the noOverwrite flag is set */ public void saveToFile(final String outFile) throws FileExistsException { try { final File file = new File(outFile); if (Globals.noOverwrite && file.exists()) throw new FileExistsException(outFile); else { final PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file), sb.length())); out.print(sb); out.close(); } } catch (final IOException e) { Messages.hardErr(e); } } /* * Base classes visit methods */ /** * Prints into the current buffer a NodeToken image and its specials before if global flag set. * * @param n the node to visit */ @Override public void visit(final NodeToken n) { sb.append(Globals.keepSpecialTokens ? n.withSpecials(spc.spc) : n.tokenImage); } /* * Convenience methods */ /** * Generates a java node and its subtree with a JavaPrinter. * * @param n the node to process * @return a buffer with the generated source */ protected StringBuilder genJavaBranch(final INode n) { return jbpv.genJavaBranch(n); } /** * Prints into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void oneNewLine(final INode n) { sb.append(nodeClassComment(n)).append(LS); } /** * Prints into the current buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment */ void oneNewLine(final INode n, final String str) { sb.append(nodeClassComment(n, str)).append(LS); } /** * Prints twice into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void twoNewLines(final INode n) { oneNewLine(n); oneNewLine(n); } /** * Prints three times into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ void threeNewLines(final INode n) { oneNewLine(n); oneNewLine(n); oneNewLine(n); } /** * Returns a node class comment (a //§§ followed by the node class short name if global flag set, * nothing otherwise). * * @param n the node for the node class comment * @return the node class comment */ private String nodeClassComment(final INode n) { if (Globals.PRINT_CLASS_COMMENT) { final String s = n.toString(); final int b = s.lastIndexOf('.') + 1; final int e = s.indexOf('@'); if (b == -1 || e == -1) return " //§§ " + s; else return " //§§ " + s.substring(b, e); } else return ""; } /** * Returns a node class comment with an extra comment (a //§§ followed by the node class short * name plus the extra comment if global flag set, nothing otherwise). * * @param n the node for the node class comment * @param str the extra comment * @return the node class comment */ private String nodeClassComment(final INode n, final String str) { if (Globals.PRINT_CLASS_COMMENT) return nodeClassComment(n) + " " + str; else return ""; } /* * User grammar generated and overridden visit methods below */ /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // we do not use sb.append(spc.spc) as indent level should be 0 at this point // f0 -> JavaCCOptions() n.f0.accept(this); oneNewLine(n); oneNewLine(n); oneNewLine(n); // f1 -> "PARSER_BEGIN" n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); oneNewLine(n); // f5 -> CompilationUnit() sb.append(genJavaBranch(n.f5)); // f6 -> "PARSER_END" n.f6.accept(this); // f7 -> "(" n.f7.accept(this); // f8 -> Identifier() n.f8.accept(this); // f9 -> ")" n.f9.accept(this); oneNewLine(n); oneNewLine(n); oneNewLine(n); // f10 -> ( Production() )+ for (final Iterator e = n.f10.elements(); e.hasNext();) { // Production() e.next().accept(this); if (e.hasNext()) { oneNewLine(n); oneNewLine(n); } } oneNewLine(n); } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit */ @Override public void visit(final JavaCCOptions n) { if (n.f0.present()) { final NodeSequence seq = (NodeSequence) n.f0.node; // "options" seq.elementAt(0).accept(this); oneNewLine(n); // "{" seq.elementAt(1).accept(this); // ( OptionBinding() )* final NodeListOptional nlo = (NodeListOptional) seq.elementAt(2); if (nlo.present()) { spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); for (final Iterator e = nlo.elements(); e.hasNext();) { // OptionBinding() e.next().accept(this); if (e.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } // "}" seq.elementAt(3).accept(this); } } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit */ @Override public void visit(final OptionBinding n) { // f0 -> ( < IDENTIFIER > | "LOOKAHEAD" | "IGNORE_CASE" | "static" ) // comment JTB options if (n.f0.which == 0) { final NodeToken nt = (NodeToken) n.f0.choice; if ((nt).tokenImage.startsWith("JTB_")) { if (Globals.keepSpecialTokens) sb.append(nt.getSpecials(spc.spc)); sb.append("// ").append(nt.tokenImage); } else n.f0.choice.accept(this); } else n.f0.choice.accept(this); sb.append(" "); // f1 -> "=" n.f1.accept(this); sb.append(" "); // f2 -> ( IntegerLiteral() | BooleanLiteral() | StringLiteral() ) n.f2.accept(this); // f3 -> ";" n.f3.accept(this); } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ @Override public void visit(final Production n) { // no difference with super class n.f0.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(final JavaCodeProduction n) { // f0 -> "JAVACODE" n.f0.accept(this); oneNewLine(n); sb.append(spc.spc); // f1 -> AccessModifier(p) n.f1.accept(this); // f2 -> ResultType(p.getReturnTypeTokens()) sb.append(genJavaBranch(n.f2)); // f3 -> Identifier() n.f3.accept(this); // f4 -> FormalParameters(p.getParameterListTokens()) sb.append(genJavaBranch(n.f4)); // f5 -> [ "throws" Name(excName) ( "," Name(excName) )* ] if (n.f5.present()) { final NodeSequence seq = (NodeSequence) n.f5.node; sb.append(" "); // "throws" seq.elementAt(0).accept(this); sb.append(" "); // Name(excName) sb.append(genJavaBranch(seq.elementAt(1))); // ( "," Name(excName) )* final NodeListOptional opt = ((NodeListOptional) seq.elementAt(2)); if (opt.present()) { for (final Iterator e = opt.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "," sb.append(genJavaBranch(seq1.elementAt(0))); sb.append(" "); // Name(excName) sb.append(genJavaBranch(seq1.elementAt(1))); } } } oneNewLine(n); sb.append(spc.spc); // f6 -> Block(p.getCodeTokens()) sb.append(genJavaBranch(n.f6)); } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ @Override public void visit(final BNFProduction n) { bnfLvl = 0; // f0 -> AccessModifier(p) n.f0.accept(this); // f1 -> ResultType(p.getReturnTypeTokens()) sb.append(genJavaBranch(n.f1)); sb.append(" "); // f2 -> Identifier() n.f2.accept(this); // f3 -> FormalParameters(p.getParameterListTokens()) sb.append(genJavaBranch(n.f3)); // f4 -> [ "throws" Name(excName) ( "," Name(excName) )* ] if (n.f4.present()) { final NodeSequence seq = (NodeSequence) n.f4.node; sb.append(" "); // "throws" seq.elementAt(0).accept(this); sb.append(" "); // Name(excName) sb.append(genJavaBranch(seq.elementAt(1))); final NodeListOptional opt = ((NodeListOptional) seq.elementAt(2)); if (opt.present()) { for (final Iterator e = (opt).elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "," seq1.elementAt(0).accept(this); sb.append(" "); // Name(excName) sb.append(genJavaBranch(seq1.elementAt(1))); } } } // f5 -> ":" n.f5.accept(this); oneNewLine(n); sb.append(spc.spc); // f6 -> Block(p.getDeclarationTokens()) sb.append(genJavaBranch(n.f6)); oneNewLine(n); sb.append(spc.spc); // f7 -> "{" n.f7.accept(this); oneNewLine(n); spc.updateSpc(+1); sb.append(spc.spc); // f8 -> ExpansionChoices(c) n.f8.accept(this); oneNewLine(n); spc.updateSpc(-1); sb.append(spc.spc); // f9 -> "}" n.f9.accept(this); oneNewLine(n); } /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit */ @Override public void visit(final AccessModifier n) { if (n.f0.present()) { ((NodeChoice) n.f0.node).choice.accept(this); sb.append(" "); } } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(final RegularExprProduction n) { // f0 -> [ "<" "*" ">" | "<" < IDENTIFIER > ( "," < IDENTIFIER > )* ">" ] if (n.f0.present()) { n.f0.node.accept(this); oneNewLine(n); } // f1 -> RegExprKind(p) n.f1.accept(this); // f2 -> [ "[" "IGNORE_CASE" "]" ] if (n.f2.present()) { sb.append(" "); n.f2.node.accept(this); } sb.append(" "); // f3 -> ":" n.f3.accept(this); oneNewLine(n); // f4 -> "{" n.f4.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f5 -> RegExprSpec() n.f5.accept(this); // f6 -> ( "|" RegExprSpec(p) )* if (n.f6.present()) { for (final Iterator e = n.f6.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); oneNewLine(n); // "|" seq.elementAt(0).accept(this); sb.append(" "); // RegExprSpec(p) seq.elementAt(1).accept(this); } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); // f7 -> "}" n.f7.accept(this); } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit */ @Override public void visit(final TokenManagerDecls n) { // f0 -> "TOKEN_MGR_DECLS" n.f0.accept(this); sb.append(" "); // f1 -> ":" n.f1.accept(this); sb.append(" "); // f2 -> ClassOrInterfaceBody(false,decls) sb.append(genJavaBranch(n.f2)); } /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit */ @Override public void visit(final RegExprKind n) { // no difference with superclass n.f0.accept(this); } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit */ @Override public void visit(final RegExprSpec n) { // f0 -> RegularExpression(c) n.f0.accept(this); // f1 -> [ Block(act.getActionTokens()) ] if (n.f1.present()) { oneNewLine(n); spc.updateSpc(+1); sb.append(spc.spc); sb.append(genJavaBranch(n.f1.node)); spc.updateSpc(-1); } // f2 -> [ ":" < IDENTIFIER > ] if (n.f2.present()) { final NodeSequence seq = (NodeSequence) n.f2.node; sb.append(" "); // ":" sb.append(seq.elementAt(0)); sb.append(" "); // < IDENTIFIER > sb.append(seq.elementAt(1)); } } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { if (!n.f1.present()) { // f0 -> Expansion(c1) n.f0.accept(this); } else { // f0 -> Expansion(c1) ++bnfLvl; n.f0.accept(this); --bnfLvl; // f1 -> ( "|" Expansion(c2) )* for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); if (bnfLvl != 0) sb.append(" "); else { oneNewLine(n); sb.append(spc.spc); } // "|" seq.elementAt(0).accept(this); sb.append(" "); // Expansion(c2) ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; } } } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // f0 -> ( "LOOKAHEAD" "(" LocalLookahead() ")" )? if (n.f0.present()) { final NodeSequence seq = (NodeSequence) n.f0.node; // "LOOKAHEAD" seq.elementAt(0).accept(this); sb.append(" "); // "(" seq.elementAt(1).accept(this); sb.append(" "); // LocalLookahead() seq.elementAt(2).accept(this); sb.append(" "); // ")" seq.elementAt(3).accept(this); } // f1 -> ( ExpansionUnit(c2) )+ for (final Iterator e = n.f1.elements(); e.hasNext();) { // ExpansionUnit(c2) e.next().accept(this); if (e.hasNext()) if (bnfLvl == 0) { oneNewLine(n); sb.append(spc.spc); } else sb.append(" "); } } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit */ @Override public void visit(final LocalLookahead n) { // f0 -> [ IntegerLiteral() ] if (n.f0.present()) n.f0.accept(this); // f1 -> [ "," ] if (n.f1.present()) { n.f1.accept(this); sb.append(" "); } // f2 -> [ ExpansionChoices(c) ] if (n.f2.present()) { ++bnfLvl; n.f2.node.accept(this); --bnfLvl; } // f3 -> [ "," ] if (n.f3.present()) { n.f3.accept(this); sb.append(" "); } // f4 -> [ "{" Expression(la.getActionTokens()) "}" ] if (n.f4.present()) { final NodeSequence seq = (NodeSequence) n.f4.node; // "{" seq.elementAt(0).accept(this); sb.append(" "); sb.append(genJavaBranch(seq.elementAt(1))); sb.append(" "); // "}" seq.elementAt(2).accept(this); } } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { NodeSequence seq; NodeOptional opt; NodeChoice ch; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // #0 "LOOKAHEAD" seq = ((NodeSequence) n.f0.choice); seq.elementAt(0).accept(this); sb.append(" "); // #1 "(" seq.elementAt(1).accept(this); sb.append(" "); // #2 LocalLookahead() seq.elementAt(2).accept(this); sb.append(" "); // #3 ")" seq.elementAt(3).accept(this); break; case 1: // %1 Block() sb.append(genJavaBranch(n.f0.choice)); break; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" seq = ((NodeSequence) n.f0.choice); seq.elementAt(0).accept(this); sb.append(" "); ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; sb.append(" "); seq.elementAt(2).accept(this); break; case 3: // %3 ExpansionUnitInTCF() n.f0.choice.accept(this); break; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) seq = (NodeSequence) n.f0.choice; // #0 [ $0 PrimaryExpression() $1 "=" ] opt = (NodeOptional) seq.elementAt(0); if (opt.present()) { // $0 PrimaryExpression() ((NodeSequence) opt.node).elementAt(0).accept(this); sb.append(" "); // $1 "=" ((NodeSequence) opt.node).elementAt(1).accept(this); sb.append(" "); } // #1 ( &0 $0 Identifier() $1 Arguments() &1 $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] ) ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; if (ch.which == 0) { // &0 $0 Identifier() $1 Arguments() seq1.elementAt(0).accept(this); sb.append(genJavaBranch(seq1.elementAt(1))); } else { // &1 $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] seq1.elementAt(0).accept(this); final NodeOptional opt1 = (NodeOptional) seq1.elementAt(1); if (opt1.present()) { ((NodeToken) ((NodeSequence) opt1.node).elementAt(0)).accept(this); ((NodeToken) ((NodeSequence) opt1.node).elementAt(1)).accept(this); } } break; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? seq = (NodeSequence) n.f0.choice; // #0 "(" seq.elementAt(0).accept(this); sb.append(" "); //#1 ExpansionChoices() ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; sb.append(" "); // #2 ")" seq.elementAt(2).accept(this); // #3 ( &0 "+" | &1 "*" | &2 "?" )? opt = (NodeOptional) seq.elementAt(3); if (opt.present()) { opt.node.accept(this); } break; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); break; } } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f0 -> "try" n.f0.accept(this); sb.append(" "); //f1 -> "{" n.f1.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f2 -> ExpansionChoices() n.f2.accept(this); sb.append(" "); spc.updateSpc(-1); // f3 -> "}" n.f3.accept(this); oneNewLine(n); sb.append(spc.spc); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* if (n.f4.present()) { for (int i = 0; i < n.f4.size(); i++) { final NodeSequence seq = (NodeSequence) n.f4.elementAt(i); // #0 "catch" seq.elementAt(0).accept(this); sb.append(" "); // #1 "(" seq.elementAt(1).accept(this); // #2 Name() sb.append(genJavaBranch(seq.elementAt(2))); sb.append(" "); // #3 < IDENTIFIER > sb.append(((NodeToken) seq.elementAt(3)).tokenImage); // #4 ")" seq.elementAt(3).accept(this); // #5 Block() sb.append(genJavaBranch(seq.elementAt(4))); oneNewLine(n); } } // f5 -> [ #0 "finally" #1 Block() ] if (n.f5.present()) { // #0 "finally" (((NodeSequence) n.f5.node).elementAt(0)).accept(this); sb.append(" "); // #1 Block() sb.append(genJavaBranch(((NodeSequence) n.f5.node).elementAt(1))); oneNewLine(n); } } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(final RegularExpression n) { if (n.f0.which == 0) // StringLiteral() n.f0.choice.accept(this); else if (n.f0.which == 1) { // [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) "> final NodeSequence seq = (NodeSequence) n.f0.choice; // "<" seq.elementAt(0).accept(this); sb.append(" "); final NodeOptional opt = (NodeOptional) seq.elementAt(1); if (opt.present()) { final NodeSequence seq1 = (NodeSequence) opt.node; if (((NodeOptional) seq1.elementAt(0)).present()) // "#" seq1.elementAt(0).accept(this); // Identifier() seq1.elementAt(1).accept(this); sb.append(" "); // ":" seq1.elementAt(2).accept(this); sb.append(" "); } // ComplexRegularExpressionChoices(c) seq.elementAt(2).accept(this); sb.append(" "); // ">" seq.elementAt(3).accept(this); } else { // "<" Identifier() ">" or "<" "EOF" ">" // "<" ((NodeSequence) n.f0.choice).elementAt(0).accept(this); sb.append(" "); // Identifier() or "EOF" ((NodeSequence) n.f0.choice).elementAt(1).accept(this); sb.append(" "); // ">" ((NodeSequence) n.f0.choice).elementAt(2).accept(this); } } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpressionChoices n) { // f0 -> ComplexRegularExpression(c1) n.f0.accept(this); // f1 -> ( "|" ComplexRegularExpression(c2) )* if (n.f1.present()) for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "|" seq.elementAt(0).accept(this); sb.append(" "); // ComplexRegularExpression(c2) seq.elementAt(1).accept(this); } } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpression n) { for (final Iterator e = n.f0.elements(); e.hasNext();) { // ComplexRegularExpressionUnit(c2) e.next().accept(this); if (e.hasNext()) sb.append(" "); } } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit */ @Override public void visit(final ComplexRegularExpressionUnit n) { if (n.f0.which == 0 || n.f0.which == 2) // StringLiteral() or CharacterList(c) n.f0.choice.accept(this); else if (n.f0.which == 1) { // "<" ((NodeSequence) n.f0.choice).elementAt(0).accept(this); // Identifier() ((NodeSequence) n.f0.choice).elementAt(1).accept(this); // ">" ((NodeSequence) n.f0.choice).elementAt(2).accept(this); } else { // "(" ComplexRegularExpressionChoices(c) ")" ( "+" | "*" | "?" | "{" IntegerLiteral() [ "," [ IntegerLiteral() ] ] "}" )? final NodeSequence seq = (NodeSequence) n.f0.choice; // "(" seq.elementAt(0).accept(this); sb.append(" "); // ComplexRegularExpressionChoices(c) seq.elementAt(1).accept(this); sb.append(" "); // ")" seq.elementAt(2).accept(this); final NodeOptional opt = (NodeOptional) seq.elementAt(3); if (opt.present()) { final NodeChoice ch = (NodeChoice) opt.node; if (ch.which <= 2) // "+" or "*" or "?" ch.choice.accept(this); else { // "{" IntegerLiteral() [ "," [ IntegerLiteral() ] ] "}" final NodeSequence seq1 = (NodeSequence) ch.choice; // "{" seq1.elementAt(0).accept(this); // IntegerLiteral() seq1.elementAt(1).accept(this); final NodeOptional opt1 = (NodeOptional) seq1.elementAt(2); if (opt1.present()) { // "," ((NodeSequence) opt1.node).elementAt(0).accept(this); sb.append(" "); // IntegerLiteral() ((NodeSequence) opt1.node).elementAt(1).accept(this); } // "}" seq1.elementAt(3).accept(this); } } } } /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit */ @Override public void visit(final CharacterList n) { // f0 -> [ "~" ] if (n.f0.present()) n.f0.accept(this); // f1 -> "[" n.f1.accept(this); // f2 -> [ CharacterDescriptor(c2) ( "," CharacterDescriptor(c2) )* ] if (n.f2.present()) { final NodeSequence seq = (NodeSequence) n.f2.node; // CharacterDescriptor(c2) seq.elementAt(0).accept(this); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(1); for (final Iterator e = nlo.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); // "," seq1.elementAt(0).accept(this); sb.append(" "); // CharacterDescriptor(c2) seq1.elementAt(1).accept(this); } } // f3 -> "]" n.f3.accept(this); } /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit */ @Override public void visit(final CharacterDescriptor n) { // f0 -> StringLiteral() n.f0.accept(this); // f1 -> [ "-" StringLiteral() ] if (n.f1.present()) { final NodeSequence seq = (NodeSequence) n.f1.node; // "-" seq.elementAt(0).accept(this); // StringLiteral() seq.elementAt(1).accept(this); } } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { final String str = Globals.keepSpecialTokens ? n.f0.withSpecials(spc.spc) : n.f0.tokenImage; sb.append(UnicodeConverter.addUnicodeEscapes(str)); } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit */ @Override public void visit(final IntegerLiteral n) { final String str = Globals.keepSpecialTokens ? n.f0.withSpecials(spc.spc) : n.f0.tokenImage; sb.append(UnicodeConverter.addUnicodeEscapes(str)); } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { final String str = Globals.keepSpecialTokens ? n.f0.withSpecials(spc.spc) : n.f0.tokenImage; sb.append(UnicodeConverter.addUnicodeEscapes(str)); } } jtb-1.4.4/EDU/purdue/jtb/visitor/AcceptInliner.java0000644000175000017500000006136011365272206021713 0ustar cavedoncavedonpackage EDU.purdue.jtb.visitor; import java.util.Iterator; import EDU.purdue.jtb.misc.ClassInfo; import EDU.purdue.jtb.misc.DepthFirstVisitorsGenerator; import EDU.purdue.jtb.misc.FieldNameGenerator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.JavaBranchPrinter; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.Spacing; import EDU.purdue.jtb.misc.UnicodeConverter; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; /** * The AcceptInliner visitor (an extension of {@link JavaCCPrinter visitor}) is called by * {@link DepthFirstVisitorsGenerator} (which calls * {@link #genAcceptMethods(StringBuilder, Spacing, ClassInfo, boolean, boolean)} to "inline" the * accept methods on the base classes nodes (in order to facilitate the user customization work). *

* TODO add field comments and replace INode with field type * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : creation * @version 1.4.2 : 20/02/2010 : MMa : fixed inlining issue in visit ExpansionChoices * @version 1.4.3.1 : 20/04/2010 : MMa : fixed descriptive field name issues in visit * ExpansionChoices and Expansion * @version 1.4.3.2 : 26/04/2010 : MMa : fixed index issue in visit Expansion */ public class AcceptInliner extends JavaCCPrinter { /** The processed ClassInfo */ ClassInfo ci; /** The ClassInfo field number */ int fn; /** The user return type flag */ boolean ret; /** The user argument flag */ boolean argu; /** The JTB node reference (e.g. n.f0, nF0.choice, ...) */ String ref; /** The JTB node reference type (e.g. NodeChoice, INode, ...) */ String type; /** The variable (e.g. nF0, nF0Ch, ...) to refer to the JTB node reference with proper cast */ String var; /** The loop variable (depth) number (0, 1, 2 ... -> i, i1, i2, ...) */ int lvn; /** The sequence variable number (-1, 0, 1, 2 ... -> Seq, Seq0, Seq1, Seq2, ...) */ int svn; /** The field name generator */ final FieldNameGenerator nameGen = new FieldNameGenerator(); /** * Constructor which does nothing. */ public AcceptInliner() { // nothing done here } /** * Generates the accept methods for all the node tree.
* *@param aSB the buffer to write into (must be allocated) * @param aSpc an indentation (must be valid) * @param aCI the ClassInfo to work on (must be fully initialized, in particular field comments) * @param aRet the user return type flag * @param aArgu the user argument flag */ public void genAcceptMethods(final StringBuilder aSB, final Spacing aSpc, final ClassInfo aCI, final boolean aRet, final boolean aArgu) { sb = aSB; spc = aSpc; bnfLvl = 0; jbpv = new JavaBranchPrinter(spc); ci = aCI; fn = 0; ret = aRet; argu = aArgu; ref = "n"; type = ""; var = "n"; lvn = 0; svn = 0; nameGen.reset(); aCI.getAstNode().accept(this); } /* * Convenience methods */ /** * Prints into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void oneNewLine(final INode n) { sb.append(nodeClassComment(n)).append(LS); } /** * Prints into the current buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment */ @Override void oneNewLine(final INode n, final String str) { sb.append(nodeClassComment(n, str)).append(LS); } /** * Prints twice into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void twoNewLines(final INode n) { oneNewLine(n); oneNewLine(n); } /** * Prints three times into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void threeNewLines(final INode n) { oneNewLine(n); oneNewLine(n); oneNewLine(n); } /** * Returns a node class comment (a //== followed by the node class short name if global flag set, * nothing otherwise). * * @param n the node for the node class comment * @return the node class comment */ private String nodeClassComment(final INode n) { if (Globals.PRINT_CLASS_COMMENT) { final String s = n.toString(); final int b = s.lastIndexOf('.') + 1; final int e = s.indexOf('@'); if (b == -1 || e == -1) return " //== " + s; else return " //== " + s.substring(b, e); } else return ""; } /** * Returns a node class comment with an extra comment (a //== followed by the node class short * name plus the extra comment if global flag set, nothing otherwise). * * @param n the node for the node class comment * @param str the extra comment * @return the node class comment */ private String nodeClassComment(final INode n, final String str) { if (Globals.PRINT_CLASS_COMMENT) return nodeClassComment(n) + " " + str; else return ""; } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { String oldRef = ref; String oldVar = var; String oldType = type; int oldSvn = -1; if (Globals.PRINT_CLASS_COMMENT) { sb.append("// bnfLvl = ").append(bnfLvl); oneNewLine(n, "dbg"); } // only f0 if (!n.f1.present()) { if (Globals.PRINT_CLASS_COMMENT) oneNewLine(n, "f0_a"); svn = -1; // Expansion() n.f0.accept(this); ref = oldRef; var = oldVar; type = oldType; svn = oldSvn; if (Globals.PRINT_CLASS_COMMENT) oneNewLine(n, "f0_b"); return; } // f0 and f1 : generate switch choice // f0 -> Expansion(c1) if (bnfLvl == 0) { type = ci.getFieldTypes().get(fn); // should always be NodeChoice // if (!Globals.descriptiveFieldNames) // ref = ref.concat(".f").concat(String.valueOf(fn)); // else ref = ref.concat(".").concat(ci.getFieldNames().get(fn)); var = var.concat(String.valueOf(fn)).concat("Ch"); sb.append(spc.spc).append("final ").append(type).append(" ").append(var).append(" = ") .append(ref).append(";"); oneNewLine(n); fn++; } else { if (!"NodeChoice".equals(type)) { var = var.concat("Ch"); type = "NodeChoice"; sb.append(spc.spc).append("final NodeChoice ").append(var).append(" = (NodeChoice) ") .append(ref).append(";"); oneNewLine(n); } } ref = var.concat(".choice"); sb.append(spc.spc).append("final INode ").append(var).append("N = ").append(ref).append(";"); type = "INode"; oneNewLine(n); sb.append(spc.spc).append("switch (").append(var).append(".which) {"); oneNewLine(n); var = var.concat("N"); ref = var; spc.updateSpc(+1); sb.append(spc.spc).append("case 0:"); oneNewLine(n); spc.updateSpc(+1); svn = 0; oldRef = ref; oldVar = var; oldType = type; oldSvn = svn; ++bnfLvl; // Expansion() n.f0.accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; svn = oldSvn; sb.append(spc.spc).append("break;"); oneNewLine(n); spc.updateSpc(-1); // f1 -> ( "|" Expansion(c2) )* for (int i = 0; i < n.f1.size();) { final NodeSequence seq = (NodeSequence) n.f1.elementAt(i); i++; sb.append(spc.spc).append("case ").append(i).append(":"); oneNewLine(n); spc.updateSpc(+1); svn = i; ++bnfLvl; // Expansion(c2) seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; svn = oldSvn; sb.append(spc.spc).append("break;"); oneNewLine(n); spc.updateSpc(-1); } sb.append(spc.spc).append("default:"); oneNewLine(n); spc.updateSpc(+1); sb.append(spc.spc).append("// should not occur !!!"); oneNewLine(n); sb.append(spc.spc).append("break;"); oneNewLine(n); spc.updateSpc(-1); spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // don't take f0, only f1 // f1 -> ( ExpansionUnit(c2) )+ : visit something within a sequence (nbEuOk > 1) or directly (nbEuOk == 1) // count the number of non LocalLookahead nor Block ExpansionUnits int nbEuOk = 0; for (final Iterator e = n.f1.elements(); e.hasNext();) { final ExpansionUnit expUnit = (ExpansionUnit) e.next(); if (expUnit.f0.which > 1) nbEuOk++; } if (Globals.PRINT_CLASS_COMMENT) { sb.append("// bnfLvl = ").append(bnfLvl).append(", nbEuOk = ").append(nbEuOk); oneNewLine(n, "dbg"); } if ((bnfLvl > 0) && (nbEuOk > 1) && !"NodeSequence".equals(type)) { var = var.concat("Seq").concat(svn == -1 ? "" : String.valueOf(svn)); type = "NodeSequence"; sb.append(spc.spc).append("final NodeSequence ").append(var).append(" = (NodeSequence) ") .append(ref).append(";"); oneNewLine(n); } int numEuOk = 0; final String oldRef = ref; final String oldVar = var; final String oldType = type; for (int i = 0; i < n.f1.size(); i++) { final ExpansionUnit expUnit = (ExpansionUnit) n.f1.elementAt(i); // don't process LocalLookahead nor Block in ExpansionUnit if (expUnit.f0.which > 1) { if (bnfLvl == 0) { // at first Expansion level // if (!Globals.descriptiveFieldNames) // ref = ref.concat(".f").concat(String.valueOf(fn)); // else ref = ref.concat(".").concat(ci.getFieldNames().get(fn)); var = var.concat(String.valueOf(fn)); type = ci.getFieldTypes().get(fn); sb.append(spc.spc).append("final ").append(type).append(" ").append(var).append(" = ") .append(ref).append(";"); oneNewLine(n); fn++; } else { // at other Expansion levels if (nbEuOk > 1) { final String numEuOkStr = String.valueOf(numEuOk); ref = var.concat(".elementAt(").concat(numEuOkStr).concat(")"); var = var.concat("A").concat(numEuOkStr); type = "INode"; sb.append(spc.spc).append("final INode ").append(var).append(" = ").append(ref) .append(";"); oneNewLine(n); ref = var; } } // visit ++bnfLvl; expUnit.accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; numEuOk++; } } } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { final NodeSequence seq; NodeOptional opt; NodeChoice ch; final String oldRef = ref; final String oldVar = var; final String oldType = type; int oldLvn = lvn; String lvnStr; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // should not be called ! break; case 1: // %1 Block() // should not be called ! break; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" // visit something within a node optional if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 2"); oneNewLine(n, "2_beg"); } seq = (NodeSequence) n.f0.choice; if (!"NodeOptional".equals(type)) { type = "NodeOptional"; sb.append(spc.spc).append("final NodeOptional ").append(var) .append("Opt = (NodeOptional) ").append(var).append(";"); oneNewLine(n); var = var.concat("Opt"); } sb.append(spc.spc).append("if (").append(var).append(".present()) {"); oneNewLine(n); spc.updateSpc(+1); ref = var.concat(".node"); ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n, "2_end"); break; case 3: // %3 ExpansionUnitInTCF() if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 3"); oneNewLine(n, "3_beg"); } n.f0.choice.accept(this); break; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) // #0 [ $0 PrimaryExpression() $1 "=" ] // TODO process ??? // opt = (NodeOptional) seq.elementAt(0); // if (opt.present()) { // sb.append(spc.spc); // ((NodeSequence) opt.node).elementAt(0).accept(this); // sb.append(" = "); // } // #1 ... seq = (NodeSequence) n.f0.choice; ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; if (ch.which == 0) { // $0 Identifier() $1 Arguments() if (Globals.depthLevel) { sb.append(spc.spc).append("++depthLevel;"); oneNewLine(n); } sb.append(spc.spc).append(ret ? "nRes = " : "").append(var).append(".accept(this") .append(argu ? ", argu);" : ");"); oneNewLine(n, "4_Identifier"); if (Globals.depthLevel) { sb.append(spc.spc).append("--depthLevel;"); oneNewLine(n); } } else { // $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] if (Globals.depthLevel) { sb.append(spc.spc).append("++depthLevel;"); oneNewLine(n); } sb.append(spc.spc).append(ret ? "nRes = " : "").append(var).append(".accept(this") .append(argu ? ", argu);" : ");"); oneNewLine(n, "4_RegularExpression"); if (Globals.depthLevel) { sb.append(spc.spc).append("--depthLevel;"); oneNewLine(n); } opt = (NodeOptional) seq1.elementAt(1); if (opt.present()) { // TODO process ??? sb.append("// Please report to support : TODO $1 [ £0 \".\" £1 < IDENTIFIER > ]"); oneNewLine(n, "4_._<_IDENTIFIER_>"); } } break; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? // visit something within a node list for +, a node list optional for *, // a node optional for ?, and something directly for nothing seq = (NodeSequence) n.f0.choice; opt = (NodeOptional) seq.elementAt(3); if (opt.present()) { ch = (NodeChoice) opt.node; if (ch.which == 0) { // "+" modifier : visit something within a node list if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 5 with '+' modifier"); oneNewLine(n, "5_+"); } if (!"NodeList".equals(type)) { type = "NodeList"; sb.append(spc.spc).append("final NodeList ").append(var).append("Lst = (NodeList) ") .append(var).append(";"); oneNewLine(n); var = var.concat("Lst"); } oldLvn = lvn; lvnStr = lvn == 0 ? "" : String.valueOf(lvn); lvn++; sb.append(spc.spc).append("for (int i").append(lvnStr).append(" = 0; i").append(lvnStr) .append(" < ").append(var).append(".size(); i").append(lvnStr).append("++) {"); oneNewLine(n); spc.updateSpc(+1); ref = var.concat(".elementAt(i").concat(String.valueOf(lvnStr)).concat(")"); var = var.concat("Ei"); sb.append(spc.spc).append("final INode ").append(var).append(" = ").append(ref) .append(";"); oneNewLine(n); ref = var; ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; lvn = oldLvn; spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); } else if (ch.which == 1) { // "*" modifier : visit something within a node list optional if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 5 with '*' modifier"); oneNewLine(n, "5_*"); } if (!"NodeListOptional".equals(type)) { type = "NodeListOptional"; sb.append(spc.spc).append("final NodeListOptional ").append(var) .append("Nlo = (NodeListOptional) ").append(var).append(";"); oneNewLine(n); var = var.concat("Nlo"); } sb.append(spc.spc).append("if (").append(var).append(".present()) {"); oneNewLine(n); spc.updateSpc(+1); oldLvn = lvn; lvnStr = lvn == 0 ? "" : String.valueOf(lvn); lvn++; sb.append(spc.spc).append("for (int i").append(lvnStr).append(" = 0; i").append(lvnStr) .append(" < ").append(var).append(".size(); i").append(lvnStr).append("++) {"); oneNewLine(n); spc.updateSpc(+1); ref = var.concat(".elementAt(i").concat(String.valueOf(lvnStr)).concat(")"); var = var.concat("Ei"); sb.append(spc.spc).append("final INode ").append(var).append(" = ").append(ref) .append(";"); oneNewLine(n); ref = var; ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; lvn = oldLvn; spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); } else { // "?" modifier : visit something within a node optional if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 5 with '?' modifier"); oneNewLine(n, "5_?"); } if (!"NodeOptional".equals(type)) { type = "NodeOptional"; sb.append(spc.spc).append("final NodeOptional ").append(var) .append("Opt = (NodeOptional) ").append(var).append(";"); oneNewLine(n); var = var.concat("Opt"); } sb.append(spc.spc).append("if (").append(var).append(".present()) {"); oneNewLine(n); spc.updateSpc(+1); ref = var.concat(".node"); ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); } } else { // no modifier : visit something directly if (Globals.PRINT_CLASS_COMMENT) { sb.append(spc.spc).append("// ExpansionUnit type 5 with no modifiers"); oneNewLine(n, "5_no"); } ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; ref = oldRef; var = oldVar; type = oldType; } break; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); break; } } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f0 -> "try" sb.append(spc.spc).append(genJavaBranch(n.f0)); // f1 -> "{" sb.append(" ").append(genJavaBranch(n.f1)); oneNewLine(n); spc.updateSpc(+1); // f2 -> ExpansionChoices() n.f2.accept(this); // f3 -> "}" spc.updateSpc(-1); sb.append(spc.spc).append("}"); oneNewLine(n); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* if (n.f4.present()) for (int i = 0; i < n.f4.size(); i++) { final NodeSequence seq = (NodeSequence) n.f4.elementAt(i); // #0 "catch" sb.append(spc.spc).append(genJavaBranch(seq.elementAt(0))); // #1 "(" sb.append(" ").append(genJavaBranch(seq.elementAt(1))); // #2 Name() sb.append(genJavaBranch(seq.elementAt(2))); // #3 < IDENTIFIER > sb.append(" ").append(genJavaBranch(seq.elementAt(3))); // #4 ")" sb.append(genJavaBranch(seq.elementAt(4))); // #5 Block() sb.append(spc.spc).append(genJavaBranch(seq.elementAt(5))); oneNewLine(n); } // f5 -> [ #0 "finally" #1 Block() ] if (n.f5.present()) { final NodeSequence seq = (NodeSequence) n.f5.node; // #0 "finally" sb.append(spc.spc).append(genJavaBranch(seq.elementAt(0))); // #1 Block() sb.append(" ").append(genJavaBranch(seq.elementAt(1))); oneNewLine(n); } } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); } // /** // * Visits a {@link IntegerLiteral} node, whose children are the following : // *

// * f0 -> < INTEGER_LITERAL >
// * // * @param n the node to visit // */ // @Override // public void visit(final IntegerLiteral n) { // sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); // } // // /** // * Visits a {@link StringLiteral} node, whose children are the following : // *

// * f0 -> < STRING_LITERAL >
// * // * @param n the node to visit // */ // @Override // public void visit(final StringLiteral n) { // sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); // } // } jtb-1.4.4/EDU/purdue/jtb/visitor/IVoidVisitor.java0000644000175000017500000013511311416555700021563 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; /** * All "Void" visitors must implement this interface. */ public interface IVoidVisitor { /* * Base "Void" visit methods */ /** * Visits a {@link NodeList} node. * * @param n the node to visit */ public void visit(final NodeList n); /** * Visits a {@link NodeListOptional} node. * * @param n the node to visit */ public void visit(final NodeListOptional n); /** * Visits a {@link NodeOptional} node. * * @param n the node to visit */ public void visit(final NodeOptional n); /** * Visits a {@link NodeSequence} node. * * @param n the node to visit */ public void visit(final NodeSequence n); /** * Visits a {@link NodeToken} node. * * @param n the node to visit */ public void visit(final NodeToken n); /* * User grammar generated visit methods */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit */ public void visit(final AFancyProduction n); /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ public void visit(final JavaCCInput n); /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit */ public void visit(final JavaCCOptions n); /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit */ public void visit(final OptionBinding n); /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ public void visit(final Production n); /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ public void visit(final JavaCodeProduction n); /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ public void visit(final BNFProduction n); /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit */ public void visit(final AccessModifier n); /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ public void visit(final RegularExprProduction n); /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit */ public void visit(final TokenManagerDecls n); /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit */ public void visit(final RegExprKind n); /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit */ public void visit(final RegExprSpec n); /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ public void visit(final ExpansionChoices n); /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ public void visit(final Expansion n); /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit */ public void visit(final LocalLookahead n); /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ public void visit(final ExpansionUnit n); /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ public void visit(final ExpansionUnitInTCF n); /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ public void visit(final RegularExpression n); /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit */ public void visit(final ComplexRegularExpressionChoices n); /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit */ public void visit(final ComplexRegularExpression n); /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit */ public void visit(final ComplexRegularExpressionUnit n); /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit */ public void visit(final CharacterList n); /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit */ public void visit(final CharacterDescriptor n); /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ public void visit(final Identifier n); /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit */ public void visit(final JavaIdentifier n); /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit */ public void visit(final CompilationUnit n); /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit */ public void visit(final PackageDeclaration n); /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit */ public void visit(final ImportDeclaration n); /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit */ public void visit(final Modifiers n); /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit */ public void visit(final TypeDeclaration n); /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit */ public void visit(final ClassOrInterfaceDeclaration n); /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final ExtendsList n); /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final ImplementsList n); /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit */ public void visit(final EnumDeclaration n); /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit */ public void visit(final EnumBody n); /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit */ public void visit(final EnumConstant n); /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit */ public void visit(final TypeParameters n); /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit */ public void visit(final TypeParameter n); /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit */ public void visit(final TypeBound n); /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final ClassOrInterfaceBody n); /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit */ public void visit(final ClassOrInterfaceBodyDeclaration n); /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit */ public void visit(final FieldDeclaration n); /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit */ public void visit(final VariableDeclarator n); /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ public void visit(final VariableDeclaratorId n); /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit */ public void visit(final VariableInitializer n); /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit */ public void visit(final ArrayInitializer n); /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit */ public void visit(final MethodDeclaration n); /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit */ public void visit(final MethodDeclarator n); /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit */ public void visit(final FormalParameters n); /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit */ public void visit(final FormalParameter n); /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit */ public void visit(final ConstructorDeclaration n); /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit */ public void visit(final ExplicitConstructorInvocation n); /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit */ public void visit(final Initializer n); /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit */ public void visit(final Type n); /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit */ public void visit(final ReferenceType n); /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit */ public void visit(final ClassOrInterfaceType n); /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit */ public void visit(final TypeArguments n); /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit */ public void visit(final TypeArgument n); /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit */ public void visit(final WildcardBounds n); /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit */ public void visit(final PrimitiveType n); /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit */ public void visit(final ResultType n); /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit */ public void visit(final Name n); /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit */ public void visit(final NameList n); /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit */ public void visit(final Expression n); /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit */ public void visit(final AssignmentOperator n); /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit */ public void visit(final ConditionalExpression n); /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit */ public void visit(final ConditionalOrExpression n); /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit */ public void visit(final ConditionalAndExpression n); /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit */ public void visit(final InclusiveOrExpression n); /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit */ public void visit(final ExclusiveOrExpression n); /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit */ public void visit(final AndExpression n); /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit */ public void visit(final EqualityExpression n); /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit */ public void visit(final InstanceOfExpression n); /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit */ public void visit(final RelationalExpression n); /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit */ public void visit(final ShiftExpression n); /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit */ public void visit(final AdditiveExpression n); /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit */ public void visit(final MultiplicativeExpression n); /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ public void visit(final UnaryExpression n); /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ public void visit(final PreIncrementExpression n); /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit */ public void visit(final PreDecrementExpression n); /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit */ public void visit(final UnaryExpressionNotPlusMinus n); /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit */ public void visit(final CastLookahead n); /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit */ public void visit(final PostfixExpression n); /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit */ public void visit(final CastExpression n); /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit */ public void visit(final PrimaryExpression n); /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit */ public void visit(final MemberSelector n); /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit */ public void visit(final PrimaryPrefix n); /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit */ public void visit(final PrimarySuffix n); /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit */ public void visit(final Literal n); /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit */ public void visit(final IntegerLiteral n); /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit */ public void visit(final BooleanLiteral n); /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ public void visit(final StringLiteral n); /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit */ public void visit(final NullLiteral n); /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit */ public void visit(final Arguments n); /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit */ public void visit(final ArgumentList n); /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit */ public void visit(final AllocationExpression n); /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit */ public void visit(final ArrayDimsAndInits n); /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit */ public void visit(final Statement n); /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit */ public void visit(final AssertStatement n); /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit */ public void visit(final LabeledStatement n); /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final Block n); /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit */ public void visit(final BlockStatement n); /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit */ public void visit(final LocalVariableDeclaration n); /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit */ public void visit(final EmptyStatement n); /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit */ public void visit(final StatementExpression n); /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit */ public void visit(final SwitchStatement n); /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit */ public void visit(final SwitchLabel n); /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit */ public void visit(final IfStatement n); /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ public void visit(final WhileStatement n); /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit */ public void visit(final DoStatement n); /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ public void visit(final ForStatement n); /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit */ public void visit(final ForInit n); /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit */ public void visit(final StatementExpressionList n); /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit */ public void visit(final ForUpdate n); /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final BreakStatement n); /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ContinueStatement n); /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ReturnStatement n); /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit */ public void visit(final ThrowStatement n); /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit */ public void visit(final SynchronizedStatement n); /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ public void visit(final TryStatement n); /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit */ public void visit(final RUNSIGNEDSHIFT n); /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit */ public void visit(final RSIGNEDSHIFT n); /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit */ public void visit(final Annotation n); /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit */ public void visit(final NormalAnnotation n); /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit */ public void visit(final MarkerAnnotation n); /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit */ public void visit(final SingleMemberAnnotation n); /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit */ public void visit(final MemberValuePairs n); /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit */ public void visit(final MemberValuePair n); /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit */ public void visit(final MemberValue n); /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit */ public void visit(final MemberValueArrayInitializer n); /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit */ public void visit(final AnnotationTypeDeclaration n); /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ public void visit(final AnnotationTypeBody n); /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit */ public void visit(final AnnotationTypeMemberDeclaration n); /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit */ public void visit(final DefaultValue n); } jtb-1.4.4/EDU/purdue/jtb/visitor/DepthFirstRetVisitor.java0000644000175000017500000025506511416555700023311 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; import java.util.*; /** * Provides default methods which visit each node in the tree in depth-first order.
* In your "Ret" visitors extend this class and override part or all of these methods. * * @param The user return information type */ public class DepthFirstRetVisitor implements IRetVisitor { /* * Base nodes classes visit methods (to be overridden if necessary) */ /** * Visits a {@link NodeChoice} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeChoice n) { final R nRes = n.choice.accept(this); return nRes; } /** * Visits a {@link NodeList} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeList n) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") final R sRes = e.next().accept(this); } return nRes; } /** * Visits a {@link NodeListOptional} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeListOptional n) { if (n.present()) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") R sRes = e.next().accept(this); } return nRes; } else return null; } /** * Visits a {@link NodeOptional} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeOptional n) { if (n.present()) { final R nRes = n.node.accept(this); return nRes; } else return null; } /** * Visits a {@link NodeSequence} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeSequence n) { R nRes = null; for (final Iterator e = n.elements(); e.hasNext();) { @SuppressWarnings("unused") R subRet = e.next().accept(this); } return nRes; } /** * Visits a {@link NodeToken} node. * * @param n the node to visit * @return the user return information */ public R visit(final NodeToken n) { R nRes = null; @SuppressWarnings("unused") final String tkIm = n.tokenImage; return nRes; } /* * User grammar generated visit methods (to be overridden if necessary) */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @return the user return information */ public R visit(final AFancyProduction n) { R nRes = null; // try { // f0 -> ( #0 ( Annotation() )* // .. .. . #1 ( %0 LabeledStatement() // .. .. . .. | %1 AssertStatement() // .. .. . .. | %2 Block() // .. .. . .. | %3 EmptyStatement() // .. .. . .. | %4 $0 StatementExpression() $1 ";" // .. .. . .. | %5 SwitchStatement() // .. .. . .. | %6 TryStatement() ) // .. .. . #2 [ MarkerAnnotation() ] ) // } // catch (Name() < IDENTIFIER >) Block() // catch (Name() < IDENTIFIER >) Block() // finally Block() n.f0.accept(this); return nRes; } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCCInput n) { R nRes = null; // f0 -> JavaCCOptions() n.f0.accept(this); // f1 -> "PARSER_BEGIN" n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); // f5 -> CompilationUnit() n.f5.accept(this); // f6 -> "PARSER_END" n.f6.accept(this); // f7 -> "(" n.f7.accept(this); // f8 -> Identifier() n.f8.accept(this); // f9 -> ")" n.f9.accept(this); // f10 -> ( Production() )+ n.f10.accept(this); return nRes; } /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCCOptions n) { R nRes = null; // f0 -> [ #0 "options" #1 "{" // .. .. . #2 ( OptionBinding() )* #3 "}" ] n.f0.accept(this); return nRes; } /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final OptionBinding n) { R nRes = null; // f0 -> ( %0 < IDENTIFIER > // .. .. | %1 "LOOKAHEAD" // .. .. | %2 "IGNORE_CASE" // .. .. | %3 "static" ) n.f0.accept(this); // f1 -> "=" n.f1.accept(this); // f2 -> ( %0 IntegerLiteral() // .. .. | %1 BooleanLiteral() // .. .. | %2 StringLiteral() ) n.f2.accept(this); // f3 -> ";" n.f3.accept(this); return nRes; } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @return the user return information */ public R visit(final Production n) { R nRes = null; // f0 -> . %0 JavaCodeProduction() // .. .. | %1 RegularExprProduction() // .. .. | %2 TokenManagerDecls() // .. .. | %3 BNFProduction() n.f0.accept(this); return nRes; } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final JavaCodeProduction n) { R nRes = null; // f0 -> "JAVACODE" n.f0.accept(this); // f1 -> AccessModifier() n.f1.accept(this); // f2 -> ResultType() n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> FormalParameters() n.f4.accept(this); // f5 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f5.accept(this); // f6 -> Block() n.f6.accept(this); return nRes; } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final BNFProduction n) { R nRes = null; // f0 -> AccessModifier() n.f0.accept(this); // f1 -> ResultType() n.f1.accept(this); // f2 -> Identifier() n.f2.accept(this); // f3 -> FormalParameters() n.f3.accept(this); // f4 -> [ #0 "throws" #1 Name() // .. .. . #2 ( $0 "," $1 Name() )* ] n.f4.accept(this); // f5 -> ":" n.f5.accept(this); // f6 -> Block() n.f6.accept(this); // f7 -> "{" n.f7.accept(this); // f8 -> ExpansionChoices() n.f8.accept(this); // f9 -> "}" n.f9.accept(this); return nRes; } /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @return the user return information */ public R visit(final AccessModifier n) { R nRes = null; // f0 -> ( %0 "public" // .. .. | %1 "protected" // .. .. | %2 "private" )? n.f0.accept(this); return nRes; } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final RegularExprProduction n) { R nRes = null; // f0 -> [ %0 #0 "<" #1 "*" #2 ">" // .. .. | %1 #0 "<" #1 < IDENTIFIER > // .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ] n.f0.accept(this); // f1 -> RegExprKind() n.f1.accept(this); // f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ] n.f2.accept(this); // f3 -> ":" n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> RegExprSpec() n.f5.accept(this); // f6 -> ( #0 "|" #1 RegExprSpec() )* n.f6.accept(this); // f7 -> "}" n.f7.accept(this); return nRes; } /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @return the user return information */ public R visit(final TokenManagerDecls n) { R nRes = null; // f0 -> "TOKEN_MGR_DECLS" n.f0.accept(this); // f1 -> ":" n.f1.accept(this); // f2 -> ClassOrInterfaceBody() n.f2.accept(this); return nRes; } /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @return the user return information */ public R visit(final RegExprKind n) { R nRes = null; // f0 -> . %0 "TOKEN" // .. .. | %1 "SPECIAL_TOKEN" // .. .. | %2 "SKIP" // .. .. | %3 "MORE" n.f0.accept(this); return nRes; } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @return the user return information */ public R visit(final RegExprSpec n) { R nRes = null; // f0 -> RegularExpression() n.f0.accept(this); // f1 -> [ Block() ] n.f1.accept(this); // f2 -> [ #0 ":" #1 < IDENTIFIER > ] n.f2.accept(this); return nRes; } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionChoices n) { R nRes = null; // f0 -> Expansion() n.f0.accept(this); // f1 -> ( #0 "|" #1 Expansion() )* n.f1.accept(this); return nRes; } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @return the user return information */ public R visit(final Expansion n) { R nRes = null; // f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )? n.f0.accept(this); // f1 -> ( ExpansionUnit() )+ n.f1.accept(this); return nRes; } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @return the user return information */ public R visit(final LocalLookahead n) { R nRes = null; // f0 -> [ IntegerLiteral() ] n.f0.accept(this); // f1 -> [ "," ] n.f1.accept(this); // f2 -> [ ExpansionChoices() ] n.f2.accept(this); // f3 -> [ "," ] n.f3.accept(this); // f4 -> [ #0 "{" #1 Expression() #2 "}" ] n.f4.accept(this); return nRes; } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionUnit n) { R nRes = null; // f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // .. .. | %1 Block() // .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]" // .. .. | %3 ExpansionUnitInTCF() // .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. . .. .. | &1 $0 RegularExpression() // .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) // .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" )? n.f0.accept(this); return nRes; } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @return the user return information */ public R visit(final ExpansionUnitInTCF n) { R nRes = null; // f0 -> "try" n.f0.accept(this); // f1 -> "{" n.f1.accept(this); // f2 -> ExpansionChoices() n.f2.accept(this); // f3 -> "}" n.f3.accept(this); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* n.f4.accept(this); // f5 -> [ #0 "finally" #1 Block() ] n.f5.accept(this); return nRes; } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RegularExpression n) { R nRes = null; // f0 -> . %0 StringLiteral() // .. .. | %1 #0 < LANGLE : "<" > // .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" > // .. .. | %2 #0 "<" #1 Identifier() #2 ">" // .. .. | %3 #0 "<" #1 "EOF" #2 ">" n.f0.accept(this); return nRes; } /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpressionChoices n) { R nRes = null; // f0 -> ComplexRegularExpression() n.f0.accept(this); // f1 -> ( #0 "|" #1 ComplexRegularExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpression n) { R nRes = null; // f0 -> ( ComplexRegularExpressionUnit() )+ n.f0.accept(this); return nRes; } /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @return the user return information */ public R visit(final ComplexRegularExpressionUnit n) { R nRes = null; // f0 -> . %0 StringLiteral() // .. .. | %1 #0 "<" #1 Identifier() #2 ">" // .. .. | %2 CharacterList() // .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")" // .. .. . .. #3 ( &0 "+" // .. .. . .. .. | &1 "*" // .. .. . .. .. | &2 "?" // .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral() // .. .. . .. .. . .. $2 [ £0 "," // .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )? n.f0.accept(this); return nRes; } /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @return the user return information */ public R visit(final CharacterList n) { R nRes = null; // f0 -> [ "~" ] n.f0.accept(this); // f1 -> "[" n.f1.accept(this); // f2 -> [ #0 CharacterDescriptor() // .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ] n.f2.accept(this); // f3 -> "]" n.f3.accept(this); return nRes; } /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @return the user return information */ public R visit(final CharacterDescriptor n) { R nRes = null; // f0 -> StringLiteral() n.f0.accept(this); // f1 -> [ #0 "-" #1 StringLiteral() ] n.f1.accept(this); return nRes; } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @return the user return information */ public R visit(final Identifier n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); return nRes; } /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @return the user return information */ public R visit(final JavaIdentifier n) { R nRes = null; // f0 -> ( %00 < IDENTIFIER > // .. .. | %01 "LOOKAHEAD" // .. .. | %02 "IGNORE_CASE" // .. .. | %03 "PARSER_BEGIN" // .. .. | %04 "PARSER_END" // .. .. | %05 "JAVACODE" // .. .. | %06 "TOKEN" // .. .. | %07 "SPECIAL_TOKEN" // .. .. | %08 "MORE" // .. .. | %09 "SKIP" // .. .. | %10 "TOKEN_MGR_DECLS" // .. .. | %11 "EOF" ) n.f0.accept(this); return nRes; } /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @return the user return information */ public R visit(final CompilationUnit n) { R nRes = null; // f0 -> [ PackageDeclaration() ] n.f0.accept(this); // f1 -> ( ImportDeclaration() )* n.f1.accept(this); // f2 -> ( TypeDeclaration() )* n.f2.accept(this); return nRes; } /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final PackageDeclaration n) { R nRes = null; // f0 -> ( Annotation() )* n.f0.accept(this); // f1 -> "package" n.f1.accept(this); // f2 -> Name() n.f2.accept(this); // f3 -> ";" n.f3.accept(this); return nRes; } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ImportDeclaration n) { R nRes = null; // f0 -> "import" n.f0.accept(this); // f1 -> [ "static" ] n.f1.accept(this); // f2 -> Name() n.f2.accept(this); // f3 -> [ #0 "." #1 "*" ] n.f3.accept(this); // f4 -> ";" n.f4.accept(this); return nRes; } /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @return the user return information */ public R visit(final Modifiers n) { R nRes = null; // f0 -> ( ( %00 "public" // .. .. . | %01 "static" // .. .. . | %02 "protected" // .. .. . | %03 "private" // .. .. . | %04 "final" // .. .. . | %05 "abstract" // .. .. . | %06 "synchronized" // .. .. . | %07 "native" // .. .. . | %08 "transient" // .. .. . | %09 "volatile" // .. .. . | %10 "strictfp" // .. .. . | %11 Annotation() ) )* n.f0.accept(this); return nRes; } /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @return the user return information */ public R visit(final TypeDeclaration n) { R nRes = null; // f0 -> . %0 ";" // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 AnnotationTypeDeclaration() ) n.f0.accept(this); return nRes; } /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceDeclaration n) { R nRes = null; // f0 -> ( %0 "class" // .. .. | %1 "interface" ) n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ TypeParameters() ] n.f2.accept(this); // f3 -> [ ExtendsList() ] n.f3.accept(this); // f4 -> [ ImplementsList() ] n.f4.accept(this); // f5 -> ClassOrInterfaceBody() n.f5.accept(this); return nRes; } /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExtendsList n) { R nRes = null; // f0 -> "extends" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this); return nRes; } /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ImplementsList n) { R nRes = null; // f0 -> "implements" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "," #1 ClassOrInterfaceType() )* n.f2.accept(this); return nRes; } /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @return the user return information */ public R visit(final EnumDeclaration n) { R nRes = null; // f0 -> "enum" n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ ImplementsList() ] n.f2.accept(this); // f3 -> EnumBody() n.f3.accept(this); return nRes; } /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final EnumBody n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> [ #0 EnumConstant() // .. .. . #1 ( $0 "," $1 EnumConstant() )* ] n.f1.accept(this); // f2 -> [ "," ] n.f2.accept(this); // f3 -> [ #0 ";" // .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ] n.f3.accept(this); // f4 -> "}" n.f4.accept(this); return nRes; } /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @return the user return information */ public R visit(final EnumConstant n) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> [ Arguments() ] n.f2.accept(this); // f3 -> [ ClassOrInterfaceBody() ] n.f3.accept(this); return nRes; } /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final TypeParameters n) { R nRes = null; // f0 -> "<" n.f0.accept(this); // f1 -> TypeParameter() n.f1.accept(this); // f2 -> ( #0 "," #1 TypeParameter() )* n.f2.accept(this); // f3 -> ">" n.f3.accept(this); return nRes; } /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TypeParameter n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeBound() ] n.f1.accept(this); return nRes; } /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @return the user return information */ public R visit(final TypeBound n) { R nRes = null; // f0 -> "extends" n.f0.accept(this); // f1 -> ClassOrInterfaceType() n.f1.accept(this); // f2 -> ( #0 "&" #1 ClassOrInterfaceType() )* n.f2.accept(this); return nRes; } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceBody n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> ( ClassOrInterfaceBodyDeclaration() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); return nRes; } /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceBodyDeclaration n) { R nRes = null; // f0 -> . %0 Initializer() // .. .. | %1 #0 Modifiers() // .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration() // .. .. . .. .. | &1 EnumDeclaration() // .. .. . .. .. | &2 ConstructorDeclaration() // .. .. . .. .. | &3 FieldDeclaration() // .. .. . .. .. | &4 MethodDeclaration() ) // .. .. | %2 ";" n.f0.accept(this); return nRes; } /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final FieldDeclaration n) { R nRes = null; // f0 -> Type() n.f0.accept(this); // f1 -> VariableDeclarator() n.f1.accept(this); // f2 -> ( #0 "," #1 VariableDeclarator() )* n.f2.accept(this); // f3 -> ";" n.f3.accept(this); return nRes; } /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @return the user return information */ public R visit(final VariableDeclarator n) { R nRes = null; // f0 -> VariableDeclaratorId() n.f0.accept(this); // f1 -> [ #0 "=" #1 VariableInitializer() ] n.f1.accept(this); return nRes; } /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final VariableDeclaratorId n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ( #0 "[" #1 "]" )* n.f1.accept(this); return nRes; } /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @return the user return information */ public R visit(final VariableInitializer n) { R nRes = null; // f0 -> . %0 ArrayInitializer() // .. .. | %1 Expression() n.f0.accept(this); return nRes; } /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ArrayInitializer n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> [ #0 VariableInitializer() // .. .. . #1 ( $0 "," $1 VariableInitializer() )* ] n.f1.accept(this); // f2 -> [ "," ] n.f2.accept(this); // f3 -> "}" n.f3.accept(this); return nRes; } /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @return the user return information */ public R visit(final MethodDeclaration n) { R nRes = null; // f0 -> [ TypeParameters() ] n.f0.accept(this); // f1 -> ResultType() n.f1.accept(this); // f2 -> MethodDeclarator() n.f2.accept(this); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this); // f4 -> ( %0 Block() // .. .. | %1 ";" ) n.f4.accept(this); return nRes; } /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final MethodDeclarator n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> FormalParameters() n.f1.accept(this); // f2 -> ( #0 "[" #1 "]" )* n.f2.accept(this); return nRes; } /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final FormalParameters n) { R nRes = null; // f0 -> "(" n.f0.accept(this); // f1 -> [ #0 FormalParameter() // .. .. . #1 ( $0 "," $1 FormalParameter() )* ] n.f1.accept(this); // f2 -> ")" n.f2.accept(this); return nRes; } /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @return the user return information */ public R visit(final FormalParameter n) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this); // f1 -> Type() n.f1.accept(this); // f2 -> [ "..." ] n.f2.accept(this); // f3 -> VariableDeclaratorId() n.f3.accept(this); return nRes; } /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final ConstructorDeclaration n) { R nRes = null; // f0 -> [ TypeParameters() ] n.f0.accept(this); // f1 -> < IDENTIFIER > n.f1.accept(this); // f2 -> FormalParameters() n.f2.accept(this); // f3 -> [ #0 "throws" #1 NameList() ] n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> [ ExplicitConstructorInvocation() ] n.f5.accept(this); // f6 -> ( BlockStatement() )* n.f6.accept(this); // f7 -> "}" n.f7.accept(this); return nRes; } /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ExplicitConstructorInvocation n) { R nRes = null; // f0 -> . %0 #0 "this" #1 Arguments() #2 ";" // .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";" n.f0.accept(this); return nRes; } /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final Initializer n) { R nRes = null; // f0 -> [ "static" ] n.f0.accept(this); // f1 -> Block() n.f1.accept(this); return nRes; } /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @return the user return information */ public R visit(final Type n) { R nRes = null; // f0 -> . %0 ReferenceType() // .. .. | %1 PrimitiveType() n.f0.accept(this); return nRes; } /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @return the user return information */ public R visit(final ReferenceType n) { R nRes = null; // f0 -> . %0 #0 PrimitiveType() // .. .. . .. #1 ( $0 "[" $1 "]" )+ // .. .. | %1 #0 ClassOrInterfaceType() // .. .. . .. #1 ( $0 "[" $1 "]" )* n.f0.accept(this); return nRes; } /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @return the user return information */ public R visit(final ClassOrInterfaceType n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> [ TypeArguments() ] n.f1.accept(this); // f2 -> ( #0 "." #1 < IDENTIFIER > // .. .. . #2 [ TypeArguments() ] )* n.f2.accept(this); return nRes; } /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final TypeArguments n) { R nRes = null; // f0 -> "<" n.f0.accept(this); // f1 -> TypeArgument() n.f1.accept(this); // f2 -> ( #0 "," #1 TypeArgument() )* n.f2.accept(this); // f3 -> ">" n.f3.accept(this); return nRes; } /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TypeArgument n) { R nRes = null; // f0 -> . %0 ReferenceType() // .. .. | %1 #0 "?" // .. .. . .. #1 [ WildcardBounds() ] n.f0.accept(this); return nRes; } /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @return the user return information */ public R visit(final WildcardBounds n) { R nRes = null; // f0 -> . %0 #0 "extends" #1 ReferenceType() // .. .. | %1 #0 "super" #1 ReferenceType() n.f0.accept(this); return nRes; } /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @return the user return information */ public R visit(final PrimitiveType n) { R nRes = null; // f0 -> . %0 "boolean" // .. .. | %1 "char" // .. .. | %2 "byte" // .. .. | %3 "short" // .. .. | %4 "int" // .. .. | %5 "long" // .. .. | %6 "float" // .. .. | %7 "double" n.f0.accept(this); return nRes; } /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @return the user return information */ public R visit(final ResultType n) { R nRes = null; // f0 -> ( %0 "void" // .. .. | %1 Type() ) n.f0.accept(this); return nRes; } /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @return the user return information */ public R visit(final Name n) { R nRes = null; // f0 -> JavaIdentifier() n.f0.accept(this); // f1 -> ( #0 "." #1 JavaIdentifier() )* n.f1.accept(this); return nRes; } /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @return the user return information */ public R visit(final NameList n) { R nRes = null; // f0 -> Name() n.f0.accept(this); // f1 -> ( #0 "," #1 Name() )* n.f1.accept(this); return nRes; } /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final Expression n) { R nRes = null; // f0 -> ConditionalExpression() n.f0.accept(this); // f1 -> [ #0 AssignmentOperator() #1 Expression() ] n.f1.accept(this); return nRes; } /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @return the user return information */ public R visit(final AssignmentOperator n) { R nRes = null; // f0 -> . %00 "=" // .. .. | %01 "*=" // .. .. | %02 "/=" // .. .. | %03 "%=" // .. .. | %04 "+=" // .. .. | %05 "-=" // .. .. | %06 "<<=" // .. .. | %07 ">>=" // .. .. | %08 ">>>=" // .. .. | %09 "&=" // .. .. | %10 "^=" // .. .. | %11 "|=" n.f0.accept(this); return nRes; } /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalExpression n) { R nRes = null; // f0 -> ConditionalOrExpression() n.f0.accept(this); // f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ] n.f1.accept(this); return nRes; } /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalOrExpression n) { R nRes = null; // f0 -> ConditionalAndExpression() n.f0.accept(this); // f1 -> ( #0 "||" #1 ConditionalAndExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ConditionalAndExpression n) { R nRes = null; // f0 -> InclusiveOrExpression() n.f0.accept(this); // f1 -> ( #0 "&&" #1 InclusiveOrExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final InclusiveOrExpression n) { R nRes = null; // f0 -> ExclusiveOrExpression() n.f0.accept(this); // f1 -> ( #0 "|" #1 ExclusiveOrExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ExclusiveOrExpression n) { R nRes = null; // f0 -> AndExpression() n.f0.accept(this); // f1 -> ( #0 "^" #1 AndExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final AndExpression n) { R nRes = null; // f0 -> EqualityExpression() n.f0.accept(this); // f1 -> ( #0 "&" #1 EqualityExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final EqualityExpression n) { R nRes = null; // f0 -> InstanceOfExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "==" // .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @return the user return information */ public R visit(final InstanceOfExpression n) { R nRes = null; // f0 -> RelationalExpression() n.f0.accept(this); // f1 -> [ #0 "instanceof" #1 Type() ] n.f1.accept(this); return nRes; } /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final RelationalExpression n) { R nRes = null; // f0 -> ShiftExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "<" // .. .. . .. | %1 ">" // .. .. . .. | %2 "<=" // .. .. . .. | %3 ">=" ) #1 ShiftExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ShiftExpression n) { R nRes = null; // f0 -> AdditiveExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "<<" // .. .. . .. | %1 RSIGNEDSHIFT() // .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final AdditiveExpression n) { R nRes = null; // f0 -> MultiplicativeExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "+" // .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final MultiplicativeExpression n) { R nRes = null; // f0 -> UnaryExpression() n.f0.accept(this); // f1 -> ( #0 ( %0 "*" // .. .. . .. | %1 "/" // .. .. . .. | %2 "%" ) #1 UnaryExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @return the user return information */ public R visit(final UnaryExpression n) { R nRes = null; // f0 -> . %0 #0 ( &0 "+" // .. .. . .. .. | &1 "-" ) #1 UnaryExpression() // .. .. | %1 PreIncrementExpression() // .. .. | %2 PreDecrementExpression() // .. .. | %3 UnaryExpressionNotPlusMinus() n.f0.accept(this); return nRes; } /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final PreIncrementExpression n) { R nRes = null; // f0 -> "++" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); return nRes; } /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final PreDecrementExpression n) { R nRes = null; // f0 -> "--" n.f0.accept(this); // f1 -> PrimaryExpression() n.f1.accept(this); return nRes; } /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final UnaryExpressionNotPlusMinus n) { R nRes = null; // f0 -> . %0 #0 ( &0 "~" // .. .. . .. .. | &1 "!" ) #1 UnaryExpression() // .. .. | %1 CastExpression() // .. .. | %2 PostfixExpression() n.f0.accept(this); return nRes; } /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @return the user return information */ public R visit(final CastLookahead n) { R nRes = null; // f0 -> . %0 #0 "(" #1 PrimitiveType() // .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]" // .. .. | %2 #0 "(" #1 Type() #2 ")" // .. .. . .. #3 ( &0 "~" // .. .. . .. .. | &1 "!" // .. .. . .. .. | &2 "(" // .. .. . .. .. | &3 < IDENTIFIER > // .. .. . .. .. | &4 "this" // .. .. . .. .. | &5 "super" // .. .. . .. .. | &6 "new" // .. .. . .. .. | &7 Literal() ) n.f0.accept(this); return nRes; } /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @return the user return information */ public R visit(final PostfixExpression n) { R nRes = null; // f0 -> PrimaryExpression() n.f0.accept(this); // f1 -> [ %0 "++" // .. .. | %1 "--" ] n.f1.accept(this); return nRes; } /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @return the user return information */ public R visit(final CastExpression n) { R nRes = null; // f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression() // .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus() n.f0.accept(this); return nRes; } /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @return the user return information */ public R visit(final PrimaryExpression n) { R nRes = null; // f0 -> PrimaryPrefix() n.f0.accept(this); // f1 -> ( PrimarySuffix() )* n.f1.accept(this); return nRes; } /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @return the user return information */ public R visit(final MemberSelector n) { R nRes = null; // f0 -> "." n.f0.accept(this); // f1 -> TypeArguments() n.f1.accept(this); // f2 -> < IDENTIFIER > n.f2.accept(this); return nRes; } /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @return the user return information */ public R visit(final PrimaryPrefix n) { R nRes = null; // f0 -> . %0 Literal() // .. .. | %1 "this" // .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER > // .. .. | %3 #0 "(" #1 Expression() #2 ")" // .. .. | %4 AllocationExpression() // .. .. | %5 #0 ResultType() #1 "." #2 "class" // .. .. | %6 Name() n.f0.accept(this); return nRes; } /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @return the user return information */ public R visit(final PrimarySuffix n) { R nRes = null; // f0 -> . %0 #0 "." #1 "this" // .. .. | %1 #0 "." #1 AllocationExpression() // .. .. | %2 MemberSelector() // .. .. | %3 #0 "[" #1 Expression() #2 "]" // .. .. | %4 #0 "." #1 < IDENTIFIER > // .. .. | %5 Arguments() n.f0.accept(this); return nRes; } /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @return the user return information */ public R visit(final Literal n) { R nRes = null; // f0 -> . %0 < INTEGER_LITERAL > // .. .. | %1 < FLOATING_POINT_LITERAL > // .. .. | %2 < CHARACTER_LITERAL > // .. .. | %3 < STRING_LITERAL > // .. .. | %4 BooleanLiteral() // .. .. | %5 NullLiteral() n.f0.accept(this); return nRes; } /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @return the user return information */ public R visit(final IntegerLiteral n) { R nRes = null; // f0 -> < INTEGER_LITERAL > n.f0.accept(this); return nRes; } /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @return the user return information */ public R visit(final BooleanLiteral n) { R nRes = null; // f0 -> . %0 "true" // .. .. | %1 "false" n.f0.accept(this); return nRes; } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @return the user return information */ public R visit(final StringLiteral n) { R nRes = null; // f0 -> < STRING_LITERAL > n.f0.accept(this); return nRes; } /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @return the user return information */ public R visit(final NullLiteral n) { R nRes = null; // f0 -> "null" n.f0.accept(this); return nRes; } /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final Arguments n) { R nRes = null; // f0 -> "(" n.f0.accept(this); // f1 -> [ ArgumentList() ] n.f1.accept(this); // f2 -> ")" n.f2.accept(this); return nRes; } /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final ArgumentList n) { R nRes = null; // f0 -> Expression() n.f0.accept(this); // f1 -> ( #0 "," #1 Expression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @return the user return information */ public R visit(final AllocationExpression n) { R nRes = null; // f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits() // .. .. | %1 #0 "new" #1 ClassOrInterfaceType() // .. .. . .. #2 [ TypeArguments() ] // .. .. . .. #3 ( &0 ArrayDimsAndInits() // .. .. . .. .. | &1 $0 Arguments() // .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] ) n.f0.accept(this); return nRes; } /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @return the user return information */ public R visit(final ArrayDimsAndInits n) { R nRes = null; // f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+ // .. .. . .. #1 ( $0 "[" $1 "]" )* // .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer() n.f0.accept(this); return nRes; } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @return the user return information */ public R visit(final Statement n) { R nRes = null; // f0 -> . %00 LabeledStatement() // .. .. | %01 AssertStatement() // .. .. | %02 Block() // .. .. | %03 EmptyStatement() // .. .. | %04 #0 StatementExpression() #1 ";" // .. .. | %05 SwitchStatement() // .. .. | %06 IfStatement() // .. .. | %07 WhileStatement() // .. .. | %08 DoStatement() // .. .. | %09 ForStatement() // .. .. | %10 BreakStatement() // .. .. | %11 ContinueStatement() // .. .. | %12 ReturnStatement() // .. .. | %13 ThrowStatement() // .. .. | %14 SynchronizedStatement() // .. .. | %15 TryStatement() n.f0.accept(this); return nRes; } /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final AssertStatement n) { R nRes = null; // f0 -> "assert" n.f0.accept(this); // f1 -> Expression() n.f1.accept(this); // f2 -> [ #0 ":" #1 Expression() ] n.f2.accept(this); // f3 -> ";" n.f3.accept(this); return nRes; } /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final LabeledStatement n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ":" n.f1.accept(this); // f2 -> Statement() n.f2.accept(this); return nRes; } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final Block n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> ( BlockStatement() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); return nRes; } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @return the user return information */ public R visit(final BlockStatement n) { R nRes = null; // f0 -> . %0 #0 LocalVariableDeclaration() #1 ";" // .. .. | %1 Statement() // .. .. | %2 ClassOrInterfaceDeclaration() n.f0.accept(this); return nRes; } /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @return the user return information */ public R visit(final LocalVariableDeclaration n) { R nRes = null; // f0 -> Modifiers() n.f0.accept(this); // f1 -> Type() n.f1.accept(this); // f2 -> VariableDeclarator() n.f2.accept(this); // f3 -> ( #0 "," #1 VariableDeclarator() )* n.f3.accept(this); return nRes; } /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final EmptyStatement n) { R nRes = null; // f0 -> ";" n.f0.accept(this); return nRes; } /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @return the user return information */ public R visit(final StatementExpression n) { R nRes = null; // f0 -> . %0 PreIncrementExpression() // .. .. | %1 PreDecrementExpression() // .. .. | %2 #0 PrimaryExpression() // .. .. . .. #1 [ &0 "++" // .. .. . .. .. | &1 "--" // .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ] n.f0.accept(this); return nRes; } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final SwitchStatement n) { R nRes = null; // f0 -> "switch" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> "{" n.f4.accept(this); // f5 -> ( #0 SwitchLabel() // .. .. . #1 ( BlockStatement() )* )* n.f5.accept(this); // f6 -> "}" n.f6.accept(this); return nRes; } /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @return the user return information */ public R visit(final SwitchLabel n) { R nRes = null; // f0 -> . %0 #0 "case" #1 Expression() #2 ":" // .. .. | %1 #0 "default" #1 ":" n.f0.accept(this); return nRes; } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @return the user return information */ public R visit(final IfStatement n) { R nRes = null; // f0 -> "if" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); // f5 -> [ #0 "else" #1 Statement() ] n.f5.accept(this); return nRes; } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final WhileStatement n) { R nRes = null; // f0 -> "while" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); return nRes; } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final DoStatement n) { R nRes = null; // f0 -> "do" n.f0.accept(this); // f1 -> Statement() n.f1.accept(this); // f2 -> "while" n.f2.accept(this); // f3 -> "(" n.f3.accept(this); // f4 -> Expression() n.f4.accept(this); // f5 -> ")" n.f5.accept(this); // f6 -> ";" n.f6.accept(this); return nRes; } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @return the user return information */ public R visit(final ForStatement n) { R nRes = null; // f0 -> "for" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression() // .. .. | %1 #0 [ ForInit() ] #1 ";" // .. .. . .. #2 [ Expression() ] #3 ";" // .. .. . .. #4 [ ForUpdate() ] ) n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() n.f4.accept(this); return nRes; } /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @return the user return information */ public R visit(final ForInit n) { R nRes = null; // f0 -> . %0 LocalVariableDeclaration() // .. .. | %1 StatementExpressionList() n.f0.accept(this); return nRes; } /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @return the user return information */ public R visit(final StatementExpressionList n) { R nRes = null; // f0 -> StatementExpression() n.f0.accept(this); // f1 -> ( #0 "," #1 StatementExpression() )* n.f1.accept(this); return nRes; } /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @return the user return information */ public R visit(final ForUpdate n) { R nRes = null; // f0 -> StatementExpressionList() n.f0.accept(this); return nRes; } /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final BreakStatement n) { R nRes = null; // f0 -> "break" n.f0.accept(this); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); return nRes; } /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ContinueStatement n) { R nRes = null; // f0 -> "continue" n.f0.accept(this); // f1 -> [ < IDENTIFIER > ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); return nRes; } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ReturnStatement n) { R nRes = null; // f0 -> "return" n.f0.accept(this); // f1 -> [ Expression() ] n.f1.accept(this); // f2 -> ";" n.f2.accept(this); return nRes; } /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @return the user return information */ public R visit(final ThrowStatement n) { R nRes = null; // f0 -> "throw" n.f0.accept(this); // f1 -> Expression() n.f1.accept(this); // f2 -> ";" n.f2.accept(this); return nRes; } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @return the user return information */ public R visit(final SynchronizedStatement n) { R nRes = null; // f0 -> "synchronized" n.f0.accept(this); // f1 -> "(" n.f1.accept(this); // f2 -> Expression() n.f2.accept(this); // f3 -> ")" n.f3.accept(this); // f4 -> Block() n.f4.accept(this); return nRes; } /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @return the user return information */ public R visit(final TryStatement n) { R nRes = null; // f0 -> "try" n.f0.accept(this); // f1 -> Block() n.f1.accept(this); // f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )* n.f2.accept(this); // f3 -> [ #0 "finally" #1 Block() ] n.f3.accept(this); return nRes; } /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RUNSIGNEDSHIFT n) { R nRes = null; // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); // f2 -> ">" n.f2.accept(this); return nRes; } /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @return the user return information */ public R visit(final RSIGNEDSHIFT n) { R nRes = null; // f0 -> ">" n.f0.accept(this); // f1 -> ">" n.f1.accept(this); return nRes; } /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @return the user return information */ public R visit(final Annotation n) { R nRes = null; // f0 -> . %0 NormalAnnotation() // .. .. | %1 SingleMemberAnnotation() // .. .. | %2 MarkerAnnotation() n.f0.accept(this); return nRes; } /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final NormalAnnotation n) { R nRes = null; // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> [ MemberValuePairs() ] n.f3.accept(this); // f4 -> ")" n.f4.accept(this); return nRes; } /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @return the user return information */ public R visit(final MarkerAnnotation n) { R nRes = null; // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); return nRes; } /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @return the user return information */ public R visit(final SingleMemberAnnotation n) { R nRes = null; // f0 -> "@" n.f0.accept(this); // f1 -> Name() n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> MemberValue() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); return nRes; } /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValuePairs n) { R nRes = null; // f0 -> MemberValuePair() n.f0.accept(this); // f1 -> ( #0 "," #1 MemberValuePair() )* n.f1.accept(this); return nRes; } /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValuePair n) { R nRes = null; // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> "=" n.f1.accept(this); // f2 -> MemberValue() n.f2.accept(this); return nRes; } /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValue n) { R nRes = null; // f0 -> . %0 Annotation() // .. .. | %1 MemberValueArrayInitializer() // .. .. | %2 ConditionalExpression() n.f0.accept(this); return nRes; } /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final MemberValueArrayInitializer n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> MemberValue() n.f1.accept(this); // f2 -> ( #0 "," #1 MemberValue() )* n.f2.accept(this); // f3 -> [ "," ] n.f3.accept(this); // f4 -> "}" n.f4.accept(this); return nRes; } /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeDeclaration n) { R nRes = null; // f0 -> "@" n.f0.accept(this); // f1 -> "interface" n.f1.accept(this); // f2 -> < IDENTIFIER > n.f2.accept(this); // f3 -> AnnotationTypeBody() n.f3.accept(this); return nRes; } /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeBody n) { R nRes = null; // f0 -> "{" n.f0.accept(this); // f1 -> ( AnnotationTypeMemberDeclaration() )* n.f1.accept(this); // f2 -> "}" n.f2.accept(this); return nRes; } /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @return the user return information */ public R visit(final AnnotationTypeMemberDeclaration n) { R nRes = null; // f0 -> . %0 #0 Modifiers() // .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")" // .. .. . .. .. $4 [ DefaultValue() ] $5 ";" // .. .. . .. .. | &1 ClassOrInterfaceDeclaration() // .. .. . .. .. | &2 EnumDeclaration() // .. .. . .. .. | &3 AnnotationTypeDeclaration() // .. .. . .. .. | &4 FieldDeclaration() ) // .. .. | %1 ";" n.f0.accept(this); return nRes; } /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @return the user return information */ public R visit(final DefaultValue n) { R nRes = null; // f0 -> "default" n.f0.accept(this); // f1 -> MemberValue() n.f1.accept(this); return nRes; } } jtb-1.4.4/EDU/purdue/jtb/visitor/CommentsPrinter.java0000644000175000017500000006747311364255334022341 0ustar cavedoncavedonpackage EDU.purdue.jtb.visitor; import java.util.ArrayList; import java.util.Iterator; import EDU.purdue.jtb.misc.ClassInfo; import EDU.purdue.jtb.misc.FieldNameGenerator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.Spacing; import EDU.purdue.jtb.misc.UnicodeConverter; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.syntaxtree.RegExprSpec; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.StringLiteral; /** * The CommentsPrinter visitor (an extension of {@link JavaCCPrinter visitor}) is called by * {@link ClassInfo} (through {@link #visit(ExpansionChoices)} to find which part of the production * each field corresponds, and to format the class, method or field corresponding javadoc comments. *

* Each field comment is terminated by a break tag and a newline, and may be splitted, for better * readability, in different lines, with proper indentation (with spaces " " and dots "."), on a new * choice (after a "|") or on a new expansion choice ("("...")" or "["..."]). *

* Examples: *

* 1 - Expansion at first BNF level: f0...fn show each ExpansionUnit:
* * f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
*
*

* 2 - Choices at first BNF level (not included in an ExpansionUnit "(...)": %0...%n * show the which indicator for each Expansion (note the dummy dot on first line):
* * f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
*
*

* 3 - Choices at non first BNF level (included in an ExpansionUnit with parentheses "(...)": * %0...%n show the which indicator for each Expansion (note the parentheses):
* * f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
*
*

* 4 - Choices at two levels: %0...%n show the which indicator for level 1, * %0...%n show the which indicator for level 1, &0...&n show the which * indicator for level 2, ~1...~n show the which indicator for level 3, and back again * for the next levels:
* * f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
*
*

* 5 - Sequence of ExpansionUnits (in an Expansion in an ExpansionChoice in a ExpansionUnit): * #0...#n show the sequence number for each ExpansionUnit (notice that here in f1 * there is no Sequence, so no number is shown, unlike in f2 where there are 2 nodes):
* * f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
*
*

* 6 - Sequence of ExpansionUnits (in an Expansion in an ExpansionChoice in a ExpansionUnit) at two * or more levels: #0...#n show the sequence number for level 1, $0...$n * show the sequence number for level 2, £0...£n show the sequence number for next * level, and back again for the next levels:
* * f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
*
*

* 7 - Example showing almost all features (%and & for choices, #, $ and £ for sequences):
* * f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 #0 "try" #1 "{" #2 ExpansionChoices() #3 "}"
* .. .. . .. #4 ( $0 "catch" $1 "(" $2 Name() $3 < IDENTIFIER > $4 ")" $5 Block() )*
* .. .. . .. #5 [ $0 "finally" $1 Block() ]
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
*
* * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5
* @version 1.4.3.1 : 04/2010 : MMa : fixed case 4 of getExpUnitBaseNodeType (bug n°2990962)
* TODO changer les .. et ... en nombre adéquats si Globals.descriptiveFieldNames */ public class CommentsPrinter extends JavaCCPrinter { /** The comment sequence level (0 -> none, 1 -> first, 2 -> second, ...) */ int seqLvl = 0; /** The choice sequence level (0 -> none, 1 -> first, 2 -> second, ...) */ int chLvl = 0; /** The comment prefix */ StringBuffer prefix = new StringBuffer(32); /** The which indicator characters */ public static final String[] WHCH = { "%", "&", "~" }; /** The sequence characters */ public static final String[] SEQCH = { "#", "$", "£" }; /** The field name generator */ final FieldNameGenerator nameGen = new FieldNameGenerator(); /** * The list of class fields for receiving the javadoc comments (must be valid)
* Start with " * " but without indentation, and may be on multiple lines */ public ArrayList fc = null; /** * Constructor which just allocates the internal buffer. */ public CommentsPrinter() { sb = new StringBuilder(512); } /* * Base classes visit methods */ /** * Prints a NodeToken image taking care of '<' and '>' characters. * * @param n the NodeToken */ @Override public void visit(final NodeToken n) { // change into < XXX > for proper display of comments in Eclipse for (int i = 0; i < n.tokenImage.length(); ++i) { final char c = n.tokenImage.charAt(i); if (c == '<') { i++; if (i < n.tokenImage.length()) { final char d = n.tokenImage.charAt(i); sb.append("< "); if (d != ' ') { sb.append(d); } } else { sb.append('<'); } } else if (c == '>') { if (' ' != sb.charAt(sb.length() - 1)) { sb.append(" "); } sb.append(">"); } else { sb.append(c); } } } /* * User grammar generated and overridden visit methods below */ /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { // only f0 if (!n.f1.present()) { n.f0.accept(this); if (bnfLvl == 0) { sb.append("
").append(LS); fc.add(sb.toString()); sb.setLength(0); } return; } // f0 and f1 final boolean bigWh = n.f1.size() > 9; String locPrefix = prefix.toString(); // f0 -> Expansion(c1) if (bnfLvl == 0) { // if first ExpansionChoices level, generate field name final String fx = nameGen.genCommentFieldName(Globals.nodeChoiceName); // output which indicator sb.append(" * ").append(fx).append(" -> . %0").append(bigWh ? "0 " : " "); // set and save prefix reinitPrefix(fx); locPrefix = prefix.toString(); prefix.append(bigWh ? ". ... " : ". .. "); } else { // if non first ExpansionChoices levels, output which indicator sb.append(WHCH[(chLvl % 3)]).append(bigWh ? "00 " : "0 "); } // save state info final int oldChLvl = chLvl++; // visit ++bnfLvl; n.f0.accept(this); --bnfLvl; // restore state info chLvl = oldChLvl; restorePrefix(locPrefix); // f1 -> ( "|" Expansion(c2) )* int fi = 1; for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // new line and prefix sb.append("
").append(LS); sb.append(prefix); // "|" sb.append("| "); // output which indicator sb.append(WHCH[(chLvl++ % 3)]).append(bigWh ? (fi > 9 ? "" : "0") : "").append(fi) .append(" "); // update prefix prefix.append(bigWh ? ". ... " : ". .. "); fi++; // visit ++bnfLvl; // Expansion(c2) seq.elementAt(1).accept(this); --bnfLvl; // restore state info chLvl = oldChLvl; restorePrefix(locPrefix); } // close comment with last field if (bnfLvl == 0) { sb.append("
").append(LS); fc.add(sb.toString()); sb.setLength(0); } } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // don't take f0, only f1 // count the number of non LocalLookahead nor Block ExpansionUnits int nbEuOk = 0; for (final Iterator e = n.f1.elements(); e.hasNext();) { final ExpansionUnit expUnit = (ExpansionUnit) e.next(); if (expUnit.f0.which > 1) nbEuOk++; } final boolean outSeq = nbEuOk > 1; final boolean bigSeq = nbEuOk > 10; int numEuOk = 0; // save state info final int oldSeqLvl = seqLvl; String locPrefix = prefix.toString(); // f1 -> ( ExpansionUnit(c2) )+ for (final Iterator e = n.f1.elements(); e.hasNext();) { final ExpansionUnit expUnit = (ExpansionUnit) e.next(); // don't process LocalLookahead nor Block in ExpansionUnit if (expUnit.f0.which > 1) { if (bnfLvl == 0) { // at first Expansion level if (sb.length() > 0) { // if already something, new comment sb.append("
").append(LS); fc.add(sb.toString()); sb.setLength(0); } // output generated field final String fx = nameGen.genCommentFieldName(getExpUnitBaseNodeType(expUnit)); sb.append(" * ").append(fx).append(" -> "); // set and save prefix reinitPrefix(fx); locPrefix = prefix.toString(); } else { // at non first Expansion levels if (numEuOk > 0 && (expUnit.f0.which == 5 || expUnit.f0.which == 2)) { // new line if (...) or [...] and not first sb.append("
").append(LS); sb.append(prefix); } else { // otherwise on same line (don't double space) if (sb.charAt(sb.length() - 1) != ' ') sb.append(" "); } } // if real sequence output sequence number except at first Expansion level if (bnfLvl > 0 && outSeq) { sb.append(SEQCH[(seqLvl % 3)]).append(bigSeq && numEuOk < 10 ? "0" : "").append(numEuOk) .append(" "); seqLvl++; // pre-update prefix with sequence number prefix.append(bigSeq ? "... " : ".. "); } // pre-update prefix with delimiter location, only for ExpansionChoices with no choice if (expUnit.f0.which == 5 || expUnit.f0.which == 2) { final NodeSequence seq = (NodeSequence) expUnit.f0.choice; final ExpansionChoices ec = (ExpansionChoices) seq.elementAt(1); if (!ec.f1.present()) prefix.append(". "); } // visit ++bnfLvl; expUnit.accept(this); --bnfLvl; // restore state info seqLvl = oldSeqLvl; restorePrefix(locPrefix); numEuOk++; } } } /** * Returns the base node type corresponding to the given ExpansionUnit.
* 4.2 Grammar production for ExpansionUnit:
* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 #0 "try" #1 "{" #2 ExpansionChoices() #3 "}"
* .. .. . .. #4 ( $0 "catch" $1 "(" $2 Name() $3 < IDENTIFIER > $4 ")" $5 Block() )*
* .. .. . .. #5 [ $0 "finally" $1 Block() ]
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node * @return the base node type */ // private String getUnitName(final ExpansionUnit n) { private String getExpUnitBaseNodeType(final ExpansionUnit n) { NodeSequence seq; ExpansionChoices ec; switch (n.f0.which) { // // cases 0 and 1 should not occur as getUnitName() is not called for LocalLookahead nor Block // case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" return Globals.nodeOptName; case 3: // %3 #0 "try" #1 "{" #2 ExpansionChoices() #3 "}" // .. #4 ( $0 "catch" $1 "(" $2 Name() $3 < IDENTIFIER > $4 ")" $5 Block() )* // .. #5 [ $0 "finally" $1 Block() ] // seq = (NodeSequence) n.f0.choice; // ec = (ExpansionChoices) seq.elementAt(2); // if (ec.f1.present()) // // f1 -> ( "|" Expansion(c2) )* // return Globals.nodeChoiceName; // else // // f0 -> Expansion(c1) // return Globals.nodeSeqName; final ExpansionUnitInTCF eut3 = (ExpansionUnitInTCF) n.f0.choice; ec = eut3.f2; if (ec.f1.present()) // f1 -> ( "|" Expansion(c2) )* return Globals.nodeChoiceName; else // f0 -> Expansion(c1) return Globals.nodeSeqName; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) seq = (NodeSequence) n.f0.choice; final NodeChoice ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; if (ch.which == 0) { // $0 Identifier() $1 Arguments() return ((Identifier) seq1.elementAt(0)).f0.tokenImage; } else { // $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] // grammar for RegularExpression // f0 -> . %0 StringLiteral()
// .. .. | %1 #0 < LANGLE : "<" >
// .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
// .. .. | %2 #0 "<" #1 Identifier() #2 ">"
// .. .. | %3 #0 "<" #1 "EOF" #2 ">"
return Globals.nodeTokenName; } case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? seq = (NodeSequence) n.f0.choice; final NodeOptional ebnfMod = (NodeOptional) seq.elementAt(3); if (ebnfMod.present()) { // case there is a "+" or "*" or "?" final NodeChoice modChoice = (NodeChoice) ebnfMod.node; final String mod = ((NodeToken) modChoice.choice).tokenImage; return nameGen.getNameForMod(mod); } else { ec = (ExpansionChoices) seq.elementAt(1); if (ec.f1.present()) return Globals.nodeChoiceName; else return Globals.nodeSeqName; } default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); break; } throw new Error("Error in CommentsPrinter.getExpUnitBaseNodeType()"); } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { NodeSequence seq; NodeOptional opt; NodeChoice ch; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" // should not be called ! break; case 1: // %1 Block() // should not be called ! break; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" seq = (NodeSequence) n.f0.choice; sb.append("[ "); ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; sb.append(" ]"); break; case 3: // %3 ExpansionUnitInTCF() n.f0.choice.accept(this); break; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) seq = (NodeSequence) n.f0.choice; ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; if (ch.which == 0) { // $0 Identifier() $1 Arguments() seq1.elementAt(0).accept(this); // don't print arguments, only parenthesis (for lisibility) // sb.append(genJavaBranch(seq1.elementAt(1))); sb.append("()"); } else { // $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] seq1.elementAt(0).accept(this); final NodeOptional opt1 = (NodeOptional) seq1.elementAt(1); if (opt1.present()) { sb.append("."); ((NodeSequence) opt1.node).elementAt(1).accept(this); } } break; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? seq = (NodeSequence) n.f0.choice; // #0 "(" sb.append("( "); // #1 ExpansionChoices() ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; // #2 ")" sb.append(" )"); // #3 ( &0 "+" | &1 "*" | &2 "?" )? opt = (NodeOptional) seq.elementAt(3); if (opt.present()) { ((NodeChoice) opt.node).choice.accept(this); } break; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); break; } } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f0 -> "try" // f1 -> "{" sb.insert(0, " * try {
".concat(LS)); // f2 -> ExpansionChoices() n.f2.accept(this); // f3 -> "}" sb.append("
").append(LS).append(" * }"); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* for (int i = 0; i < n.f4.size(); i++) sb.append("
").append(LS).append(" * catch (Name() < IDENTIFIER >) Block()"); // f5 -> [ #0 "finally" #1 Block() ] if (n.f5.present()) sb.append("
").append(LS).append(" * finally Block()"); } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(final RegularExprProduction n) { // f5 -> RegExprSpec() n.f5.accept(this); // f6 -> ( "|" RegExprSpec(p) )* if (n.f6.present()) { for (final Iterator e = n.f6.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "|" sb.append("| "); // RegExprSpec(p) seq.elementAt(1).accept(this); } } } /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit */ @Override public void visit(final RegExprSpec n) { // f0 -> RegularExpression(c) n.f0.accept(this); } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(final RegularExpression n) { if (n.f0.which == 0) // StringLiteral() n.f0.choice.accept(this); else if (n.f0.which == 1) { // [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) "> final NodeSequence seq = (NodeSequence) n.f0.choice; // "<" sb.append("< "); final NodeOptional opt = (NodeOptional) seq.elementAt(1); if (opt.present()) { final NodeSequence seq1 = (NodeSequence) opt.node; if (((NodeOptional) seq1.elementAt(0)).present()) // "#" sb.append("#"); // Identifier() seq1.elementAt(1).accept(this); sb.append(" "); // ":" sb.append(": "); } // ComplexRegularExpressionChoices(c) // here we can use super class (JavaCCPrinter) methods which do not add newlines nor indentation seq.elementAt(2).accept(this); // ">" sb.append(" >"); } else if (n.f0.which == 2) { // "<" Identifier() ">" // "<" sb.append("< "); // Identifier() ((NodeSequence) n.f0.choice).elementAt(1).accept(this); // ">" sb.append(" >"); } else { // "<" "EOF" ">" // "<" sb.append("< "); // "EOF" ((NodeSequence) n.f0.choice).elementAt(1).accept(this); // ">" sb.append(" >"); } } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); } // /** // * Visits a {@link IntegerLiteral} node, whose children are the following : // *

// * f0 -> < INTEGER_LITERAL >
// * // * @param n the node to visit // */ // @Override // public void visit(final IntegerLiteral n) { // sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); // } // /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { sb.append(UnicodeConverter.addUnicodeEscapes(n.f0.tokenImage)); } /* * Methods to manage prefix */ /** * Reinitializes the prefix with the appropriate number of leading dots. * * @param fx the current leading field name */ void reinitPrefix(final String fx) { final int fxl = fx.length(); prefix.setLength(0); prefix.append(" * "); for (int i = 0; i < fxl; i++) prefix.append("."); prefix.append(" .. "); } /** * Restores the prefix with the given saved string. * * @param locPrefix the saved string */ void restorePrefix(final String locPrefix) { prefix.setLength(0); prefix.append(locPrefix); } /* * Methods to format javadoc comments */ /** * Formats the javadoc comment for all fields.
* Does not add the javadoc opening and closing delimiters. * * @param aSpc an indentation (must be valid) * @param aCI the ClassInfo to work on * @return the javadoc comment */ public String formatAllFieldsComment(final Spacing aSpc, final ClassInfo aCI) { sb.setLength(0); fc = aCI.getFieldComments(); if (fc.size() == 0) genFieldsComments(aCI); for (int i = 0; i < fc.size(); i++) { sb.append(formatAFieldComment(aSpc, aCI, i)); } return sb.toString(); } /** * Formats the javadoc comment for a single field.
* Does not add the javadoc opening and closing delimiters. * * @param aSpc an indentation (must be valid) * @param fi the field index (must be valid) * @param aCI the ClassInfo to work on * @return the javadoc comment */ public String formatAFieldComment(final Spacing aSpc, final ClassInfo aCI, final int fi) { fc = aCI.getFieldComments(); if (fc.size() == 0) genFieldsComments(aCI); final String fci = fc.get(fi); final int lsl = LS.length(); if (aSpc.indentLevel == 0) { // no need to add indentation return fci; } else { // need to add indentation int k = fci.indexOf(LS); final int lm1 = fci.length() - 1; if (k >= 0 && k < lm1) { // need to break out lines to add indentation int j = 0; final StringBuilder buf = new StringBuilder(128); while (k >= 0) { k = k + lsl; buf.append(aSpc.spc).append(fci.substring(j, k)); j = k; k = fci.indexOf(LS, j); } if (j <= lm1) buf.append(aSpc.spc).append(fci.substring(j)); return buf.toString(); } else { // just one line, add indentation return aSpc.spc.concat(fci); } } } /** * Generates the fields comments. * * @param aCI the ClassInfo to work on */ void genFieldsComments(final ClassInfo aCI) { nameGen.reset(); bnfLvl = seqLvl = chLvl = 0; prefix.setLength(0); aCI.getAstNode().accept(this); aCI.setFieldComments(fc); } } jtb-1.4.4/EDU/purdue/jtb/visitor/Annotator.java0000644000175000017500000023774311364244652021155 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb.visitor; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.Spacing; import EDU.purdue.jtb.misc.VarInfo; import EDU.purdue.jtb.syntaxtree.BNFProduction; import EDU.purdue.jtb.syntaxtree.Block; import EDU.purdue.jtb.syntaxtree.BlockStatement; import EDU.purdue.jtb.syntaxtree.ClassOrInterfaceBody; import EDU.purdue.jtb.syntaxtree.ClassOrInterfaceType; import EDU.purdue.jtb.syntaxtree.CompilationUnit; import EDU.purdue.jtb.syntaxtree.DoStatement; import EDU.purdue.jtb.syntaxtree.Expansion; import EDU.purdue.jtb.syntaxtree.ExpansionChoices; import EDU.purdue.jtb.syntaxtree.ExpansionUnit; import EDU.purdue.jtb.syntaxtree.ExpansionUnitInTCF; import EDU.purdue.jtb.syntaxtree.ForStatement; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.syntaxtree.Identifier; import EDU.purdue.jtb.syntaxtree.IfStatement; import EDU.purdue.jtb.syntaxtree.ImportDeclaration; import EDU.purdue.jtb.syntaxtree.JavaCCInput; import EDU.purdue.jtb.syntaxtree.JavaCodeProduction; import EDU.purdue.jtb.syntaxtree.LabeledStatement; import EDU.purdue.jtb.syntaxtree.LocalLookahead; import EDU.purdue.jtb.syntaxtree.NodeChoice; import EDU.purdue.jtb.syntaxtree.NodeList; import EDU.purdue.jtb.syntaxtree.NodeListOptional; import EDU.purdue.jtb.syntaxtree.NodeOptional; import EDU.purdue.jtb.syntaxtree.NodeSequence; import EDU.purdue.jtb.syntaxtree.NodeToken; import EDU.purdue.jtb.syntaxtree.PrimitiveType; import EDU.purdue.jtb.syntaxtree.Production; import EDU.purdue.jtb.syntaxtree.ReferenceType; import EDU.purdue.jtb.syntaxtree.RegularExprProduction; import EDU.purdue.jtb.syntaxtree.RegularExpression; import EDU.purdue.jtb.syntaxtree.ResultType; import EDU.purdue.jtb.syntaxtree.ReturnStatement; import EDU.purdue.jtb.syntaxtree.Statement; import EDU.purdue.jtb.syntaxtree.StringLiteral; import EDU.purdue.jtb.syntaxtree.SwitchStatement; import EDU.purdue.jtb.syntaxtree.SynchronizedStatement; import EDU.purdue.jtb.syntaxtree.TryStatement; import EDU.purdue.jtb.syntaxtree.Type; import EDU.purdue.jtb.syntaxtree.WhileStatement; /** * The Annotator visitor generates the (jtb) annotated .jj file containing the tree-building code.
* Annotator and {@link ClassGenerator} depend on each other to create and use classes.
* Code is printed in a buffer and {@link #saveToFile} must be called to save it in the output file. *

* Annotator works as follows: *

    *
  • in generateRHS in visit(BNFProduction) and others, it redirects output to a temporary buffer, *
  • it walks down the tree, prints the RHS into the temporary buffer, and builds the varList, *
  • it traverses varList, prints the variable declarations to the main buffer *
  • it prints the Block to the main buffer, then the temporary buffer into the main buffer. *
* When it wants to print a node and its subtree without annotating it, it uses * n.accept(JavaCCPrinter). *

* TODO reporter les commentaires formattés ... * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05-08/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5 * @version 1.4.0.2 : 01/2010 : MMa : fixed output of else in IfStatement */ public class Annotator extends JavaCCPrinter { /** Visitor for lower nodes which don't need annotation */ final JavaCCPrinter jccpv; /** Visitor for printing the compilation unit */ final CompilationUnitPrinter cupv; /** Visitor for finding return variables declarations */ final GlobalDataFinder gdfv; /** Counter for generated variables names */ int varNum; /** List of all variables to be declared */ ArrayList varList = new ArrayList(); /** List of all outer variables for the default constructor */ ArrayList outerVars = new ArrayList(); /** List of all return variables pairs of comments and declarations */ public ArrayList retVarDecl = new ArrayList(); /** The RegularExpression generated token name */ String reTokenName = null; /** The last variable generated so far */ VarInfo prevVar; /** Flag set to false for Blocks and LocalLookaheads */ boolean annotateNode; /** Name of the current production */ String curProduction; /** List of additional variables to initialize */ ArrayList extraVarsList = null; /** The BNFProduction result type */ String resultType = null; /** The BNFProduction result type specials */ String resultTypeSpecials = null; /** The JavaCodeProductions table */ Hashtable jcpHT = new Hashtable(); /** The visitor to count ExpansionUnit types */ final ExpansionUnitTypeCounter eutcv = new ExpansionUnitTypeCounter(); /** True if in ExpansionUnit type 3, false otherwise */ boolean inEUT3; /** * Constructor which will allocate a default buffer and indentation. */ public Annotator() { jccpv = new JavaCCPrinter(sb, spc); gdfv = new GlobalDataFinder(); cupv = new CompilationUnitPrinter(sb, spc); inEUT3 = false; } /* * Convenience methods */ /** * Generates a new variable name (n0, n1, ...) * * @return the new variable name */ private final String genNewVarName() { return "n" + String.valueOf(varNum++); } /** * Reset the variable generator counter */ private final void resetVarNum() { varNum = 0; } /** * Common end-code from all the annotation methods here * * @param varInfo the variable to annotate */ private void finalActions(final VarInfo varInfo) { if (bnfLvl == 0) outerVars.add(varInfo); else { prevVar = varInfo; annotateNode = true; } } /** * Prints into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void oneNewLine(final INode n) { sb.append(nodeClassComment(n)).append(LS); } /** * Prints into the current buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment */ @Override void oneNewLine(final INode n, final String str) { sb.append(nodeClassComment(n, str)).append(LS); } /** * Prints into a given buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment * @param aSB the buffer to print into */ void oneNewLine(final INode n, final String str, final StringBuilder aSB) { aSB.append(nodeClassComment(n, str)).append(LS); } /** * Prints twice into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void twoNewLines(final INode n) { oneNewLine(n); oneNewLine(n); } /** * Returns a node class comment (a //@@ followed by the node class short name if global flag set, * nothing otherwise). * * @param n the node for the node class comment * @return the node class comment */ private String nodeClassComment(final INode n) { if (Globals.PRINT_CLASS_COMMENT) { final String s = n.toString(); final int b = s.lastIndexOf('.') + 1; final int e = s.indexOf('@'); if (b == -1 || e == -1) return " //@@ " + s; else return " //@@ " + s.substring(b, e); } else return ""; } /** * Returns a node class comment with an extra comment (a //@@ followed by the node class short * name plus the extra comment if global flag set, nothing otherwise). * * @param n the node for the node class comment * @param str the extra comment * @return the node class comment */ String nodeClassComment(final INode n, final String str) { if (Globals.PRINT_CLASS_COMMENT) return nodeClassComment(n) + " " + str; else return ""; } /* * User grammar generated and overridden visit methods below */ /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // find first all global data n.accept(gdfv); // generate now output sb.append(spc.spc); sb.append(Globals.genFileHeaderComment()); threeNewLines(n); sb.append(spc.spc); // f0 -> JavaCCOptions() n.f0.accept(jccpv); twoNewLines(n); sb.append(spc.spc); // f1 -> "PARSER_BEGIN" n.f1.accept(this); // f2 -> "(" n.f2.accept(this); // f3 -> Identifier() n.f3.accept(this); // f4 -> ")" n.f4.accept(this); oneNewLine(n); sb.append(spc.spc); // f5 -> CompilationUnit() n.f5.accept(cupv); oneNewLine(n); sb.append(spc.spc); // f6 -> "PARSER_END" n.f6.accept(this); // f7 -> "(" n.f7.accept(this); // f8 -> Identifier() n.f8.accept(this); // f9 -> ")" n.f9.accept(this); twoNewLines(n); sb.append(spc.spc); // f10 -> ( Production() )+ for (final Iterator e = n.f10.elements(); e.hasNext();) { e.next().accept(this); if (e.hasNext()) { sb.append(spc.spc); twoNewLines(n); } } oneNewLine(n); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(final JavaCodeProduction n) { // f0 -> "JAVACODE" n.f0.accept(this); oneNewLine(n); sb.append(spc.spc); // f1 -> AccessModifier(p) n.f1.accept(this); // f2 -> ResultType(p.getReturnTypeTokens()) sb.append(genJavaBranch(n.f2)); sb.append(" "); // f3 -> Identifier() n.f3.accept(this); // f4 -> FormalParameters(p.getParameterListTokens()) sb.append(genJavaBranch(n.f4)); // f5 -> [ "throws" Name(excName) ( "," Name(excName) )* ] if (n.f5.present()) { final NodeSequence seq = (NodeSequence) n.f5.node; sb.append(" "); seq.elementAt(0).accept(this); sb.append(" "); sb.append(genJavaBranch(seq.elementAt(1))); final NodeListOptional opt = ((NodeListOptional) seq.elementAt(3)); if (opt.present()) { for (final Iterator e = opt.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); seq1.elementAt(0).accept(this); sb.append(" "); sb.append(genJavaBranch(seq1.elementAt(1))); } } } oneNewLine(n); sb.append(spc.spc); // f6 -> Block(p.getCodeTokens()) sb.append(genJavaBranch(n.f6)); } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ @Override public void visit(final BNFProduction n) { varList.clear(); outerVars.clear(); prevVar = null; resetVarNum(); bnfLvl = 0; annotateNode = true; curProduction = n.f2.f0.tokenImage; // f0 -> AccessModifier(p) n.f0.accept(this); // f1 -> ResultType(p.getReturnTypeTokens()) // just print the f1 specials, then print the Identifier instead of the ResultType getResultTypeSpecials(n.f1); sb.append(resultTypeSpecials); sb.append(curProduction); sb.append(" "); // f2 -> Identifier() n.f2.accept(this); // f3 -> FormalParameters(p.getParameterListTokens()) sb.append(genJavaBranch(n.f3)); // f4 -> [ "throws" Name(excName) ( "," Name(excName) )* ] if (n.f4.present()) { final NodeSequence seq = (NodeSequence) n.f4.node; sb.append(" "); seq.elementAt(0).accept(this); sb.append(" "); seq.elementAt(1).accept(this); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(2); if (nlo.present()) { for (final Iterator e = nlo.elements(); e.hasNext();) { final NodeSequence seq1 = (NodeSequence) e.next(); seq1.elementAt(0).accept(this); sb.append(" "); seq1.elementAt(1).accept(this); } } } // f5 -> ":" sb.append(" "); n.f5.accept(this); oneNewLine(n); // generate the RHS into a temporary buffer and collect variables final StringBuilder rhsSB = generateRHS(n); // print the variables declarations sb.append(spc.spc); // block left brace n.f6.f0.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); sb.append("// --- JTB generated node declarations ---"); oneNewLine(n); sb.append(spc.spc); for (final Iterator e = varList.iterator(); e.hasNext();) { sb.append(e.next().generateNodeDeclaration()); if (e.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } // f6 -> Block(p.getDeclarationTokens()) if (n.f6.f1.present()) { // print block declarations only if non empty // don't print "{" and "}" otherwise the resulting inner scope will prevent to use declarations oneNewLine(n); sb.append(spc.spc); sb.append("// --- user BNFProduction java block ---"); oneNewLine(n); sb.append(spc.spc); for (final Iterator e = n.f6.f1.elements(); e.hasNext();) { // BlockStatement() e.next().accept(this); if (e.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } } spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); // block right brace n.f6.f2.accept(this); oneNewLine(n); sb.append(spc.spc); // print the RHS buffer sb.append(rhsSB); // reset global variable resultType = null; } /** * Memorizes the ResultType specials and the ResultType. Walks down the tree to find the first * token. *

* {@link ResultType}
* f0 -> ( "void" | Type() )
*

* {@link Type}
* f0 -> ReferenceType()
* | PrimitiveType()
*

* {@link ReferenceType}
* f0 -> PrimitiveType() ( "[" "]" )+
* | ClassOrInterfaceType() ( "[" "]" )*
*

* {@link PrimitiveType}
* f0 -> "boolean"
* | "char"
* | "byte"
* | "short"
* | "int"
* | "long"
* | "float"
* | "double"
*

* {@link ClassOrInterfaceType}
* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( "." < IDENTIFIER > [ TypeArguments() ] )*
* * @param rt the node to process */ void getResultTypeSpecials(final ResultType rt) { NodeToken tk; final INode n = rt.f0.choice; if (rt.f0.which == 0) { // "void" tk = (NodeToken) n; } else { // Type( final NodeChoice ch = ((Type) n).f0; if (ch.which == 0) { // ReferenceType() final NodeChoice ch1 = ((ReferenceType) ch.choice).f0; if (ch1.which == 0) { // PrimitiveType() ( "[" "]" )+ tk = (NodeToken) ((PrimitiveType) ch1.choice).f0.choice; } else { // ClassOrInterfaceType() ( "[" "]" )* tk = ((ClassOrInterfaceType) ((NodeSequence) ch1.choice).elementAt(0)).f0; } } else { // PrimitiveType() tk = (NodeToken) ((PrimitiveType) ch.choice).f0.choice; } } resultTypeSpecials = tk.getSpecials(spc.spc); resultType = tk.tokenImage; return; } /** * Returns a string with the RHS of the current BNF production.
* When this function returns, varList and outerVars will have been built and will be used by the * calling method. *

* Visits the {@link BNFProduction}
* f0 -> AccessModifier(p)
* f1 -> ResultType(p.getReturnTypeTokens())
* f2 -> Identifier()
* f3 -> FormalParameters(p.getParameterListTokens())
* f4 -> [ "throws" Name(excName) ( "," Name(excName) )* ]
* f5 -> ":"
* f6 -> Block(p.getDeclarationTokens())
* f7 -> "{"
* f8 -> ExpansionChoices(c)
* f9 -> "}"
* * @param n the node to process * @return the generated buffer */ private StringBuilder generateRHS(final BNFProduction n) { final StringBuilder mainSB = sb; final StringBuilder newSB = new StringBuilder(512); sb = jccpv.sb = newSB; // f7 -> "{" n.f7.accept(this); oneNewLine(n, "generateRHS a"); spc.updateSpc(+1); sb.append(spc.spc); // outerVars will be set further down the tree in finalActions // f8 -> ExpansionChoices(c) n.f8.accept(this); sb.append("{ return new ").append(n.f2.f0.tokenImage).append("("); final Iterator e = outerVars.iterator(); if (e.hasNext()) { sb.append(e.next().getName()); for (; e.hasNext();) sb.append(", " + e.next().getName()); } sb.append("); }"); oneNewLine(n, "generateRHS b"); spc.updateSpc(-1); sb.append(spc.spc); // f9 -> "}" n.f9.accept(this); sb = jccpv.sb = mainSB; return newSB; } /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit */ @Override public void visit(final RegularExprProduction n) { n.accept(jccpv); } /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit */ @Override public void visit(final ExpansionChoices n) { // f1 -> RegExprKind(p) if (!n.f1.present()) // f0 -> [ "<" "*" ">" | "<" < IDENTIFIER > ( "," < IDENTIFIER > )* ">" ] n.f0.accept(this); else { final String name = genNewVarName(); final VarInfo varInfo = new VarInfo(Globals.nodeChoiceName, name, "null"); varList.add(varInfo); genExpChWithChoices(n, name); finalActions(varInfo); } } /** * Visits the ExpansionChoices and adds the NodeChoice variables declarations
* (called only when there is a choice, ie f1 present.). *

* Visits the {@link ExpansionChoices}
* f0 -> Expansion(c1)
* f1 -> ( "|" Expansion(c2) )*
* * @param n the node to process * @param ident the identifier */ private void genExpChWithChoices(final ExpansionChoices n, final String ident) { int whichVal = 0; // visit the first choice (f0) // f0 -> Expansion(c1) // extra parenthesis needed ! sb.append("("); oneNewLine(n, "genExpChWithChoices a"); spc.updateSpc(+1); sb.append(spc.spc); ++bnfLvl; n.f0.accept(this); --bnfLvl; final int total = n.f1.size() + 1; if (!annotateNode) Messages.softErr("Empty NodeChoice in " + curProduction + "()"); else { genNewNodeChoiceVarDecl(ident, whichVal, total); oneNewLine(n, "genExpChWithChoices b"); spc.updateSpc(-1); sb.append(spc.spc); ++whichVal; } // visit the remaining choices (f1) // f1 -> ( "|" Expansion(c2) )* for (final Iterator e = n.f1.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // "|" seq.elementAt(0).accept(this); oneNewLine(n, "genExpChWithChoices c"); spc.updateSpc(+1); sb.append(spc.spc); // Expansion(c2) ++bnfLvl; seq.elementAt(1).accept(this); --bnfLvl; if (!annotateNode) Messages.softErr("Empty NodeChoice in " + curProduction + "()"); else { genNewNodeChoiceVarDecl(ident, whichVal, total); oneNewLine(n, "genExpChWithChoices d"); spc.updateSpc(-1); sb.append(spc.spc); ++whichVal; } } // extra parenthesis needed ! sb.append(")"); oneNewLine(n, "genExpChWithChoices e"); sb.append(spc.spc); } /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit */ @Override public void visit(final Expansion n) { // f0 -> ( "LOOKAHEAD" "(" LocalLookahead() ")" )? if (n.f0.present()) { final NodeSequence seq = (NodeSequence) n.f0.node; seq.elementAt(0).accept(this); seq.elementAt(1).accept(this); sb.append(" "); seq.elementAt(2).accept(this); sb.append(" "); seq.elementAt(3).accept(this); oneNewLine(n, "a"); sb.append(spc.spc); } // f1 -> ( ExpansionUnit(c2) )+ if (bnfLvl == 0) { n.f1.accept(this); } else { final ExpansionUnitTypeCounter v = new ExpansionUnitTypeCounter(); n.f1.accept(v); if (v.getNumNormals() == 0) annotateNode = false; else if (v.getNumNormals() == 1) { n.f1.accept(this); // The line below fixes the C grammar bug where something like // ( A() | B() | C() { someJavaCode(); } ) would cause an "Empty NodeChoice" error annotateNode = true; } else { final String name = genNewVarName(); final VarInfo varInfo = new VarInfo(Globals.nodeSeqName, name, "null"); varList.add(varInfo); genExpSequence(n, name); prevVar = varInfo; annotateNode = true; } } } /** * 4.2 Grammar production for Expansion}
* f0 -> ( "LOOKAHEAD" "(" LocalLookahead() ")" )?
* f1 -> ( ExpansionUnit(c2) )+
* * @param n the node to process * @param ident the identifier */ private void genExpSequence(final Expansion n, final String ident) { // f0 -> ( "LOOKAHEAD" "(" LocalLookahead() ")" )? // nothing done for f0 (done in Expansion) // f1 -> ( ExpansionUnit(c2) )+ final Iterator e = n.f1.elements(); // process first ExpansionUnit final ExpansionUnit expUnit = (ExpansionUnit) e.next(); if (expUnit.f0.which == 0) { // if the unit is a lookahead, visit it first expUnit.accept(this); genNewNodeSequenceVarDecl(ident, n.f1.size()); oneNewLine(n, "genExpSequence a"); sb.append(spc.spc); } else { genNewNodeSequenceVarDecl(ident, n.f1.size()); oneNewLine(n, "genExpSequence b"); sb.append(spc.spc); ++bnfLvl; expUnit.accept(this); --bnfLvl; if (annotateNode) { sb.append(addNodeString(ident, prevVar.getName())); oneNewLine(n, "genExpSequence c"); sb.append(spc.spc); } } // visit the other nodes that need to be for (; e.hasNext();) { ++bnfLvl; (e.next()).accept(this); --bnfLvl; if (annotateNode) { sb.append(addNodeString(ident, prevVar.getName())); oneNewLine(n, "genExpSequence d"); sb.append(spc.spc); } } } /** * Returns the java block for adding a node to its parent. * * @param parentName the parent node * @param varName the node's variable name * @return the java block */ private final String addNodeString(final String parentName, final String varName) { return "{ ".concat(parentName).concat(".addNode(").concat(varName).concat("); }"); } /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit */ @Override public void visit(final LocalLookahead n) { // Don't want to annotate these n.accept(jccpv); } /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit */ @Override public void visit(final ExpansionUnit n) { NodeSequence seq; switch (n.f0.which) { case 0: // %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" seq = (NodeSequence) n.f0.choice; seq.elementAt(0).accept(this); seq.elementAt(1).accept(this); sb.append(" "); seq.elementAt(2).accept(this); sb.append(" "); seq.elementAt(3).accept(this); oneNewLine(n, "0"); sb.append(spc.spc); return; case 1: // %1 Block() n.f0.choice.accept(this); oneNewLine(n, "1"); sb.append(spc.spc); annotateNode = false; return; case 2: // %2 #0 "[" #1 ExpansionChoices() #2 "]" genBracketExpCh(n); return; case 3: // %3 ExpansionUnitInTCF() n.f0.choice.accept(this); return; case 4: // %4 #0 [ $0 PrimaryExpression() $1 "=" ] // .. #1 ( &0 $0 Identifier() $1 Arguments() // .. .. | &1 $0 RegularExpression() // .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] ) seq = (NodeSequence) n.f0.choice; final NodeOptional opt1 = (NodeOptional) seq.elementAt(0); final NodeChoice ch = (NodeChoice) seq.elementAt(1); final NodeSequence seq1 = (NodeSequence) ch.choice; String name; if (ch.which == 0) { // &0 $0 Identifier() $1 Arguments() final String ident = ((Identifier) seq1.elementAt(0)).f0.tokenImage; if (jcpHT.containsKey(ident)) { // generate JavaCodeProduction() if a JavaCodeProduction // $0 Identifier() seq1.elementAt(0).accept(jccpv); // $1 Arguments() sb.append(genJavaBranch(seq1.elementAt(1))); } else { // generate nx = Production() if not a JavaCodeProduction name = genNewVarName(); final VarInfo varInfo = inEUT3 ? new VarInfo(ident, name, "null") : new VarInfo(ident, name); varList.add(varInfo); sb.append(name); sb.append(" = "); // $0 Identifier() seq1.elementAt(0).accept(jccpv); // $1 Arguments() sb.append(genJavaBranch(seq1.elementAt(1))); finalActions(varInfo); } oneNewLine(n, "4a"); sb.append(spc.spc); if (opt1.present()) { // generate pe = jtbrt_Identifier; final NodeSequence seq2 = (NodeSequence) opt1.node; sb.append("{ "); // $0 PrimaryExpression() sb.append(genJavaBranch(seq2.elementAt(0))); sb.append(" "); // $1 "=" seq2.elementAt(1).accept(this); sb.append(" "); // Identifier() -> jtbrt_Identifier sb.append(Globals.JTBRT_PREFIX).append(ident); sb.append("; }"); oneNewLine(n, "4b"); sb.append(spc.spc); } } else { // &1 $0 RegularExpression() $1 [ £0 "." £1 < IDENTIFIER > ] ) // $0 RegularExpression() seq1.elementAt(0).accept(this); final NodeOptional opt2 = (NodeOptional) seq1.elementAt(1); // $1 [ £0 "." £1 < IDENTIFIER > ] if (opt2.present()) { sb.append("."); ((NodeSequence) opt2.node).elementAt(1).accept(this); } if (opt1.present()) { // above has generated nx = RegularExpression and generate now { pe = nx; } oneNewLine(n, "4c"); sb.append(spc.spc); final NodeSequence seq2 = (NodeSequence) opt1.node; sb.append("{ "); // $0 PrimaryExpression() sb.append(genJavaBranch(seq2.elementAt(0))); sb.append(" "); // $1 "=" seq2.elementAt(1).accept(this); sb.append(" "); // variable generated for RegularExpression(c) sb.append(reTokenName); sb.append("; }"); oneNewLine(n, "4d"); sb.append(spc.spc); } } return; case 5: // %5 #0 "(" #1 ExpansionChoices() #2 ")" // .. #3 ( &0 "+" | &1 "*" | &2 "?" )? genParenExpCh(n); return; default: Messages.hardErr("n.f0.which = " + String.valueOf(n.f0.which)); return; } } /** * Generates the bracketed expansion choices fragment
* (choice 2 of {@link Expansion Unit}.
* ExpansionUnit n -> "[" ExpansionChoices(c) "]"
* * @param n the node to process */ private void genBracketExpCh(final ExpansionUnit n) { // seq -> "[" ExpansionChoices(c) "]" final NodeSequence seq = (NodeSequence) n.f0.choice; // ec -> ExpansionChoices(c) final ExpansionChoices ec = (ExpansionChoices) seq.elementAt(1); String name; // "[" seq.elementAt(0).accept(this); oneNewLine(n, "genBracketExpCh 1"); spc.updateSpc(+1); sb.append(spc.spc); name = genNewVarName(); VarInfo varInfo; // build the list of expansion units final NodeList list = ec.f0.f1; // count the number of ExpansionUnits of each type (choice) eutcv.reset(); ec.accept(eutcv); // print the first item first if it's a lookahead and not in a choice if (eutcv.getNumNormals() == 0) { // technically, we should only generate an error if it's not a choice, // but that greatly complicates things and an empty choice is probably useless. Messages.softErr("Empty BNF expansion in " + curProduction + "()", ((NodeToken) seq.elementAt(0)).beginLine); } else { final ExpansionUnit firstExpUnit = (ExpansionUnit) list.nodes.get(0); if (extraVarsList == null) // top level additional variables varInfo = creNewVarInfoForBracket(name, true); else { // nested additional variables varInfo = creNewVarInfoForBracket(name, false); extraVarsList.add(varInfo); } varList.add(varInfo); final NodeOptional expLA = ec.f0.f0; if (!ec.f1.present() && expLA.present()) { // not in an ExpansionChoices choice and with an Expansion Lookahead final NodeSequence seq1 = (NodeSequence) expLA.node; seq1.elementAt(0).accept(this); seq1.elementAt(1).accept(this); sb.append(" "); seq1.elementAt(2).accept(this); sb.append(" "); seq1.elementAt(3).accept(this); oneNewLine(n, "genBracketExpCh 2"); sb.append(spc.spc); // don't print lookahead twice, so remove temporary the ec.f0.f0 node ec.f0.f0.node = null; genExpChInExpUnit(ec); // restore ec.f0.f0 node ec.f0.f0.node = expLA.node; } else if (!ec.f1.present() && (firstExpUnit.f0.which == 0)) { // not in an ExpansionChoices choice and with an ExpansionUnit Lookahead final NodeSequence seq1 = (NodeSequence) firstExpUnit.f0.choice; seq1.elementAt(0).accept(this); seq1.elementAt(1).accept(this); sb.append(" "); seq1.elementAt(2).accept(this); sb.append(" "); seq1.elementAt(3).accept(this); oneNewLine(n, "genBracketExpCh 3" + " ??? should we go through here ???"); sb.append(spc.spc); // don't print lookahead twice, so remove it temporary from the ec.f0.f1 list of nodes list.nodes.get(0); genExpChInExpUnit(ec); // restore the ec.f0.f1 list of nodes list.nodes.add(0, firstExpUnit); } else { // in an ExpansionChoices choice or without an Expansion or ExpansionUnit Lookahead genExpChInExpUnit(ec); } if (annotateNode) sb.append(addNodeString(name, prevVar.getName())); finalActions(varInfo); } oneNewLine(n, "genBracketExpCh 4"); spc.updateSpc(-1); sb.append(spc.spc); // "]" seq.elementAt(2).accept(this); oneNewLine(n, "genBracketExpCh 5"); sb.append(spc.spc); } /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit */ @Override public void visit(final ExpansionUnitInTCF n) { // f0 -> "try" n.f0.accept(this); sb.append(" "); // f1 -> "{" n.f1.accept(this); spc.updateSpc(+1); oneNewLine(n, "a"); sb.append(spc.spc); // f2 -> ExpansionChoices() inEUT3 = true; n.f2.accept(this); inEUT3 = false; spc.updateSpc(-1); oneNewLine(n, "b"); sb.append(spc.spc); // f3 -> "}" n.f3.accept(this); // f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )* if (n.f4.present()) { for (final Iterator e = n.f4.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); oneNewLine(n, "c"); sb.append(spc.spc); // #0 "catch" seq.elementAt(0).accept(this); sb.append(" "); // #1 "(" seq.elementAt(1).accept(this); // #2 Name() sb.append(genJavaBranch(seq.elementAt(2))); sb.append(" "); // #3 < IDENTIFIER > seq.elementAt(3).accept(this); // #4 ")" seq.elementAt(4).accept(this); sb.append(" "); // #5 Block() seq.elementAt(5).accept(this); } } // f5 -> [ #0 "finally" #1 Block() ] if (n.f5.present()) { final NodeSequence seq = (NodeSequence) n.f5.node; oneNewLine(n, "d"); sb.append(spc.spc); // #0 "finally" seq.elementAt(0).accept(this); sb.append(" "); // #1 Block() seq.elementAt(1).accept(this); } oneNewLine(n, "e"); sb.append(spc.spc); } /** * Generates the parenthesised expansion choices fragment
* (choice 5 of {@link Expansion Unit}.
* ExpansionUnit n -> "(" ExpansionChoices(c) ")" ( "+" | "*" | "?" )?
* * @param n the node to process */ private void genParenExpCh(final ExpansionUnit n) { // seq -> "(" ExpansionChoices(c) ")" ( "+" | "*" | "?" )? final NodeSequence seq = (NodeSequence) n.f0.choice; // ec -> ExpansionChoices(c) final ExpansionChoices ec = (ExpansionChoices) seq.elementAt(1); String name; // "(" seq.elementAt(0).accept(this); oneNewLine(n, "genParenExpCh 1"); spc.updateSpc(+1); sb.append(spc.spc); // seq.elementAt(3) -> ( "+" | "*" | "?" )? if (!((NodeOptional) seq.elementAt(3)).present()) { // No BNF modifier present, so either generate a NodeChoice or a NodeSequence if (ec.f1.present()) // generate a NodeChoice ec.accept(this); else { // generate a NodeSequence // count the number of ExpansionUnits of each type (choice) eutcv.reset(); ec.accept(eutcv); if (eutcv.getNumNormals() == 0) Messages.warning("Empty parentheses in " + curProduction + "()", ((NodeToken) seq.elementAt(0)).beginLine); name = genNewVarName(); final VarInfo varInfo = inEUT3 ? new VarInfo(Globals.nodeSeqName, name, "null") : new VarInfo(Globals.nodeSeqName, name); varList.add(varInfo); genExpSequence(ec.f0, name); finalActions(varInfo); } oneNewLine(n, "genParenExpCh 2"); spc.updateSpc(-1); sb.append(spc.spc); // ")" seq.elementAt(2).accept(this); oneNewLine(n, "genParenExpCh 3"); } else { // an BNF modifier is present so generate the appropriate structure // ch -> ( "+" | "*" | "?" )? final NodeChoice ch = (NodeChoice) ((NodeOptional) seq.elementAt(3)).node; name = genNewVarName(); VarInfo varInfo; // build the list of expansion units final NodeList list = ec.f0.f1; // count the number of ExpansionUnits of each type (choice) eutcv.reset(); ec.accept(eutcv); // print the first item first if it's a lookahead and not in a choice if (eutcv.getNumNormals() == 0) { // technically, we should only generate an error if it's not a choice, // but that greatly complicates things and an empty choice is probably useless. Messages.softErr("Empty BNF expansion in " + curProduction + "()", ((NodeToken) seq.elementAt(0)).beginLine); } else { final ExpansionUnit firstExpUnit = (ExpansionUnit) list.nodes.get(0); if (extraVarsList == null) // top level additional variables varInfo = creNewVarInfoForMod(ch, name, true); else { // nested additional variables varInfo = creNewVarInfoForMod(ch, name, false); extraVarsList.add(varInfo); } varList.add(varInfo); final NodeOptional expLA = ec.f0.f0; if (!ec.f1.present() && expLA.present()) { // not in an ExpansionChoices choice and with an Expansion Lookahead final NodeSequence seq1 = (NodeSequence) expLA.node; seq1.elementAt(0).accept(this); seq1.elementAt(1).accept(this); sb.append(" "); seq1.elementAt(2).accept(this); sb.append(" "); seq1.elementAt(3).accept(this); oneNewLine(n, "genParenExpCh 4"); sb.append(spc.spc); // don't print lookahead twice, so remove temporary the ec.f0.f0 node ec.f0.f0.node = null; genExpChInExpUnit(ec); // restore ec.f0.f0 node ec.f0.f0.node = expLA.node; } else if (!ec.f1.present() && (firstExpUnit.f0.which == 0)) { // not in an ExpansionChoices choice and with an ExpansionUnit Lookahead final NodeSequence seq1 = (NodeSequence) firstExpUnit.f0.choice; seq1.elementAt(0).accept(this); seq1.elementAt(1).accept(this); sb.append(" "); seq1.elementAt(2).accept(this); sb.append(" "); seq1.elementAt(3).accept(this); oneNewLine(n, "genParenExpCh 5" + " ??? should we go through here ???"); sb.append(spc.spc); // don't print lookahead twice, so remove it temporary from the ec.f0.f1 list of nodes list.nodes.get(0); genExpChInExpUnit(ec); // restore the ec.f0.f1 list of nodes list.nodes.add(0, firstExpUnit); } else { // in an ExpansionChoices choice or without an Expansion or ExpansionUnit Lookahead genExpChInExpUnit(ec); } if (annotateNode) sb.append(addNodeString(name, prevVar.getName())); finalActions(varInfo); } oneNewLine(n, "genParenExpCh 6"); spc.updateSpc(-1); sb.append(spc.spc); // ")" seq.elementAt(2).accept(this); // "+" or "*" or "?" ch.choice.accept(this); oneNewLine(n, "genParenExpCh 7"); if (ch.which != 2) { // // temporary displays : production;node;size;normals // sb.append(spc.spc); // sb.append("{ System.out.println(\"").append(curProduction).append(";").append(name) // .append(";\" + ").append(name).append(".nodes.size() + \";\" + ") // .append(eutc.getNumNormals()).append("); }"); // oneNewLine(n); sb.append(spc.spc); sb.append("{ ").append(name).append(".nodes.trimToSize(); }"); oneNewLine(n, "genParenExpCh 8"); } } sb.append(spc.spc); } /** * Common code for generating the ExpansionChoices in choices 2, 3 and 5 of ExpansionUnit. * * @param n the node to process */ private void genExpChInExpUnit(final ExpansionChoices n) { // put apart "main" sb, create a new temp sb to generate a list of extra variables nested into final StringBuilder mainSB = sb; final StringBuilder tempSB = new StringBuilder(512); sb = jccpv.sb = tempSB; // put apart "extraVarsList", create a new "tempExtraVarsList" to generate a new list final ArrayList tempExtraVarsList = extraVarsList; extraVarsList = new ArrayList(); // new sb will be fed by this ExpansionChoices accept ++bnfLvl; n.accept(this); --bnfLvl; if (extraVarsList.size() > 0) { // we have nested extra variables, generate them in the "main" sb for (final Iterator e = extraVarsList.iterator(); e.hasNext();) { genNewNodeOptOrListOrListOptVarDecl(mainSB, e.next()); oneNewLine(n, "K", mainSB); mainSB.append(spc.spc); } } // restore original "main" sb and extraVarsList sb = jccpv.sb = mainSB; extraVarsList = tempExtraVarsList; // print temp sb sb.append(tempSB); } /** * Creates a new VarInfo object (with the appropriate node type) for a given BNF modifier. * * @param modifier the modifier (which directs the node type) * @param varName the variable name to store * @param initialize the need to initialize flag * @return the new VarInfo object */ private VarInfo creNewVarInfoForMod(final NodeChoice modifier, final String varName, final boolean initialize) { if (initialize) { if (modifier.which == 0) // "+" return new VarInfo(Globals.nodeListName, varName, "new " + Globals.nodeListName + "()"); else if (modifier.which == 1) // "*" return new VarInfo(Globals.nodeListOptName, varName, "new " + Globals.nodeListOptName + "()"); else if (modifier.which == 2) // "?" return new VarInfo(Globals.nodeOptName, varName, "new " + Globals.nodeOptName + "()"); else Messages.hardErr("Illegal BNF modifier: " + modifier.choice.toString()); } else { if (modifier.which == 0) // "+" return new VarInfo(Globals.nodeListName, varName); else if (modifier.which == 1) // "*" return new VarInfo(Globals.nodeListOptName, varName); else if (modifier.which == 2) // "?" return new VarInfo(Globals.nodeOptName, varName); else Messages.hardErr("Illegal BNF modifier: " + modifier.choice.toString()); } return null; // shouldn't happen } /** * Creates a new VarInfo object for a NodeOptional node. * * @param varName the variable name to store * @param initializer the initializer presence flag * @return the new VarInfo object */ private VarInfo creNewVarInfoForBracket(final String varName, final boolean initializer) { if (initializer) { return new VarInfo(Globals.nodeOptName, varName, "new " + Globals.nodeOptName + "()"); } else { return new VarInfo(Globals.nodeOptName, varName); } } /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit */ @Override public void visit(final RegularExpression n) { final String nodeName = genNewVarName(); reTokenName = genNewVarName(); final VarInfo nodeTokenInfo = new VarInfo(Globals.nodeTokenName, nodeName); final VarInfo tokenNameInfo = new VarInfo("Token", reTokenName); varList.add(nodeTokenInfo); varList.add(tokenNameInfo); sb.append(reTokenName); sb.append(" = "); if (n.f0.which == 0) { // StringLiteral() n.f0.choice.accept(jccpv); oneNewLine(n, "a"); sb.append(spc.spc); sb.append("{ ").append(nodeName).append(" = JTBToolkit.makeNodeToken(").append(reTokenName) .append("); }"); oneNewLine(n, "b"); } else if (n.f0.which == 1) { // [ [ "#" ] Identifier() ":" ] ComplexRegularExpressionChoices(c) "> final NodeSequence seq = (NodeSequence) n.f0.choice; // "<" seq.elementAt(0).accept(this); // opt -> [ [ "#" ] Identifier() ":" ] final NodeOptional opt = (NodeOptional) seq.elementAt(1); if (opt.present()) { final NodeSequence seq1 = (NodeSequence) opt.node; if (((NodeOptional) seq1.elementAt(0)).present()) // "#" seq1.elementAt(0).accept(jccpv); // Identifier() seq1.elementAt(1).accept(jccpv); sb.append(" "); // ":" seq1.elementAt(2).accept(jccpv); sb.append(" "); } // ComplexRegularExpressionChoices(c) seq.elementAt(2).accept(jccpv); // ">" seq.elementAt(3).accept(jccpv); sb.append(" "); oneNewLine(n, "c"); sb.append(spc.spc); sb.append("{ ").append(nodeName).append(" = JTBToolkit.makeNodeToken(").append(reTokenName) .append("); }"); oneNewLine(n, "d"); } else if (n.f0.which == 2) { // "<" Identifier() ">" final NodeSequence seq1 = (NodeSequence) n.f0.choice; // "<" seq1.elementAt(0).accept(jccpv); sb.append(" "); // Identifier() seq1.elementAt(1).accept(jccpv); sb.append(" "); // ">" seq1.elementAt(2).accept(jccpv); oneNewLine(n, "e"); sb.append(spc.spc); sb.append("{ ").append(nodeName).append(" = JTBToolkit.makeNodeToken(").append(reTokenName) .append("); }"); oneNewLine(n, "f"); } else { sb.append("< EOF >"); // "<" "EOF" ">" // Compensate for the position of sb.append(" {"); oneNewLine(n, "g"); spc.updateSpc(+1); sb.append(spc.spc); sb.append(reTokenName).append(".beginColumn++;"); oneNewLine(n, "h"); sb.append(spc.spc); sb.append(reTokenName).append(".endColumn++;"); oneNewLine(n, "i"); sb.append(spc.spc); sb.append("{ ").append(nodeName).append(" = JTBToolkit.makeNodeToken(").append(reTokenName) .append("); }"); oneNewLine(n, "j"); spc.updateSpc(-1); sb.append(spc.spc); sb.append("}"); oneNewLine(n, "k"); } sb.append(spc.spc); finalActions(nodeTokenInfo); } /** * Generates a new NodeChoice variable declaration. * * @param varName the variable name * @param whichVal the value of the which field * @param totalVal the value of the total field */ private void genNewNodeChoiceVarDecl(final String varName, final int whichVal, final int totalVal) { sb.append("{ ").append(varName).append(" = new NodeChoice(").append(prevVar.getName()) .append(", ").append(String.valueOf(whichVal)).append(", ").append(String.valueOf(totalVal)) .append("); }"); } /** * Generates a new NodeSequence variable declaration. * * @param varName the variable name * @param nbNodes the number of nodes */ private void genNewNodeSequenceVarDecl(final String varName, final int nbNodes) { sb.append("{ ").append(varName).append(" = new NodeSequence(").append(nbNodes).append("); }"); } /** * Generates a new NodeOptional or NodeList or NodeListOptional variable declaration. * * @param aSB the StringBuilder to print to * @param aVarInfo the VarInfo variable */ private void genNewNodeOptOrListOrListOptVarDecl(final StringBuilder aSB, final VarInfo aVarInfo) { aSB.append("{ ").append(aVarInfo.getName()).append(" = new ").append(aVarInfo.getType()) .append("(); }"); } /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final Block n) { // f0 -> "{" n.f0.accept(this); // f1 -> ( BlockStatement() )* if (n.f1.present()) { spc.updateSpc(+1); oneNewLine(n, "x"); sb.append(spc.spc); for (final Iterator e = n.f1.elements(); e.hasNext();) { // BlockStatement() e.next().accept(this); if (e.hasNext()) { oneNewLine(n, "y"); sb.append(spc.spc); } } spc.updateSpc(-1); oneNewLine(n, "z"); sb.append(spc.spc); } // f2 -> "}" n.f2.accept(this); } /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit */ @Override public void visit(final BlockStatement n) { if (n.f0.which == 1) { // Statement() n.f0.choice.accept(this); } else { // others sb.append(genJavaBranch(n.f0.choice)); } } /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit */ @Override public void visit(final Statement n) { if (n.f0.which == 1 || n.f0.which == 3 || n.f0.which == 4 || n.f0.which == 10 || n.f0.which == 11 || n.f0.which == 13) { // all statements which do not lead to a ReturnStatement() sb.append(genJavaBranch(n.f0.choice)); } else { // others n.f0.choice.accept(this); } } /** * Visits the {@link TryStatement}
* f0 -> "try"
* f1 -> Block(null)
* f2 -> ( "catch" "(" FormalParameter() ")" Block(null) )*
* f3 -> [ "finally" Block(null) ]
* * @param n the node to visit */ @Override public void visit(final TryStatement n) { // f0 -> "try" n.f0.accept(this); sb.append(" "); // f1 -> Block(null) n.f1.accept(this); // f2 -> ( "catch" "(" FormalParameter() ")" Block(null) )* for (final Iterator e = n.f2.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); oneNewLine(n); sb.append(spc.spc); // "catch" seq.elementAt(0).accept(this); sb.append(" "); // "(" seq.elementAt(1).accept(this); // FormalParameter() sb.append(genJavaBranch(seq.elementAt(2))); // ")" seq.elementAt(3).accept(this); sb.append(" "); // Block(null) seq.elementAt(4).accept(this); } // f3 -> [ "finally" Block(null) ] if (n.f3.present()) { final NodeSequence seq = (NodeSequence) n.f3.node; oneNewLine(n); sb.append(spc.spc); // "finally" seq.elementAt(0).accept(this); sb.append(" "); // Block(null seq.elementAt(1).accept(this); } } /** * Visits the {@link LabeledStatement}
* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit */ @Override public void visit(final LabeledStatement n) { // f0 -> < IDENTIFIER > n.f0.accept(this); // f1 -> ":" n.f1.accept(this); oneNewLine(n); sb.append(spc.spc); // f2 -> Statement() n.f2.accept(this); } /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit */ @Override public void visit(final SwitchStatement n) { // f0 -> "switch" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) sb.append(genJavaBranch(n.f2)); // f3 -> ")" n.f3.accept(this); sb.append(" "); // f4 -> "{" n.f4.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // ( SwitchLabel() ( BlockStatement() )* )* for (final Iterator e = n.f5.elements(); e.hasNext();) { final NodeSequence seq = (NodeSequence) e.next(); // SwitchLabel() sb.append(genJavaBranch(seq.elementAt(0))); spc.updateSpc(+1); final NodeListOptional nlo = (NodeListOptional) seq.elementAt(1); if ((nlo).present()) { if (nlo.size() == 1) sb.append(" "); else { oneNewLine(n); sb.append(spc.spc); } for (final Iterator e1 = nlo.elements(); e1.hasNext();) { // BlockStatement() e1.next().accept(this); if (e1.hasNext()) { oneNewLine(n); sb.append(spc.spc); } } } oneNewLine(n); spc.updateSpc(-1); } spc.updateSpc(-1); sb.append(spc.spc); // f6 -> "}" n.f6.accept(this); oneNewLine(n); } /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit */ @Override public void visit(final IfStatement n) { // f0 -> "if" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) sb.append(genJavaBranch(n.f2)); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() if (n.f4.f0.which != 2) { // if Statement() not a Block spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); } else { // if Statement() is a Block sb.append(" "); } n.f4.accept(this); if (n.f4.f0.which != 2) // if Statement() not a Block spc.updateSpc(-1); // f5 -> [ "else" Statement() ] if (n.f5.present()) { if (n.f4.f0.which != 2) {// if Statement() not a Block oneNewLine(n); sb.append(spc.spc); } else { // if Statement() is a Block sb.append(" "); } // "else" ((NodeSequence) n.f5.node).elementAt(0).accept(this); // Statement() final Statement st = (Statement) ((NodeSequence) n.f5.node).elementAt(1); if (st.f0.which != 2) { // else Statement() is not a Block() spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // Statement() st.f0.choice.accept(this); spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } else { // else Statement() is a Block() sb.append(" "); // Statement() st.f0.choice.accept(this); } } } /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ @Override public void visit(final WhileStatement n) { // f0 -> "while" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) sb.append(genJavaBranch(n.f2)); // f3 -> ")" n.f3.accept(this); // f4 -> Statement() genStatement(n.f4); } /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit */ @Override public void visit(final DoStatement n) { // f0 -> "do" n.f0.accept(this); // f1 -> Statement() genStatement(n.f1); // f2 -> "while" n.f2.accept(this); sb.append(" "); // f3 -> "(" n.f3.accept(this); // f4 -> Expression(null) sb.append(genJavaBranch(n.f4)); // f5 -> ")" n.f5.accept(this); // f6 -> ";" n.f6.accept(this); } /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit */ @Override public void visit(final ForStatement n) { // f0 -> "for" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> ( Modifiers() Type() < IDENTIFIER > ":" Expression(null) | [ ForInit() ] ";" [ Expression(null) ] ";" [ ForUpdate() ] ) final NodeSequence seq = (NodeSequence) n.f2.choice; if (n.f2.which == 0) { // Modifiers() Type() < IDENTIFIER > ":" Expression(null) sb.append(genJavaBranch(seq.elementAt(0))); // Modifiers print the last space if not empty // Type() sb.append(genJavaBranch(seq.elementAt(1))); sb.append(" "); // < IDENTIFIER > seq.elementAt(2).accept(this); sb.append(" "); // Expression(null) sb.append(genJavaBranch(seq.elementAt(3))); } else { NodeOptional opt; // [ ForInit() ] ";" [ Expression(null) ] ";" [ ForUpdate() ] ) // [ ForInit() ] opt = (NodeOptional) seq.elementAt(0); if (opt.present()) sb.append(genJavaBranch(opt.node)); // ";" seq.elementAt(1).accept(this); sb.append(" "); // [ Expression(null) ] opt = (NodeOptional) seq.elementAt(2); if (opt.present()) sb.append(genJavaBranch(opt.node)); // ";" seq.elementAt(3).accept(this); sb.append(" "); // [ ForUpdate() ] opt = (NodeOptional) seq.elementAt(4); if (opt.present()) sb.append(genJavaBranch(opt.node)); } // f3 -> ")" n.f3.accept(this); // f4 -> Statement() genStatement(n.f4); } /** * Generates the source code corresponding to a Statement. * * @param n the Statement node */ void genStatement(final Statement n) { if (n.f0.which != 2) { // case Statement is not a Block spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // Statement() n.accept(this); spc.updateSpc(-1); oneNewLine(n); sb.append(spc.spc); } else { // case Statement is a Block sb.append(" "); // Statement() n.accept(this); sb.append(" "); } } /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit */ @Override public void visit(final ReturnStatement n) { if (resultType == null) { // keep return statement // f0 -> "return" n.f0.accept(this); if (n.f1.present()) { sb.append(" "); // f1 -> [ Expression(null) ] sb.append(genJavaBranch(n.f1)); } // f2 -> ";" n.f2.accept(this); } else { // change return statement sb.append(Globals.JTBRT_PREFIX).append(curProduction).append(" = "); if (n.f1.present()) { // should always be present ! // f1 -> [ Expression(null) ] sb.append(genJavaBranch(n.f1)); } // f2 -> ";" n.f2.accept(this); } } /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit */ @Override public void visit(final SynchronizedStatement n) { // f0 -> "synchronized" n.f0.accept(this); sb.append(" "); // f1 -> "(" n.f1.accept(this); // f2 -> Expression(null) sb.append(genJavaBranch(n.f2)); // f3 -> ")" n.f3.accept(this); spc.updateSpc(+1); oneNewLine(n); sb.append(spc.spc); // f4 -> Block(null) n.f4.accept(this); spc.updateSpc(-1); } /** * The GlobalDataFinder visitor finds}
* all "void" JavaCodeProductions and adds them to a Hashtable (which will be used to avoid * creating later invalid child nodes),
* all non "void" BNFProductions and constructs a list of return variables declarations (to be * inserted in the compilation unit by the {@link CompilationUnitPrinter}). */ class GlobalDataFinder extends DepthFirstVoidVisitor { /** * Constructor, with a given buffer and a default indentation. */ GlobalDataFinder() { super(); } /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit */ @Override public void visit(final JavaCCInput n) { // visits only Productions // f10 -> ( Production() )+ for (final Iterator e = n.f10.elements(); e.hasNext();) { e.next().accept(this); } } /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit */ @Override public void visit(final Production n) { // visits only JavaCodeProduction and BNFProduction if (n.f0.which == 0 || n.f0.which == 3) n.f0.accept(this); } /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit */ @Override public void visit(final JavaCodeProduction n) { // f3 -> Identifier() // store it in the hashtable final String ident = n.f3.f0.tokenImage; jcpHT.put(ident, ident); // store it in the list if non "void" final String resType = getResultType(n.f2); if (!"void".equals(resType)) { final String comm = "/** Return variable for {@link #".concat(ident) .concat("} production */"); retVarDecl.add(comm); final String decl = (Globals.staticFlag ? "static " : "") .concat(resType) .concat(" " + Globals.JTBRT_PREFIX) .concat(ident).concat(";"); retVarDecl.add(decl); } } /** * Gets the ResultType. Walks down the tree to find the first token. *

* {@link ResultType}
* f0 -> ( "void" | Type() )
*

* {@link Type}
* f0 -> ReferenceType()
* | PrimitiveType()
*

* {@link ReferenceType}
* f0 -> PrimitiveType() ( "[" "]" )+
* | ClassOrInterfaceType() ( "[" "]" )*
*

* {@link PrimitiveType}
* f0 -> "boolean"
* | "char"
* | "byte"
* | "short"
* | "int"
* | "long"
* | "float"
* | "double"
*

* {@link ClassOrInterfaceType}
* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( "." < IDENTIFIER > [ TypeArguments() ] )*
* * @param rt the node to process * @return the result type token image */ String getResultType(final ResultType rt) { NodeToken tk; final INode n = rt.f0.choice; if (rt.f0.which == 0) { // "void" tk = (NodeToken) n; } else { // Type( final NodeChoice ch = ((Type) n).f0; if (ch.which == 0) { // ReferenceType() final NodeChoice ch1 = ((ReferenceType) ch.choice).f0; if (ch1.which == 0) { // PrimitiveType() ( "[" "]" )+ tk = (NodeToken) ((PrimitiveType) ch1.choice).f0.choice; } else { // ClassOrInterfaceType() ( "[" "]" )* tk = ((ClassOrInterfaceType) ((NodeSequence) ch1.choice).elementAt(0)).f0; } } else { // PrimitiveType() tk = (NodeToken) ((PrimitiveType) ch.choice).f0.choice; } } return tk.tokenImage; } /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit */ @Override public void visit(final BNFProduction n) { // f1 -> ResultType(p.getReturnTypeTokens()) final ResultType rt = n.f1; NodeToken tk; final INode in = rt.f0.choice; if (rt.f0.which == 0) { // "void" : no need for return variable return; } else { // Type( final NodeChoice ch = ((Type) in).f0; if (ch.which == 0) { // ReferenceType() final NodeChoice ch1 = ((ReferenceType) ch.choice).f0; if (ch1.which == 0) { // PrimitiveType() ( "[" "]" )+ tk = (NodeToken) ((PrimitiveType) ch1.choice).f0.choice; } else { // ClassOrInterfaceType() ( "[" "]" )* tk = ((ClassOrInterfaceType) ((NodeSequence) ch1.choice).elementAt(0)).f0; } } else { // PrimitiveType() tk = (NodeToken) ((PrimitiveType) ch.choice).f0.choice; } } final String resType = tk.tokenImage; final String ident = n.f2.f0.tokenImage; final String comm = "/** Return variable for {@link #".concat(ident) .concat("} production */"); retVarDecl.add(comm); final String decl = (Globals.staticFlag ? "static " : "").concat(resType) .concat(" " + Globals.JTBRT_PREFIX) .concat(ident).concat(";"); retVarDecl.add(decl); } } /** * The CompilationUnitPrinter visitor}
* determines if an import statement for the syntax tree package is needed in the grammar file,
* prints the compilation unit (with appropriate tool kit methods), inserting the import * statements if necessary. */ class CompilationUnitPrinter extends JavaPrinter { /** * Constructor, with a given buffer and a default indentation. * * @param aSB the StringBuilder to print into (will be allocated if null) * @param aSPC the Spacing indentation object (will be allocated and set to a default if null) */ CompilationUnitPrinter(final StringBuilder aSB, final Spacing aSPC) { super(aSB, aSPC); } /* * Convenience methods */ /** * Prints into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void oneNewLine(final INode n) { sb.append(nodeClassComment(n)).append(LS); } /** * Prints into the current buffer a node class comment, an extra given comment, and a new line. * * @param n the node for the node class comment * @param str the extra comment */ @Override void oneNewLine(final INode n, final String str) { sb.append(nodeClassComment(n, str)).append(LS); } /** * Prints twice into the current buffer a node class comment and a new line. * * @param n the node for the node class comment */ @Override void twoNewLines(final INode n) { oneNewLine(n); oneNewLine(n); } /** * Returns a node class comment (a //!! followed by the node class short name if global flag * set, nothing otherwise). * * @param n the node for the node class comment * @return the node class comment */ String nodeClassComment(final INode n) { if (Globals.PRINT_CLASS_COMMENT) { final String s = n.toString(); final int b = s.lastIndexOf('.') + 1; final int e = s.indexOf('@'); if (b == -1 || e == -1) return " //!! " + s; else return " //!! " + s.substring(b, e); } else return ""; } /** * Returns a node class comment with an extra comment (a //!! followed by the node class short * name plus the extra comment if global flag set, nothing otherwise). * * @param n the node for the node class comment * @param str the extra comment * @return the node class comment */ String nodeClassComment(final INode n, final String str) { if (Globals.PRINT_CLASS_COMMENT) return nodeClassComment(n) + " " + str; else return ""; } /* * User grammar generated and overridden visit methods below */ /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit */ @Override public void visit(final CompilationUnit n) { // f0 -> [ PackageDeclaration() ] if (n.f0.present()) { n.f0.node.accept(this); twoNewLines(n); } // f1 -> ( ImportDeclaration() )* printImports(n.f1); twoNewLines(n); // f2 -> ( TypeDeclaration() )* if (n.f2.present()) { for (final Iterator e = n.f2.elements(); e.hasNext();) { e.next().accept(this); if (e.hasNext()) { twoNewLines(n); } } } // builds specials into tree if (!Globals.keepSpecialTokens) { sb.append(LS); sb.append("class JTBToolkit {").append(LS); sb.append(LS); sb.append(" static NodeToken makeNodeToken(final Token t) {").append(LS); sb .append( " return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);") .append(LS); sb.append(" }").append(LS); sb.append("}"); oneNewLine(n); } else { sb.append(LS); sb.append("class JTBToolkit {").append(LS); sb.append(LS); sb.append(" static NodeToken makeNodeToken(final Token tok) {").append(LS); sb .append( " final NodeToken node = new NodeToken(tok.image.intern(), tok.kind, tok.beginLine, tok.beginColumn, tok.endLine, tok.endColumn);") .append(LS); sb.append(" if (tok.specialToken == null)").append(LS); sb.append(" return node;").append(LS); sb .append( " final java.util.ArrayList temp = new java.util.ArrayList();") .append(LS); sb.append(" Token t = tok;").append(LS); sb.append(" while (t.specialToken != null) {").append(LS); sb.append(" t = t.specialToken;").append(LS); sb .append( " temp.add(new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn));") .append(LS); sb.append(" }").append(LS); sb.append(" for (int i = temp.size() - 1; i >= 0; --i)").append(LS); sb.append(" node.addSpecial(temp.get(i));").append(LS); sb.append(" node.trimSpecials();").append(LS); sb.append(" return node;").append(LS); sb.append(" }").append(LS); sb.append("}"); oneNewLine(n); } } /** * Visits the {@link ImportDeclaration}
* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name(null)
* f3 -> [ "." "*" ]
* f4 -> ";"
* * @param n the node to process */ private void printImports(final NodeListOptional n) { if (Globals.nodesPackageName == "") return; boolean foundTreeImport = false; final StringBuilder mainSB = sb; final StringBuilder newSB = new StringBuilder(128); sb = newSB; for (final Iterator e = n.elements(); e.hasNext();) { final ImportDeclaration dec = (ImportDeclaration) e.next(); newSB.setLength(0); dec.accept(this); final String s = newSB.toString(); mainSB.append(s).append(nodeClassComment(n, " Y")).append(LS); if (s.equals(Globals.nodesPackageName + ".*;")) foundTreeImport = true; } sb = mainSB; if (!foundTreeImport) { sb.append("import ").append(Globals.nodesPackageName).append(".*;"); oneNewLine(n, "Z"); } } /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit */ @Override public void visit(final ImportDeclaration n) { // f0 -> "import" n.f0.accept(this); sb.append(" "); // f1 -> [ "static" ] if (n.f1.present()) { n.f1.accept(this); sb.append(" "); } // f2 -> Name(null) n.f2.accept(this); // f3 -> [ "." "*" ] if (n.f3.present()) { n.f3.accept(this); } // f4 -> ";" n.f4.accept(this); } /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit */ @Override public void visit(final ClassOrInterfaceBody n) { // f0 -> "{" n.f0.accept(this); // add return variables declarations final int rvds = retVarDecl.size(); if (rvds > 0) { spc.updateSpc(+1); twoNewLines(n); sb.append(spc.spc); sb.append("/*"); oneNewLine(n); sb.append(spc.spc); sb.append(" * JTB generated return variables declarations"); oneNewLine(n); sb.append(spc.spc); sb.append(" */"); twoNewLines(n); sb.append(spc.spc); for (int i = 0; i < rvds; i++) { // comment sb.append(retVarDecl.get(i)); oneNewLine(n, "b"); sb.append(spc.spc); // declaration sb.append(retVarDecl.get(++i)); if (i < rvds - 2) { twoNewLines(n); sb.append(spc.spc); } } retVarDecl.clear(); spc.updateSpc(-1); } // f1 -> ( ClassOrInterfaceBodyDeclaration(isInterface) )* if (n.f1.present()) { spc.updateSpc(+1); twoNewLines(n); sb.append(spc.spc); for (final Iterator e = n.f1.elements(); e.hasNext();) { e.next().accept(this); oneNewLine(n, "c"); if (e.hasNext()) { oneNewLine(n, "d"); sb.append(spc.spc); } } spc.updateSpc(-1); } sb.append(spc.spc); // f2 -> "}" n.f2.accept(this); oneNewLine(n, "e"); } /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit */ @Override public void visit(final Identifier n) { n.f0.accept(this); } /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit */ @Override public void visit(final StringLiteral n) { n.f0.accept(this); } } } jtb-1.4.4/EDU/purdue/jtb/visitor/IVoidArguVisitor.java0000644000175000017500000015304011416555700022401 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; /** * All "VoidArgu" visitors must implement this interface. * @param
The user argument type */ public interface IVoidArguVisitor { /* * Base "VoidArgu" visit methods */ /** * Visits a {@link NodeList} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeList n, final A argu); /** * Visits a {@link NodeListOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeListOptional n, final A argu); /** * Visits a {@link NodeOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeOptional n, final A argu); /** * Visits a {@link NodeSequence} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeSequence n, final A argu); /** * Visits a {@link NodeToken} node, passing it an argument. * * @param n the node to visit * @param argu the user argument */ public void visit(final NodeToken n, final A argu); /* * User grammar generated visit methods */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final AFancyProduction n, final A argu); /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCCInput n, final A argu); /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCCOptions n, final A argu); /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final OptionBinding n, final A argu); /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Production n, final A argu); /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaCodeProduction n, final A argu); /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BNFProduction n, final A argu); /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final AccessModifier n, final A argu); /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegularExprProduction n, final A argu); /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final TokenManagerDecls n, final A argu); /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegExprKind n, final A argu); /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegExprSpec n, final A argu); /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionChoices n, final A argu); /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final Expansion n, final A argu); /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final LocalLookahead n, final A argu); /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionUnit n, final A argu); /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExpansionUnitInTCF n, final A argu); /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RegularExpression n, final A argu); /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpressionChoices n, final A argu); /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpression n, final A argu); /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @param argu the user argument */ public void visit(final ComplexRegularExpressionUnit n, final A argu); /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @param argu the user argument */ public void visit(final CharacterList n, final A argu); /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final CharacterDescriptor n, final A argu); /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument */ public void visit(final Identifier n, final A argu); /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @param argu the user argument */ public void visit(final JavaIdentifier n, final A argu); /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final CompilationUnit n, final A argu); /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final PackageDeclaration n, final A argu); /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ImportDeclaration n, final A argu); /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final Modifiers n, final A argu); /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeDeclaration n, final A argu); /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceDeclaration n, final A argu); /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExtendsList n, final A argu); /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ImplementsList n, final A argu); /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumDeclaration n, final A argu); /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumBody n, final A argu); /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final EnumConstant n, final A argu); /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeParameters n, final A argu); /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeParameter n, final A argu); /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeBound n, final A argu); /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceBody n, final A argu); /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceBodyDeclaration n, final A argu); /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final FieldDeclaration n, final A argu); /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableDeclarator n, final A argu); /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableDeclaratorId n, final A argu); /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final VariableInitializer n, final A argu); /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArrayInitializer n, final A argu); /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @param argu the user argument */ public void visit(final MethodDeclaration n, final A argu); /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MethodDeclarator n, final A argu); /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final FormalParameters n, final A argu); /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @param argu the user argument */ public void visit(final FormalParameter n, final A argu); /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConstructorDeclaration n, final A argu); /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExplicitConstructorInvocation n, final A argu); /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Initializer n, final A argu); /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Type n, final A argu); /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ReferenceType n, final A argu); /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ClassOrInterfaceType n, final A argu); /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeArguments n, final A argu); /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TypeArgument n, final A argu); /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @param argu the user argument */ public void visit(final WildcardBounds n, final A argu); /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimitiveType n, final A argu); /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final ResultType n, final A argu); /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final Name n, final A argu); /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final NameList n, final A argu); /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final Expression n, final A argu); /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @param argu the user argument */ public void visit(final AssignmentOperator n, final A argu); /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalExpression n, final A argu); /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalOrExpression n, final A argu); /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ConditionalAndExpression n, final A argu); /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final InclusiveOrExpression n, final A argu); /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ExclusiveOrExpression n, final A argu); /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final AndExpression n, final A argu); /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final EqualityExpression n, final A argu); /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final InstanceOfExpression n, final A argu); /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final RelationalExpression n, final A argu); /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ShiftExpression n, final A argu); /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final AdditiveExpression n, final A argu); /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MultiplicativeExpression n, final A argu); /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument */ public void visit(final UnaryExpression n, final A argu); /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PreIncrementExpression n, final A argu); /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PreDecrementExpression n, final A argu); /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final UnaryExpressionNotPlusMinus n, final A argu); /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @param argu the user argument */ public void visit(final CastLookahead n, final A argu); /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final PostfixExpression n, final A argu); /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument */ public void visit(final CastExpression n, final A argu); /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimaryExpression n, final A argu); /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberSelector n, final A argu); /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimaryPrefix n, final A argu); /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @param argu the user argument */ public void visit(final PrimarySuffix n, final A argu); /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Literal n, final A argu); /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @param argu the user argument */ public void visit(final IntegerLiteral n, final A argu); /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BooleanLiteral n, final A argu); /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @param argu the user argument */ public void visit(final StringLiteral n, final A argu); /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @param argu the user argument */ public void visit(final NullLiteral n, final A argu); /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final Arguments n, final A argu); /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArgumentList n, final A argu); /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @param argu the user argument */ public void visit(final AllocationExpression n, final A argu); /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ArrayDimsAndInits n, final A argu); /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Statement n, final A argu); /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AssertStatement n, final A argu); /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final LabeledStatement n, final A argu); /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final Block n, final A argu); /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @param argu the user argument */ public void visit(final BlockStatement n, final A argu); /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final LocalVariableDeclaration n, final A argu); /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final EmptyStatement n, final A argu); /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final StatementExpression n, final A argu); /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SwitchStatement n, final A argu); /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SwitchLabel n, final A argu); /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final IfStatement n, final A argu); /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final WhileStatement n, final A argu); /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final DoStatement n, final A argu); /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForStatement n, final A argu); /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForInit n, final A argu); /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final StatementExpressionList n, final A argu); /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @param argu the user argument */ public void visit(final ForUpdate n, final A argu); /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final BreakStatement n, final A argu); /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ContinueStatement n, final A argu); /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ReturnStatement n, final A argu); /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final ThrowStatement n, final A argu); /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @param argu the user argument */ public void visit(final SynchronizedStatement n, final A argu); /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument */ public void visit(final TryStatement n, final A argu); /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RUNSIGNEDSHIFT n, final A argu); /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @param argu the user argument */ public void visit(final RSIGNEDSHIFT n, final A argu); /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @param argu the user argument */ public void visit(final Annotation n, final A argu); /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final NormalAnnotation n, final A argu); /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MarkerAnnotation n, final A argu); /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument */ public void visit(final SingleMemberAnnotation n, final A argu); /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValuePairs n, final A argu); /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValuePair n, final A argu); /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValue n, final A argu); /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final MemberValueArrayInitializer n, final A argu); /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeDeclaration n, final A argu); /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeBody n, final A argu); /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @param argu the user argument */ public void visit(final AnnotationTypeMemberDeclaration n, final A argu); /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @param argu the user argument */ public void visit(final DefaultValue n, final A argu); } jtb-1.4.4/EDU/purdue/jtb/visitor/IRetArguVisitor.java0000644000175000017500000016557311416555700022250 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.visitor; import EDU.purdue.jtb.syntaxtree.*; /** * All "RetArgu" visitors must implement this interface. * @param The user return information type * @param
The user argument type */ public interface IRetArguVisitor { /* * Base "RetArgu" visit methods */ /** * Visits a {@link NodeList} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeList n, final A argu); /** * Visits a {@link NodeListOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeListOptional n, final A argu); /** * Visits a {@link NodeOptional} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeOptional n, final A argu); /** * Visits a {@link NodeSequence} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeSequence n, final A argu); /** * Visits a {@link NodeToken} node, passing it an argument. * * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NodeToken n, final A argu); /* * User grammar generated visit methods */ /** * Visits a {@link AFancyProduction} node, whose children are the following : *

* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AFancyProduction n, final A argu); /** * Visits a {@link JavaCCInput} node, whose children are the following : *

* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCCInput n, final A argu); /** * Visits a {@link JavaCCOptions} node, whose children are the following : *

* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCCOptions n, final A argu); /** * Visits a {@link OptionBinding} node, whose children are the following : *

* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final OptionBinding n, final A argu); /** * Visits a {@link Production} node, whose children are the following : *

* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Production n, final A argu); /** * Visits a {@link JavaCodeProduction} node, whose children are the following : *

* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaCodeProduction n, final A argu); /** * Visits a {@link BNFProduction} node, whose children are the following : *

* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BNFProduction n, final A argu); /** * Visits a {@link AccessModifier} node, whose children are the following : *

* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AccessModifier n, final A argu); /** * Visits a {@link RegularExprProduction} node, whose children are the following : *

* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegularExprProduction n, final A argu); /** * Visits a {@link TokenManagerDecls} node, whose children are the following : *

* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TokenManagerDecls n, final A argu); /** * Visits a {@link RegExprKind} node, whose children are the following : *

* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegExprKind n, final A argu); /** * Visits a {@link RegExprSpec} node, whose children are the following : *

* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegExprSpec n, final A argu); /** * Visits a {@link ExpansionChoices} node, whose children are the following : *

* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionChoices n, final A argu); /** * Visits a {@link Expansion} node, whose children are the following : *

* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Expansion n, final A argu); /** * Visits a {@link LocalLookahead} node, whose children are the following : *

* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LocalLookahead n, final A argu); /** * Visits a {@link ExpansionUnit} node, whose children are the following : *

* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionUnit n, final A argu); /** * Visits a {@link ExpansionUnitInTCF} node, whose children are the following : *

* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExpansionUnitInTCF n, final A argu); /** * Visits a {@link RegularExpression} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RegularExpression n, final A argu); /** * Visits a {@link ComplexRegularExpressionChoices} node, whose children are the following : *

* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpressionChoices n, final A argu); /** * Visits a {@link ComplexRegularExpression} node, whose children are the following : *

* f0 -> ( ComplexRegularExpressionUnit() )+
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpression n, final A argu); /** * Visits a {@link ComplexRegularExpressionUnit} node, whose children are the following : *

* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ComplexRegularExpressionUnit n, final A argu); /** * Visits a {@link CharacterList} node, whose children are the following : *

* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CharacterList n, final A argu); /** * Visits a {@link CharacterDescriptor} node, whose children are the following : *

* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CharacterDescriptor n, final A argu); /** * Visits a {@link Identifier} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Identifier n, final A argu); /** * Visits a {@link JavaIdentifier} node, whose children are the following : *

* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final JavaIdentifier n, final A argu); /** * Visits a {@link CompilationUnit} node, whose children are the following : *

* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CompilationUnit n, final A argu); /** * Visits a {@link PackageDeclaration} node, whose children are the following : *

* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PackageDeclaration n, final A argu); /** * Visits a {@link ImportDeclaration} node, whose children are the following : *

* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ImportDeclaration n, final A argu); /** * Visits a {@link Modifiers} node, whose children are the following : *

* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Modifiers n, final A argu); /** * Visits a {@link TypeDeclaration} node, whose children are the following : *

* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeDeclaration n, final A argu); /** * Visits a {@link ClassOrInterfaceDeclaration} node, whose children are the following : *

* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceDeclaration n, final A argu); /** * Visits a {@link ExtendsList} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExtendsList n, final A argu); /** * Visits a {@link ImplementsList} node, whose children are the following : *

* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ImplementsList n, final A argu); /** * Visits a {@link EnumDeclaration} node, whose children are the following : *

* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumDeclaration n, final A argu); /** * Visits a {@link EnumBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumBody n, final A argu); /** * Visits a {@link EnumConstant} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EnumConstant n, final A argu); /** * Visits a {@link TypeParameters} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeParameters n, final A argu); /** * Visits a {@link TypeParameter} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeParameter n, final A argu); /** * Visits a {@link TypeBound} node, whose children are the following : *

* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeBound n, final A argu); /** * Visits a {@link ClassOrInterfaceBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceBody n, final A argu); /** * Visits a {@link ClassOrInterfaceBodyDeclaration} node, whose children are the following : *

* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceBodyDeclaration n, final A argu); /** * Visits a {@link FieldDeclaration} node, whose children are the following : *

* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FieldDeclaration n, final A argu); /** * Visits a {@link VariableDeclarator} node, whose children are the following : *

* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableDeclarator n, final A argu); /** * Visits a {@link VariableDeclaratorId} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableDeclaratorId n, final A argu); /** * Visits a {@link VariableInitializer} node, whose children are the following : *

* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final VariableInitializer n, final A argu); /** * Visits a {@link ArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArrayInitializer n, final A argu); /** * Visits a {@link MethodDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MethodDeclaration n, final A argu); /** * Visits a {@link MethodDeclarator} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MethodDeclarator n, final A argu); /** * Visits a {@link FormalParameters} node, whose children are the following : *

* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FormalParameters n, final A argu); /** * Visits a {@link FormalParameter} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final FormalParameter n, final A argu); /** * Visits a {@link ConstructorDeclaration} node, whose children are the following : *

* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConstructorDeclaration n, final A argu); /** * Visits a {@link ExplicitConstructorInvocation} node, whose children are the following : *

* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExplicitConstructorInvocation n, final A argu); /** * Visits a {@link Initializer} node, whose children are the following : *

* f0 -> [ "static" ]
* f1 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Initializer n, final A argu); /** * Visits a {@link Type} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Type n, final A argu); /** * Visits a {@link ReferenceType} node, whose children are the following : *

* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ReferenceType n, final A argu); /** * Visits a {@link ClassOrInterfaceType} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ClassOrInterfaceType n, final A argu); /** * Visits a {@link TypeArguments} node, whose children are the following : *

* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeArguments n, final A argu); /** * Visits a {@link TypeArgument} node, whose children are the following : *

* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TypeArgument n, final A argu); /** * Visits a {@link WildcardBounds} node, whose children are the following : *

* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final WildcardBounds n, final A argu); /** * Visits a {@link PrimitiveType} node, whose children are the following : *

* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimitiveType n, final A argu); /** * Visits a {@link ResultType} node, whose children are the following : *

* f0 -> ( %0 "void"
* .. .. | %1 Type() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ResultType n, final A argu); /** * Visits a {@link Name} node, whose children are the following : *

* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Name n, final A argu); /** * Visits a {@link NameList} node, whose children are the following : *

* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NameList n, final A argu); /** * Visits a {@link Expression} node, whose children are the following : *

* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Expression n, final A argu); /** * Visits a {@link AssignmentOperator} node, whose children are the following : *

* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AssignmentOperator n, final A argu); /** * Visits a {@link ConditionalExpression} node, whose children are the following : *

* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalExpression n, final A argu); /** * Visits a {@link ConditionalOrExpression} node, whose children are the following : *

* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalOrExpression n, final A argu); /** * Visits a {@link ConditionalAndExpression} node, whose children are the following : *

* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ConditionalAndExpression n, final A argu); /** * Visits a {@link InclusiveOrExpression} node, whose children are the following : *

* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final InclusiveOrExpression n, final A argu); /** * Visits a {@link ExclusiveOrExpression} node, whose children are the following : *

* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ExclusiveOrExpression n, final A argu); /** * Visits a {@link AndExpression} node, whose children are the following : *

* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AndExpression n, final A argu); /** * Visits a {@link EqualityExpression} node, whose children are the following : *

* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EqualityExpression n, final A argu); /** * Visits a {@link InstanceOfExpression} node, whose children are the following : *

* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final InstanceOfExpression n, final A argu); /** * Visits a {@link RelationalExpression} node, whose children are the following : *

* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RelationalExpression n, final A argu); /** * Visits a {@link ShiftExpression} node, whose children are the following : *

* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ShiftExpression n, final A argu); /** * Visits a {@link AdditiveExpression} node, whose children are the following : *

* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AdditiveExpression n, final A argu); /** * Visits a {@link MultiplicativeExpression} node, whose children are the following : *

* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MultiplicativeExpression n, final A argu); /** * Visits a {@link UnaryExpression} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final UnaryExpression n, final A argu); /** * Visits a {@link PreIncrementExpression} node, whose children are the following : *

* f0 -> "++"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PreIncrementExpression n, final A argu); /** * Visits a {@link PreDecrementExpression} node, whose children are the following : *

* f0 -> "--"
* f1 -> PrimaryExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PreDecrementExpression n, final A argu); /** * Visits a {@link UnaryExpressionNotPlusMinus} node, whose children are the following : *

* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final UnaryExpressionNotPlusMinus n, final A argu); /** * Visits a {@link CastLookahead} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CastLookahead n, final A argu); /** * Visits a {@link PostfixExpression} node, whose children are the following : *

* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PostfixExpression n, final A argu); /** * Visits a {@link CastExpression} node, whose children are the following : *

* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final CastExpression n, final A argu); /** * Visits a {@link PrimaryExpression} node, whose children are the following : *

* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimaryExpression n, final A argu); /** * Visits a {@link MemberSelector} node, whose children are the following : *

* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberSelector n, final A argu); /** * Visits a {@link PrimaryPrefix} node, whose children are the following : *

* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimaryPrefix n, final A argu); /** * Visits a {@link PrimarySuffix} node, whose children are the following : *

* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final PrimarySuffix n, final A argu); /** * Visits a {@link Literal} node, whose children are the following : *

* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Literal n, final A argu); /** * Visits a {@link IntegerLiteral} node, whose children are the following : *

* f0 -> < INTEGER_LITERAL >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final IntegerLiteral n, final A argu); /** * Visits a {@link BooleanLiteral} node, whose children are the following : *

* f0 -> . %0 "true"
* .. .. | %1 "false"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BooleanLiteral n, final A argu); /** * Visits a {@link StringLiteral} node, whose children are the following : *

* f0 -> < STRING_LITERAL >
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StringLiteral n, final A argu); /** * Visits a {@link NullLiteral} node, whose children are the following : *

* f0 -> "null"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NullLiteral n, final A argu); /** * Visits a {@link Arguments} node, whose children are the following : *

* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Arguments n, final A argu); /** * Visits a {@link ArgumentList} node, whose children are the following : *

* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArgumentList n, final A argu); /** * Visits a {@link AllocationExpression} node, whose children are the following : *

* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AllocationExpression n, final A argu); /** * Visits a {@link ArrayDimsAndInits} node, whose children are the following : *

* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ArrayDimsAndInits n, final A argu); /** * Visits a {@link Statement} node, whose children are the following : *

* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Statement n, final A argu); /** * Visits a {@link AssertStatement} node, whose children are the following : *

* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AssertStatement n, final A argu); /** * Visits a {@link LabeledStatement} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LabeledStatement n, final A argu); /** * Visits a {@link Block} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Block n, final A argu); /** * Visits a {@link BlockStatement} node, whose children are the following : *

* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BlockStatement n, final A argu); /** * Visits a {@link LocalVariableDeclaration} node, whose children are the following : *

* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final LocalVariableDeclaration n, final A argu); /** * Visits a {@link EmptyStatement} node, whose children are the following : *

* f0 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final EmptyStatement n, final A argu); /** * Visits a {@link StatementExpression} node, whose children are the following : *

* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StatementExpression n, final A argu); /** * Visits a {@link SwitchStatement} node, whose children are the following : *

* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SwitchStatement n, final A argu); /** * Visits a {@link SwitchLabel} node, whose children are the following : *

* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SwitchLabel n, final A argu); /** * Visits a {@link IfStatement} node, whose children are the following : *

* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final IfStatement n, final A argu); /** * Visits a {@link WhileStatement} node, whose children are the following : *

* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final WhileStatement n, final A argu); /** * Visits a {@link DoStatement} node, whose children are the following : *

* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final DoStatement n, final A argu); /** * Visits a {@link ForStatement} node, whose children are the following : *

* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForStatement n, final A argu); /** * Visits a {@link ForInit} node, whose children are the following : *

* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForInit n, final A argu); /** * Visits a {@link StatementExpressionList} node, whose children are the following : *

* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final StatementExpressionList n, final A argu); /** * Visits a {@link ForUpdate} node, whose children are the following : *

* f0 -> StatementExpressionList()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ForUpdate n, final A argu); /** * Visits a {@link BreakStatement} node, whose children are the following : *

* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final BreakStatement n, final A argu); /** * Visits a {@link ContinueStatement} node, whose children are the following : *

* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ContinueStatement n, final A argu); /** * Visits a {@link ReturnStatement} node, whose children are the following : *

* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ReturnStatement n, final A argu); /** * Visits a {@link ThrowStatement} node, whose children are the following : *

* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final ThrowStatement n, final A argu); /** * Visits a {@link SynchronizedStatement} node, whose children are the following : *

* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SynchronizedStatement n, final A argu); /** * Visits a {@link TryStatement} node, whose children are the following : *

* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final TryStatement n, final A argu); /** * Visits a {@link RUNSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RUNSIGNEDSHIFT n, final A argu); /** * Visits a {@link RSIGNEDSHIFT} node, whose children are the following : *

* f0 -> ">"
* f1 -> ">"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final RSIGNEDSHIFT n, final A argu); /** * Visits a {@link Annotation} node, whose children are the following : *

* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final Annotation n, final A argu); /** * Visits a {@link NormalAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final NormalAnnotation n, final A argu); /** * Visits a {@link MarkerAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MarkerAnnotation n, final A argu); /** * Visits a {@link SingleMemberAnnotation} node, whose children are the following : *

* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final SingleMemberAnnotation n, final A argu); /** * Visits a {@link MemberValuePairs} node, whose children are the following : *

* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValuePairs n, final A argu); /** * Visits a {@link MemberValuePair} node, whose children are the following : *

* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValuePair n, final A argu); /** * Visits a {@link MemberValue} node, whose children are the following : *

* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValue n, final A argu); /** * Visits a {@link MemberValueArrayInitializer} node, whose children are the following : *

* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final MemberValueArrayInitializer n, final A argu); /** * Visits a {@link AnnotationTypeDeclaration} node, whose children are the following : *

* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeDeclaration n, final A argu); /** * Visits a {@link AnnotationTypeBody} node, whose children are the following : *

* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeBody n, final A argu); /** * Visits a {@link AnnotationTypeMemberDeclaration} node, whose children are the following : *

* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final AnnotationTypeMemberDeclaration n, final A argu); /** * Visits a {@link DefaultValue} node, whose children are the following : *

* f0 -> "default"
* f1 -> MemberValue()
* * @param n the node to visit * @param argu the user argument * @return the user return information */ public R visit(final DefaultValue n, final A argu); } jtb-1.4.4/EDU/purdue/jtb/parser/0000755000175000017500000000000011420623645016116 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/parser/JavaCCParserInternals.java0000644000175000017500000003252611360636752023123 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Hashtable; import java.util.List; /** * Utilities. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public abstract class JavaCCParserInternals extends JavaCCGlobals { static protected void initialize() { final Integer i = new Integer(0); lexstate_S2I.put("DEFAULT", i); lexstate_I2S.put(i, "DEFAULT"); simple_tokens_table.put("DEFAULT", new Hashtable>()); } static protected void addcuname(final String id) { cu_name = id; } static protected void compare(final Token t, final String id1, final String id2) { if (!id2.equals(id1)) { JavaCCErrors.parse_error(t, "Name " + id2 + " must be the same as that used at PARSER_BEGIN (" + id1 + ")"); } } static private List add_cu_token_here = cu_to_insertion_point_1; static private Token first_cu_token; static private boolean insertionpoint1set = false; static private boolean insertionpoint2set = false; static protected void setinsertionpoint(final Token t, final int no) { do { add_cu_token_here.add(first_cu_token); first_cu_token = first_cu_token.next; } while (first_cu_token != t); if (no == 1) { if (insertionpoint1set) { JavaCCErrors.parse_error(t, "Multiple declaration of parser class."); } else { insertionpoint1set = true; add_cu_token_here = cu_to_insertion_point_2; } } else { add_cu_token_here = cu_from_insertion_point_2; insertionpoint2set = true; } first_cu_token = t; } static protected void insertionpointerrors(final Token t) { while (first_cu_token != t) { add_cu_token_here.add(first_cu_token); first_cu_token = first_cu_token.next; } if (!insertionpoint1set || !insertionpoint2set) { JavaCCErrors.parse_error(t, "Parser class has not been defined between PARSER_BEGIN and PARSER_END."); } } static protected void set_initial_cu_token(final Token t) { first_cu_token = t; } static protected void addproduction(final NormalProduction p) { bnfproductions.add(p); } static protected void production_addexpansion(final BNFProduction_ p, final Expansion_ e) { e.parent = p; p.setExpansion(e); } static private int nextFreeLexState = 1; static protected void addregexpr(final TokenProduction p) { Integer ii; rexprlist.add(p); if (Options.getUserTokenManager()) { if (p.lexStates == null || p.lexStates.length != 1 || !p.lexStates[0].equals("DEFAULT")) { JavaCCErrors.warning(p, "Ignoring lexical state specifications since option " + "USER_TOKEN_MANAGER has been set to true."); } } if (p.lexStates == null) { return; } for (int i = 0; i < p.lexStates.length; i++) { for (int j = 0; j < i; j++) { if (p.lexStates[i].equals(p.lexStates[j])) { JavaCCErrors.parse_error(p, "Multiple occurrence of \"" + p.lexStates[i] + "\" in lexical state list."); } } if (lexstate_S2I.get(p.lexStates[i]) == null) { ii = new Integer(nextFreeLexState++); lexstate_S2I.put(p.lexStates[i], ii); lexstate_I2S.put(ii, p.lexStates[i]); simple_tokens_table.put(p.lexStates[i], new Hashtable>()); } } } static protected void add_token_manager_decls(final Token t, final List decls) { if (token_mgr_decls != null) { JavaCCErrors.parse_error(t, "Multiple occurrence of \"TOKEN_MGR_DECLS\"."); } else { token_mgr_decls = decls; if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring declarations in \"TOKEN_MGR_DECLS\" since option " + "USER_TOKEN_MANAGER has been set to true."); } } } static protected void add_inline_regexpr(final RegularExpression_ r) { if (!(r instanceof REndOfFile)) { final TokenProduction p = new TokenProduction(); p.isExplicit = false; p.lexStates = new String[] { "DEFAULT" }; p.kind = TokenProduction.TOKEN; final RegExprSpec_ res = new RegExprSpec_(); res.rexp = r; res.rexp.tpContext = p; res.act = new Action(); res.nextState = null; res.nsTok = null; p.respecs.add(res); rexprlist.add(p); } } static protected boolean hexchar(final char ch) { if (ch >= '0' && ch <= '9') return true; if (ch >= 'A' && ch <= 'F') return true; if (ch >= 'a' && ch <= 'f') return true; return false; } static protected int hexval(final char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10; return ch - 'a' + 10; } static protected String remove_escapes_and_quotes(final Token t, final String str) { // ModMMa : performance improvements (String concatenation) // String retval = ""; // int index = 1; // char ch, ch1; // int ordinal; // while (index < str.length()-1) { // if (str.charAt(index) != '\\') { // retval += str.charAt(index); index++; // continue; // } // index++; // ch = str.charAt(index); // if (ch == 'b') { // retval += '\b'; index++; // continue; // } // if (ch == 't') { // retval += '\t'; index++; // continue; // } // if (ch == 'n') { // retval += '\n'; index++; // continue; // } // if (ch == 'f') { // retval += '\f'; index++; // continue; // } // if (ch == 'r') { // retval += '\r'; index++; // continue; // } // if (ch == '"') { // retval += '\"'; index++; // continue; // } // if (ch == '\'') { // retval += '\''; index++; // continue; // } // if (ch == '\\') { // retval += '\\'; index++; // continue; // } // if (ch >= '0' && ch <= '7') { // ordinal = ((int)ch) - ((int)'0'); index++; // ch1 = str.charAt(index); // if (ch1 >= '0' && ch1 <= '7') { // ordinal = ordinal*8 + ((int)ch1) - ((int)'0'); index++; // ch1 = str.charAt(index); // if (ch <= '3' && ch1 >= '0' && ch1 <= '7') { // ordinal = ordinal*8 + ((int)ch1) - ((int)'0'); index++; // } // } // retval += (char)ordinal; // continue; // } // if (ch == 'u') { // index++; ch = str.charAt(index); // if (hexchar(ch)) { // ordinal = hexval(ch); // index++; ch = str.charAt(index); // if (hexchar(ch)) { // ordinal = ordinal*16 + hexval(ch); // index++; ch = str.charAt(index); // if (hexchar(ch)) { // ordinal = ordinal*16 + hexval(ch); // index++; ch = str.charAt(index); // if (hexchar(ch)) { // ordinal = ordinal*16 + hexval(ch); // index++; // continue; // } // } // } // } // JavaCCErrors.parse_error(t, "Encountered non-hex character '" + ch + // "' at position " + index + " of string " + // "- Unicode escape must have 4 hex digits after it."); // return retval; // } // JavaCCErrors.parse_error(t, "Illegal escape sequence '\\" + ch + // "' at position " + index + " of string."); // return retval; // } // return retval; final int strlen = str.length(); final StringBuffer buff = new StringBuffer(strlen); int index = 1; char ch, ch1; int ordinal; while (index < str.length() - 1) { if (str.charAt(index) != '\\') { buff.append(str.charAt(index)); index++; continue; } index++; ch = str.charAt(index); if (ch == 'b') { buff.append('\b'); index++; continue; } if (ch == 't') { buff.append('\t'); index++; continue; } if (ch == 'n') { buff.append('\n'); index++; continue; } if (ch == 'f') { buff.append('\f'); index++; continue; } if (ch == 'r') { buff.append('\r'); index++; continue; } if (ch == '"') { buff.append('\"'); index++; continue; } if (ch == '\'') { buff.append('\''); index++; continue; } if (ch == '\\') { buff.append('\\'); index++; continue; } if (ch >= '0' && ch <= '7') { ordinal = ch - '0'; index++; ch1 = str.charAt(index); if (ch1 >= '0' && ch1 <= '7') { ordinal = ordinal * 8 + ch1 - '0'; index++; ch1 = str.charAt(index); if (ch <= '3' && ch1 >= '0' && ch1 <= '7') { ordinal = ordinal * 8 + ch1 - '0'; index++; } } buff.append((char) ordinal); continue; } if (ch == 'u') { index++; ch = str.charAt(index); if (hexchar(ch)) { ordinal = hexval(ch); index++; ch = str.charAt(index); if (hexchar(ch)) { ordinal = ordinal * 16 + hexval(ch); index++; ch = str.charAt(index); if (hexchar(ch)) { ordinal = ordinal * 16 + hexval(ch); index++; ch = str.charAt(index); if (hexchar(ch)) { ordinal = ordinal * 16 + hexval(ch); index++; continue; } } } } JavaCCErrors.parse_error(t, "Encountered non-hex character '" + ch + "' at position " + index + " of string " + "- Unicode escape must have 4 hex digits after it."); return buff.toString(); } JavaCCErrors.parse_error(t, "Illegal escape sequence '\\" + ch + "' at position " + index + " of string."); return buff.toString(); } return buff.toString(); } static protected char character_descriptor_assign(final Token t, final String s) { if (s.length() != 1) { JavaCCErrors.parse_error(t, "String in character list may contain only one character."); return ' '; } else { return s.charAt(0); } } static protected char character_descriptor_assign(final Token t, final String s, final String left) { if (s.length() != 1) { JavaCCErrors.parse_error(t, "String in character list may contain only one character."); return ' '; } else if ((left.charAt(0)) > (s.charAt(0))) { JavaCCErrors.parse_error(t, "Right end of character range \'" + s + "\' has a lower ordinal value than the left end of character range \'" + left + "\'."); return left.charAt(0); } else { return s.charAt(0); } } static protected void makeTryBlock(final Token tryLoc, final Container result, final Container nestedExp, final List> types, final List ids, final List> catchblks, final List finallyblk) { if (catchblks.size() == 0 && finallyblk == null) { JavaCCErrors.parse_error(tryLoc, "Try block must contain at least one catch or finally block."); return; } final TryBlock tblk = new TryBlock(); tblk.setLine(tryLoc.beginLine); tblk.setColumn(tryLoc.beginColumn); tblk.exp = (Expansion_) (nestedExp.member); tblk.exp.parent = tblk; tblk.exp.ordinal = 0; tblk.types = types; tblk.ids = ids; tblk.catchblks = catchblks; tblk.finallyblk = finallyblk; result.member = tblk; } public static void reInit() { add_cu_token_here = cu_to_insertion_point_1; first_cu_token = null; insertionpoint1set = false; insertionpoint2set = false; nextFreeLexState = 1; } } jtb-1.4.4/EDU/purdue/jtb/parser/TryBlock.java0000644000175000017500000000603311360636752020522 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.List; import java.util.Set; /** * Describes expansions of the form "try {...} ...". * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class TryBlock extends Expansion_ { /** * The expansion contained within the try block. */ public Expansion_ exp; /** * The types of each catch block. Each list entry is itself a * list which in turn contains tokens as entries. */ public List> types; /** * The exception identifiers of each catch block. Each list entry * is a token. */ public List ids; /** * The block part of each catch block. Each list entry is itself a * list which in turn contains tokens as entries. */ public List> catchblks; /** * The block part of the finally block. Each list entry is a token. * If there is no finally block, this is null. */ public List finallyblk; // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker public TryBlock() { expType = EXP_TYPE.TRY_BLOCK; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); sb.append(eol).append(exp.dump(indent + 1, alreadyDumped)); return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/LookaheadCalc.java0000644000175000017500000002651011360636752021445 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class LookaheadCalc extends JavaCCGlobals { static MatchInfo overlap(final List v1, final List v2) { MatchInfo m1, m2, m3; int size; boolean diff; for (int i = 0; i < v1.size(); i++) { m1 = v1.get(i); for (int j = 0; j < v2.size(); j++) { m2 = v2.get(j); size = m1.firstFreeLoc; m3 = m1; if (size > m2.firstFreeLoc) { size = m2.firstFreeLoc; m3 = m2; } if (size == 0) return null; // we wish to ignore empty expansions and the JAVACODE stuff here. diff = false; for (int k = 0; k < size; k++) { if (m1.match[k] != m2.match[k]) { diff = true; break; } } if (!diff) return m3; } } return null; } static boolean javaCodeCheck(final List v) { for (int i = 0; i < v.size(); i++) { if (v.get(i).firstFreeLoc == 0) { return true; } } return false; } static String image(final MatchInfo m) { String ret = ""; for (int i = 0; i < m.firstFreeLoc; i++) { if (m.match[i] == 0) { ret += " "; } else { final RegularExpression_ re = rexps_of_tokens.get(new Integer(m.match[i])); if (re instanceof RStringLiteral) { ret += " \"" + add_escapes(((RStringLiteral) re).image) + "\""; } else if (re.label != null && !re.label.equals("")) { ret += " <" + re.label + ">"; } else { ret += " "; } } } if (m.firstFreeLoc == 0) { return ""; } else { return ret.substring(1); } } @SuppressWarnings("unchecked") public static void choiceCalc(final Choice ch) { final int first = firstChoice(ch); // dbl[i] and dbr[i] are lists of size limited matches for choice i // of ch. dbl ignores matches with semantic lookaheads (when force_la_check // is false), while dbr ignores semantic lookahead. final List[] dbl = new ArrayList[ch.getChoices().size()]; final List[] dbr = new ArrayList[ch.getChoices().size()]; final int[] minLA = new int[ch.getChoices().size() - 1]; final MatchInfo[] overlapInfo = new MatchInfo[ch.getChoices().size() - 1]; final int[] other = new int[ch.getChoices().size() - 1]; MatchInfo m; List v; boolean overlapDetected; for (int la = 1; la <= Options.getChoiceAmbiguityCheck(); la++) { MatchInfo.laLimit = la; LookaheadWalk.considerSemanticLA = !Options.getForceLaCheck(); for (int i = first; i < ch.getChoices().size() - 1; i++) { LookaheadWalk.sizeLimitedMatches = new ArrayList(); m = new MatchInfo(); m.firstFreeLoc = 0; v = new ArrayList(); v.add(m); LookaheadWalk.genFirstSet(v, ch.getChoices().get(i)); dbl[i] = LookaheadWalk.sizeLimitedMatches; } LookaheadWalk.considerSemanticLA = false; for (int i = first + 1; i < ch.getChoices().size(); i++) { LookaheadWalk.sizeLimitedMatches = new ArrayList(); m = new MatchInfo(); m.firstFreeLoc = 0; v = new ArrayList(); v.add(m); LookaheadWalk.genFirstSet(v, ch.getChoices().get(i)); dbr[i] = LookaheadWalk.sizeLimitedMatches; } if (la == 1) { for (int i = first; i < ch.getChoices().size() - 1; i++) { final Expansion_ exp = ch.getChoices().get(i); if (Semanticize.emptyExpansionExists(exp)) { JavaCCErrors .warning( exp, "This choice can expand to the empty token sequence " + "and will therefore always be taken in favor of the choices appearing later."); break; } else if (javaCodeCheck(dbl[i])) { JavaCCErrors.warning(exp, "JAVACODE non-terminal will force this choice to be taken " + "in favor of the choices appearing later."); break; } } } overlapDetected = false; for (int i = first; i < ch.getChoices().size() - 1; i++) { for (int j = i + 1; j < ch.getChoices().size(); j++) { if ((m = overlap(dbl[i], dbr[j])) != null) { minLA[i] = la + 1; overlapInfo[i] = m; other[i] = j; overlapDetected = true; break; } } } if (!overlapDetected) { break; } } for (int i = first; i < ch.getChoices().size() - 1; i++) { if (explicitLA(ch.getChoices().get(i)) && !Options.getForceLaCheck()) { continue; } if (minLA[i] > Options.getChoiceAmbiguityCheck()) { JavaCCErrors.warning("Choice conflict involving two expansions at"); System.err.print(" line " + (ch.getChoices().get(i)).getLine()); System.err.print(", column " + (ch.getChoices().get(i)).getColumn()); System.err.print(" and line " + (ch.getChoices().get(other[i])).getLine()); System.err.print(", column " + (ch.getChoices().get(other[i])).getColumn()); System.err.println(" respectively."); System.err.println(" A common prefix is: " + image(overlapInfo[i])); System.err.println(" Consider using a lookahead of " + minLA[i] + " or more for earlier expansion."); } else if (minLA[i] > 1) { JavaCCErrors.warning("Choice conflict involving two expansions at"); System.err.print(" line " + (ch.getChoices().get(i)).getLine()); System.err.print(", column " + (ch.getChoices().get(i)).getColumn()); System.err.print(" and line " + (ch.getChoices().get(other[i])).getLine()); System.err.print(", column " + (ch.getChoices().get(other[i])).getColumn()); System.err.println(" respectively."); System.err.println(" A common prefix is: " + image(overlapInfo[i])); System.err.println(" Consider using a lookahead of " + minLA[i] + " for earlier expansion."); } } } static boolean explicitLA(final Expansion_ exp) { if (!(exp instanceof Sequence)) { return false; } final Sequence seq = (Sequence) exp; final Object obj = seq.units.get(0); if (!(obj instanceof Lookahead)) { return false; } final Lookahead la = (Lookahead) obj; return la.isExplicit(); } static int firstChoice(final Choice ch) { if (Options.getForceLaCheck()) { return 0; } for (int i = 0; i < ch.getChoices().size(); i++) { if (!explicitLA(ch.getChoices().get(i))) { return i; } } return ch.getChoices().size(); } private static String image(final Expansion_ exp) { if (exp instanceof OneOrMore) { return "(...)+"; } else if (exp instanceof ZeroOrMore) { return "(...)*"; } else /* if (exp instanceof ZeroOrOne) */{ return "[...]"; } } public static void ebnfCalc(final Expansion_ exp, final Expansion_ nested) { // exp is one of OneOrMore, ZeroOrMore, ZeroOrOne MatchInfo m, m1 = null; List v, first, follow; int la; for (la = 1; la <= Options.getOtherAmbiguityCheck(); la++) { MatchInfo.laLimit = la; LookaheadWalk.sizeLimitedMatches = new ArrayList(); m = new MatchInfo(); m.firstFreeLoc = 0; v = new ArrayList(); v.add(m); LookaheadWalk.considerSemanticLA = !Options.getForceLaCheck(); LookaheadWalk.genFirstSet(v, nested); first = LookaheadWalk.sizeLimitedMatches; LookaheadWalk.sizeLimitedMatches = new ArrayList(); LookaheadWalk.considerSemanticLA = false; LookaheadWalk.genFollowSet(v, exp, Expansion_.nextGenerationIndex++); follow = LookaheadWalk.sizeLimitedMatches; if (la == 1) { if (javaCodeCheck(first)) { JavaCCErrors .warning( nested, "JAVACODE non-terminal within " + image(exp) + " construct will force this construct to be entered in favor of " + "expansions occurring after construct."); } } if ((m = overlap(first, follow)) == null) { break; } m1 = m; } if (la > Options.getOtherAmbiguityCheck()) { JavaCCErrors.warning("Choice conflict in " + image(exp) + " construct " + "at line " + exp.getLine() + ", column " + exp.getColumn() + "."); System.err .println(" Expansion_ nested within construct and expansion following construct"); System.err.println(" have common prefixes, one of which is: " + image(m1)); System.err.println(" Consider using a lookahead of " + la + " or more for nested expansion."); } else if (la > 1) { JavaCCErrors.warning("Choice conflict in " + image(exp) + " construct " + "at line " + exp.getLine() + ", column " + exp.getColumn() + "."); System.err .println(" Expansion_ nested within construct and expansion following construct"); System.err.println(" have common prefixes, one of which is: " + image(m1)); System.err.println(" Consider using a lookahead of " + la + " for nested expansion."); } } } jtb-1.4.4/EDU/purdue/jtb/parser/ROneOrMore.java0000644000175000017500000000530211360636752020756 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes one-or-more regular expressions (). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class ROneOrMore extends RegularExpression_ { /** * The regular expression which is repeated one or more times. */ public RegularExpression_ regexpr; @Override public Nfa GenerateNfa(final boolean ignoreCase) { final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; final Nfa temp = regexpr.GenerateNfa(ignoreCase); startState.AddMove(temp.start); temp.end.AddMove(temp.start); temp.end.AddMove(finalState); return retVal; } public ROneOrMore() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.R_ONE_OR_MORE; } public ROneOrMore(final Token t, final RegularExpression_ re) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(t.beginLine); this.setColumn(t.beginColumn); this.regexpr = re; } } jtb-1.4.4/EDU/purdue/jtb/parser/OtherFilesGen.java0000644000175000017500000001547111360636752021475 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Generates the Constants file. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class OtherFilesGen extends JavaCCGlobals implements JavaCCParserConstants { public static boolean keepLineCol; // ModMMa : modified for Token.template with GTToken //static public void start() throws MetaParseException { static public void start(final String pn) throws MetaParseException { Token t = null; keepLineCol = Options.getKeepLineColumn(); if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); JavaFiles.gen_TokenMgrError(); JavaFiles.gen_ParseException(); // ModMMa : modified for Token.template with GTToken // JavaFiles.gen_Token(); JavaFiles.gen_Token(pn); if (Options.getUserTokenManager()) { JavaFiles.gen_TokenManager(); } else if (Options.getUserCharStream()) { JavaFiles.gen_CharStream(); } else { if (Options.getJavaUnicodeEscape()) { JavaFiles.gen_JavaCharStream(); } else { JavaFiles.gen_SimpleCharStream(); } } try { ostr = new PrintWriter( new BufferedWriter( new FileWriter( new File( Options .getOutputDirectory(), cu_name + "Constants.java")), // ModMMa : performance improvements (use big BufferedWriter) // 8192 4 * 8192)); } catch (final java.io.IOException e) { JavaCCErrors.semantic_error("Could not open file " + cu_name + "Constants.java for writing."); throw new Error(); } final List tn = new ArrayList(toolNames); tn.add(toolName); ostr.println("/* " + getIdString(tn, cu_name + "Constants.java") + " */"); if (cu_to_insertion_point_1.size() != 0 && cu_to_insertion_point_1.get(0).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if (cu_to_insertion_point_1.get(i).kind == SEMICOLON) { printTokenSetup((cu_to_insertion_point_1.get(0))); for (int j = 0; j <= i; j++) { t = (cu_to_insertion_point_1.get(j)); printToken(t, ostr); } printTrailingComments(t, ostr); ostr.println(""); ostr.println(""); break; } } } ostr.println(""); ostr.println("/**"); ostr.println(" * Token literal values and constants."); ostr.println(" * Generated by org.javacc.parser.OtherFilesGen#start()"); ostr.println(" */"); if (Options.getSupportClassVisibilityPublic()) { ostr.print("public "); } ostr.println("interface " + cu_name + "Constants {"); ostr.println(""); RegularExpression_ re; ostr.println(" /** End of File. */"); ostr.println(" int EOF = 0;"); for (final Iterator it = ordered_named_tokens.iterator(); it.hasNext();) { re = it.next(); ostr.println(" /** RegularExpression_ Id. */"); ostr.println(" int " + re.label + " = " + re.ordinal + ";"); } ostr.println(""); if (!Options.getUserTokenManager() && Options.getBuildTokenManager()) { for (int i = 0; i < LexGen.lexStateName.length; i++) { ostr.println(" /** Lexical state. */"); ostr.println(" int " + LexGen.lexStateName[i] + " = " + i + ";"); } ostr.println(""); } ostr.println(" /** Literal token values. */"); ostr.println(" String[] tokenImage = {"); ostr.println(" \"\","); for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it2 = respecs.iterator(); it2.hasNext();) { final RegExprSpec_ res = (it2.next()); re = res.rexp; if (re instanceof RStringLiteral) { ostr.println(" \"\\\"" + add_escapes(add_escapes(((RStringLiteral) re).image)) + "\\\"\","); } else if (!re.label.equals("")) { ostr.println(" \"<" + re.label + ">\","); } else { if (re.tpContext.kind == TokenProduction.TOKEN) { JavaCCErrors .warning(re, "Consider giving this non-string token a label for better error reporting."); } ostr.println(" \"\","); } } } ostr.println(" };"); ostr.println(""); ostr.println("}"); ostr.close(); } static private java.io.PrintWriter ostr; public static void reInit() { ostr = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/RChoice.java0000644000175000017500000001253611360636752020312 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes regular expressions which are choices from * from among included regular expressions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RChoice extends RegularExpression_ { /** * The list of choices of this regular expression. Each * list component will narrow to RegularExpression_. */ private List choices = new ArrayList(); // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker public RChoice() { expType = EXP_TYPE.R_CHOICE; } /** * @param choices the choices to set */ public final void setChoices(final List ch) { choices = ch; } /** * @return the choices */ public final List getChoices() { return choices; } @Override public Nfa GenerateNfa(final boolean ignoreCase) { CompressCharLists(); if (getChoices().size() == 1) return getChoices().get(0).GenerateNfa(ignoreCase); final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; for (int i = 0; i < getChoices().size(); i++) { Nfa temp; final RegularExpression_ curRE = getChoices().get(i); temp = curRE.GenerateNfa(ignoreCase); startState.AddMove(temp.start); temp.end.AddMove(finalState); } return retVal; } void CompressCharLists() { CompressChoices(); // Unroll nested choices RegularExpression_ curRE; RCharacterList curCharList = null; for (int i = 0; i < getChoices().size(); i++) { curRE = getChoices().get(i); while (curRE instanceof RJustName) curRE = ((RJustName) curRE).regexpr; if (curRE instanceof RStringLiteral && ((RStringLiteral) curRE).image.length() == 1) getChoices().set(i, curRE = new RCharacterList(((RStringLiteral) curRE).image.charAt(0))); if (curRE instanceof RCharacterList) { if (((RCharacterList) curRE).negated_list) ((RCharacterList) curRE).RemoveNegation(); final List tmp = ((RCharacterList) curRE).descriptors; if (curCharList == null) getChoices().set(i, curRE = curCharList = new RCharacterList()); else getChoices().remove(i--); for (int j = tmp.size(); j-- > 0;) curCharList.descriptors.add(tmp.get(j)); } } } void CompressChoices() { RegularExpression_ curRE; for (int i = 0; i < getChoices().size(); i++) { curRE = getChoices().get(i); while (curRE instanceof RJustName) curRE = ((RJustName) curRE).regexpr; if (curRE instanceof RChoice) { getChoices().remove(i--); for (int j = ((RChoice) curRE).getChoices().size(); j-- > 0;) getChoices().add(((RChoice) curRE).getChoices().get(j)); } } } public void CheckUnmatchability() { RegularExpression_ curRE; int numStrings = 0; for (int i = 0; i < getChoices().size(); i++) { if (!(curRE = getChoices().get(i)).private_rexp && // curRE instanceof RJustName && curRE.ordinal > 0 && curRE.ordinal < ordinal && LexGen.lexStates[curRE.ordinal] == LexGen.lexStates[ordinal]) { if (label != null) JavaCCErrors.warning(this, "Regular Expression choice : " + curRE.label + " can never be matched as : " + label); else JavaCCErrors.warning(this, "Regular Expression choice : " + curRE.label + " can never be matched as token of kind : " + ordinal); } if (!curRE.private_rexp && curRE instanceof RStringLiteral) numStrings++; } } } jtb-1.4.4/EDU/purdue/jtb/parser/Choice.java0000644000175000017500000000660011360636752020163 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; /** * Describes expansions where one of many choices * is taken (c1|c2|...). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Choice extends Expansion_ { /** * The list of choices of this expansion unit. Each * List component will narrow to ExpansionUnit. */ private List choices = new ArrayList(); public Choice() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.CHOICE; } public Choice(final Token token) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(token.beginLine); this.setColumn(token.beginColumn); } public Choice(final Expansion_ expansion) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(expansion.getLine()); this.setColumn(expansion.getColumn()); this.getChoices().add(expansion); } /** * @param choices the choices to set */ public final void setChoices(final List ch) { choices = ch; } /** * @return the choices */ public final List getChoices() { return choices; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); for (final Iterator it = getChoices().iterator(); it.hasNext();) { final Expansion_ next = it.next(); sb.append(eol).append(next.dump(indent + 1, alreadyDumped)); } return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/MetaParseException.java0000644000175000017500000000366011360636752022534 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Thrown when there is a mis-configuration or a bug. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class MetaParseException extends ParseException { /** Default serialVersionUID */ private static final long serialVersionUID = 1L; } jtb-1.4.4/EDU/purdue/jtb/parser/RJustName.java0000644000175000017500000000457511360636752020652 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes regular expressions which are referred to just by * their name. This means that a regular expression with this * name has been declared earlier. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RJustName extends RegularExpression_ { /** * "regexpr" points to the regular expression denoted by the name. */ public RegularExpression_ regexpr; @Override public Nfa GenerateNfa(final boolean ignoreCase) { return regexpr.GenerateNfa(ignoreCase); } public RJustName() {} public RJustName(final Token token, final String image) { this.setLine(token.beginLine); this.setColumn(token.beginColumn); this.label = image; } } jtb-1.4.4/EDU/purdue/jtb/parser/ZeroOrMore.java0000644000175000017500000000524411360636752021037 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Set; /** * Describes zero-or-more expansions (e.g., foo*). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class ZeroOrMore extends Expansion_ { /** * The expansion which is repeated zero or more times. */ public Expansion_ expansion; public ZeroOrMore() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.ZERO_OR_MORE; } public ZeroOrMore(final Token token, final Expansion_ exp) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); setLine(token.beginLine); setColumn(token.beginColumn); expansion = exp; expansion.parent = this; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); sb.append(eol).append(expansion.dump(indent + 1, alreadyDumped)); return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/RZeroOrOne.java0000644000175000017500000000471611360636752021003 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes zero-or-one regular expressions (). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RZeroOrOne extends RegularExpression_ { /** * The regular expression which is repeated zero or one times. */ public RegularExpression_ regexpr; // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker public RZeroOrOne() { expType = EXP_TYPE.R_ZERO_OR_ONE; } @Override public Nfa GenerateNfa(final boolean ignoreCase) { final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; final Nfa temp = regexpr.GenerateNfa(ignoreCase); startState.AddMove(temp.start); startState.AddMove(finalState); temp.end.AddMove(finalState); return retVal; } } jtb-1.4.4/EDU/purdue/jtb/parser/TreeWalkerOp.java0000644000175000017500000000403611360636752021336 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Objects of this type are passed to the tree walker * routines in ExpansionTreeWalker. */ public interface TreeWalkerOp { /** * When called at a particular node, this specifies to the * tree walker if it should visit more nodes under this node. */ boolean goDeeper(Expansion_ e); /** * When a node is visited, this method is invoked with the * node as parameter. */ void action(Expansion_ e); } jtb-1.4.4/EDU/purdue/jtb/parser/RCharacterList.java0000644000175000017500000006605311360636752021653 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes character lists. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RCharacterList extends RegularExpression_ { /** * This is true if a tilde (~) appears before the character list. * Otherwise, this is false. */ public boolean negated_list = false; /** * This is the list of descriptors of the character list. Each list * entry will narrow to either SingleCharacter or to CharacterRange. */ public List descriptors = new ArrayList(); static final char[] diffLowerCaseRanges = { 65, 90, 192, 214, 216, 222, 256, 256, 258, 258, 260, 260, 262, 262, 264, 264, 266, 266, 268, 268, 270, 270, 272, 272, 274, 274, 276, 276, 278, 278, 280, 280, 282, 282, 284, 284, 286, 286, 288, 288, 290, 290, 292, 292, 294, 294, 296, 296, 298, 298, 300, 300, 302, 302, /* new for fixing 1.0.2 */304, 304, /* * End * new */ 306, 306, 308, 308, 310, 310, 313, 313, 315, 315, 317, 317, 319, 319, 321, 321, 323, 323, 325, 325, 327, 327, 330, 330, 332, 332, 334, 334, 336, 336, 338, 338, 340, 340, 342, 342, 344, 344, 346, 346, 348, 348, 350, 350, 352, 352, 354, 354, 356, 356, 358, 358, 360, 360, 362, 362, 364, 364, 366, 366, 368, 368, 370, 370, 372, 372, 374, 374, 376, 376, 377, 377, 379, 379, 381, 381, 385, 385, 386, 386, 388, 388, 390, 390, 391, 391, /* new for fixing 1.0.2 */393, 393, /* End new */394, 394, 395, 395, /* 398, Sreeni fixed for 1.2 */399, 399, 400, 400, 401, 401, 403, 403, 404, 404, 406, 406, 407, 407, 408, 408, 412, 412, 413, 413, 416, 416, 418, 418, 420, 420, 423, 423, 425, 425, 428, 428, 430, 430, 431, 431, 433, 434, 435, 435, 437, 437, 439, 439, 440, 440, 444, 444, 452, 452, 453, 453, 455, 455, 456, 456, 458, 458, 459, 459, 461, 461, 463, 463, 465, 465, 467, 467, 469, 469, 471, 471, 473, 473, 475, 475, 478, 478, 480, 480, 482, 482, 484, 484, 486, 486, 488, 488, 490, 490, 492, 492, 494, 494, 497, 497, 498, 498, 500, 500, 506, 506, 508, 508, 510, 510, 512, 512, 514, 514, 516, 516, 518, 518, 520, 520, 522, 522, 524, 524, 526, 526, 528, 528, 530, 530, 532, 532, 534, 534, 902, 902, 904, 906, 908, 908, 910, 911, 913, 929, 931, 939, 994, 994, 996, 996, 998, 998, 1000, 1000, 1002, 1002, 1004, 1004, 1006, 1006, 1025, 1036, 1038, 1039, 1040, 1040, 1041, 1041, 1042, 1071, 1120, 1120, 1122, 1122, 1124, 1124, 1126, 1126, 1128, 1128, 1130, 1130, 1132, 1132, 1134, 1134, 1136, 1136, 1138, 1138, 1140, 1140, 1142, 1142, 1144, 1144, 1146, 1146, 1148, 1148, 1150, 1150, 1152, 1152, 1168, 1168, 1170, 1170, 1172, 1172, 1174, 1174, 1176, 1176, 1178, 1178, 1180, 1180, 1182, 1182, 1184, 1184, 1186, 1186, 1188, 1188, 1190, 1190, 1192, 1192, 1194, 1194, 1196, 1196, 1198, 1198, 1200, 1200, 1202, 1202, 1204, 1204, 1206, 1206, 1208, 1208, 1210, 1210, 1212, 1212, 1214, 1214, 1217, 1217, 1219, 1219, 1223, 1223, 1227, 1227, 1232, 1232, 1234, 1234, 1236, 1236, 1238, 1238, 1240, 1240, 1242, 1242, 1244, 1244, 1246, 1246, 1248, 1248, 1250, 1250, 1252, 1252, 1254, 1254, 1256, 1256, 1258, 1258, 1262, 1262, 1264, 1264, 1266, 1266, 1268, 1268, 1272, 1272, 1329, 1366, 4256, 4293, 7680, 7680, 7682, 7682, 7684, 7684, 7686, 7686, 7688, 7688, 7690, 7690, 7692, 7692, 7694, 7694, 7696, 7696, 7698, 7698, 7700, 7700, 7702, 7702, 7704, 7704, 7706, 7706, 7708, 7708, 7710, 7710, 7712, 7712, 7714, 7714, 7716, 7716, 7718, 7718, 7720, 7720, 7722, 7722, 7724, 7724, 7726, 7726, 7728, 7728, 7730, 7730, 7732, 7732, 7734, 7734, 7736, 7736, 7738, 7738, 7740, 7740, 7742, 7742, 7744, 7744, 7746, 7746, 7748, 7748, 7750, 7750, 7752, 7752, 7754, 7754, 7756, 7756, 7758, 7758, 7760, 7760, 7762, 7762, 7764, 7764, 7766, 7766, 7768, 7768, 7770, 7770, 7772, 7772, 7774, 7774, 7776, 7776, 7778, 7778, 7780, 7780, 7782, 7782, 7784, 7784, 7786, 7786, 7788, 7788, 7790, 7790, 7792, 7792, 7794, 7794, 7796, 7796, 7798, 7798, 7800, 7800, 7802, 7802, 7804, 7804, 7806, 7806, 7808, 7808, 7810, 7810, 7812, 7812, 7814, 7814, 7816, 7816, 7818, 7818, 7820, 7820, 7822, 7822, 7824, 7824, 7826, 7826, 7828, 7828, 7840, 7840, 7842, 7842, 7844, 7844, 7846, 7846, 7848, 7848, 7850, 7850, 7852, 7852, 7854, 7854, 7856, 7856, 7858, 7858, 7860, 7860, 7862, 7862, 7864, 7864, 7866, 7866, 7868, 7868, 7870, 7870, 7872, 7872, 7874, 7874, 7876, 7876, 7878, 7878, 7880, 7880, 7882, 7882, 7884, 7884, 7886, 7886, 7888, 7888, 7890, 7890, 7892, 7892, 7894, 7894, 7896, 7896, 7898, 7898, 7900, 7900, 7902, 7902, 7904, 7904, 7906, 7906, 7908, 7908, 7910, 7910, 7912, 7912, 7914, 7914, 7916, 7916, 7918, 7918, 7920, 7920, 7922, 7922, 7924, 7924, 7926, 7926, 7928, 7928, 7944, 7951, 7960, 7965, 7976, 7983, 7992, 7999, 8008, 8013, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8031, 8040, 8047, 8072, 8079, 8088, 8095, 8104, 8111, 8120, 8121, 8122, 8123, 8124, 8124, 8136, 8139, 8140, 8140, 8152, 8153, 8154, 8155, 8168, 8169, 8170, 8171, 8172, 8172, 8184, 8185, 8186, 8187, 8188, 8188, 8544, 8559, 9398, 9423, 65313, 65338, 65339, 0xfffe, 0xffff, 0xffff }; static final char[] diffUpperCaseRanges = { 97, 122, 224, 246, 248, 254, 255, 255, 257, 257, 259, 259, 261, 261, 263, 263, 265, 265, 267, 267, 269, 269, 271, 271, 273, 273, 275, 275, 277, 277, 279, 279, 281, 281, 283, 283, 285, 285, 287, 287, 289, 289, 291, 291, 293, 293, 295, 295, 297, 297, 299, 299, 301, 301, 303, 303, 305, 305, 307, 307, 309, 309, 311, 311, 314, 314, 316, 316, 318, 318, 320, 320, 322, 322, 324, 324, 326, 326, 328, 328, 331, 331, 333, 333, 335, 335, 337, 337, 339, 339, 341, 341, 343, 343, 345, 345, 347, 347, 349, 349, 351, 351, 353, 353, 355, 355, 357, 357, 359, 359, 361, 361, 363, 363, 365, 365, 367, 367, 369, 369, 371, 371, 373, 373, 375, 375, 378, 378, 380, 380, 382, 382, 383, 383, 387, 387, 389, 389, 392, 392, 396, 396, 402, 402, 409, 409, 417, 417, 419, 419, 421, 421, 424, 424, 429, 429, 432, 432, 436, 436, 438, 438, 441, 441, 445, 445, 453, 453, 454, 454, 456, 456, 457, 457, 459, 459, 460, 460, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 479, 479, 481, 481, 483, 483, 485, 485, 487, 487, 489, 489, 491, 491, 493, 493, 495, 495, 498, 498, 499, 499, 501, 501, 507, 507, 509, 509, 511, 511, 513, 513, 515, 515, 517, 517, 519, 519, 521, 521, 523, 523, 525, 525, 527, 527, 529, 529, 531, 531, 533, 533, 535, 535, 595, 595, 596, 596, 598, /* new for fixing 1.0.2 */598, 599, /* End new */599, /* 600, Sreeni fixed for 1.2 */ 601, 601, 603, 603, 608, 608, 611, 611, 616, 616, 617, 617, 623, 623, 626, 626, 643, 643, 648, 648, 650, 651, 658, 658, 940, 940, 941, 943, 945, 961, /* new for fixing 1.0.2 */962, 962, /* End new */963, 971, 972, 972, 973, 974, 976, 976, 977, 977, 981, 981, 982, 982, 995, 995, 997, 997, 999, 999, 1001, 1001, 1003, 1003, 1005, 1005, 1007, 1007, 1008, 1008, 1009, 1009, 1072, 1103, 1105, 1116, 1118, 1119, 1121, 1121, 1123, 1123, 1125, 1125, 1127, 1127, 1129, 1129, 1131, 1131, 1133, 1133, 1135, 1135, 1137, 1137, 1139, 1139, 1141, 1141, 1143, 1143, 1145, 1145, 1147, 1147, 1149, 1149, 1151, 1151, 1153, 1153, 1169, 1169, 1171, 1171, 1173, 1173, 1175, 1175, 1177, 1177, 1179, 1179, 1181, 1181, 1183, 1183, 1185, 1185, 1187, 1187, 1189, 1189, 1191, 1191, 1193, 1193, 1195, 1195, 1197, 1197, 1199, 1199, 1201, 1201, 1203, 1203, 1205, 1205, 1207, 1207, 1209, 1209, 1211, 1211, 1213, 1213, 1215, 1215, 1218, 1218, 1220, 1220, 1224, 1224, 1228, 1228, 1233, 1233, 1235, 1235, 1237, 1237, 1239, 1239, 1241, 1241, 1243, 1243, 1245, 1245, 1247, 1247, 1249, 1249, 1251, 1251, 1253, 1253, 1255, 1255, 1257, 1257, 1259, 1259, 1263, 1263, 1265, 1265, 1267, 1267, 1269, 1269, 1273, 1273, 1377, 1414, 7681, 7681, 7683, 7683, 7685, 7685, 7687, 7687, 7689, 7689, 7691, 7691, 7693, 7693, 7695, 7695, 7697, 7697, 7699, 7699, 7701, 7701, 7703, 7703, 7705, 7705, 7707, 7707, 7709, 7709, 7711, 7711, 7713, 7713, 7715, 7715, 7717, 7717, 7719, 7719, 7721, 7721, 7723, 7723, 7725, 7725, 7727, 7727, 7729, 7729, 7731, 7731, 7733, 7733, 7735, 7735, 7737, 7737, 7739, 7739, 7741, 7741, 7743, 7743, 7745, 7745, 7747, 7747, 7749, 7749, 7751, 7751, 7753, 7753, 7755, 7755, 7757, 7757, 7759, 7759, 7761, 7761, 7763, 7763, 7765, 7765, 7767, 7767, 7769, 7769, 7771, 7771, 7773, 7773, 7775, 7775, 7777, 7777, 7779, 7779, 7781, 7781, 7783, 7783, 7785, 7785, 7787, 7787, 7789, 7789, 7791, 7791, 7793, 7793, 7795, 7795, 7797, 7797, 7799, 7799, 7801, 7801, 7803, 7803, 7805, 7805, 7807, 7807, 7809, 7809, 7811, 7811, 7813, 7813, 7815, 7815, 7817, 7817, 7819, 7819, 7821, 7821, 7823, 7823, 7825, 7825, 7827, 7827, 7829, 7829, 7841, 7841, 7843, 7843, 7845, 7845, 7847, 7847, 7849, 7849, 7851, 7851, 7853, 7853, 7855, 7855, 7857, 7857, 7859, 7859, 7861, 7861, 7863, 7863, 7865, 7865, 7867, 7867, 7869, 7869, 7871, 7871, 7873, 7873, 7875, 7875, 7877, 7877, 7879, 7879, 7881, 7881, 7883, 7883, 7885, 7885, 7887, 7887, 7889, 7889, 7891, 7891, 7893, 7893, 7895, 7895, 7897, 7897, 7899, 7899, 7901, 7901, 7903, 7903, 7905, 7905, 7907, 7907, 7909, 7909, 7911, 7911, 7913, 7913, 7915, 7915, 7917, 7917, 7919, 7919, 7921, 7921, 7923, 7923, 7925, 7925, 7927, 7927, 7929, 7929, 7936, 7943, 7952, 7957, 7968, 7975, 7984, 7991, 8000, 8005, 8017, 8017, 8019, 8019, 8021, 8021, 8023, 8023, 8032, 8039, 8048, 8049, 8050, 8053, 8054, 8055, 8056, 8057, 8058, 8059, 8060, 8061, 8064, 8071, 8080, 8087, 8096, 8103, 8112, 8113, 8115, 8115, 8131, 8131, 8144, 8145, 8160, 8161, 8165, 8165, 8179, 8179, 8560, 8575, 9424, 9449, 65345, 65370, 65371, 0xfffe, 0xffff, 0xffff }; void ToCaseNeutral() { final int cnt = descriptors.size(); for (int i = 0; i < cnt; i++) { if (descriptors.get(i) instanceof SingleCharacter) { final char ch = ((SingleCharacter) descriptors.get(i)).ch; if (ch != Character.toLowerCase(ch)) descriptors.add(new SingleCharacter(Character.toLowerCase(ch))); if (ch != Character.toUpperCase(ch)) descriptors.add(new SingleCharacter(Character.toUpperCase(ch))); } else { final char l = ((CharacterRange) descriptors.get(i)).getLeft(); final char r = ((CharacterRange) descriptors.get(i)).getRight(); int j = 0; /* Add ranges for which lower case is different. */ for (;;) { while (l > diffLowerCaseRanges[j]) j += 2; if (l < diffLowerCaseRanges[j]) { if (r < diffLowerCaseRanges[j]) break; if (r <= diffLowerCaseRanges[j + 1]) { descriptors.add(new CharacterRange( Character.toLowerCase(diffLowerCaseRanges[j]), (char) (Character.toLowerCase(diffLowerCaseRanges[j]) + r - diffLowerCaseRanges[j]))); break; } descriptors.add(new CharacterRange(Character.toLowerCase(diffLowerCaseRanges[j]), Character.toLowerCase(diffLowerCaseRanges[j + 1]))); } else { if (r <= diffLowerCaseRanges[j + 1]) { descriptors.add(new CharacterRange( (char) (Character.toLowerCase(diffLowerCaseRanges[j]) + l - diffLowerCaseRanges[j]), (char) (Character.toLowerCase(diffLowerCaseRanges[j]) + r - diffLowerCaseRanges[j]))); break; } descriptors.add(new CharacterRange( (char) (Character.toLowerCase(diffLowerCaseRanges[j]) + l - diffLowerCaseRanges[j]), Character.toLowerCase(diffLowerCaseRanges[j + 1]))); } j += 2; while (r > diffLowerCaseRanges[j]) { if (r <= diffLowerCaseRanges[j + 1]) { descriptors.add(new CharacterRange( Character.toLowerCase(diffLowerCaseRanges[j]), (char) (Character.toLowerCase(diffLowerCaseRanges[j]) + r - diffLowerCaseRanges[j]))); break; } descriptors.add(new CharacterRange(Character.toLowerCase(diffLowerCaseRanges[j]), Character.toLowerCase(diffLowerCaseRanges[j + 1]))); j += 2; } break; } /* Add ranges for which upper case is different. */ j = 0; while (l > diffUpperCaseRanges[j]) j += 2; if (l < diffUpperCaseRanges[j]) { if (r < diffUpperCaseRanges[j]) continue; if (r <= diffUpperCaseRanges[j + 1]) { descriptors.add(new CharacterRange( Character.toUpperCase(diffUpperCaseRanges[j]), (char) (Character.toUpperCase(diffUpperCaseRanges[j]) + r - diffUpperCaseRanges[j]))); continue; } descriptors.add(new CharacterRange(Character.toUpperCase(diffUpperCaseRanges[j]), Character.toUpperCase(diffUpperCaseRanges[j + 1]))); } else { if (r <= diffUpperCaseRanges[j + 1]) { descriptors.add(new CharacterRange( (char) (Character.toUpperCase(diffUpperCaseRanges[j]) + l - diffUpperCaseRanges[j]), (char) (Character.toUpperCase(diffUpperCaseRanges[j]) + r - diffUpperCaseRanges[j]))); continue; } descriptors.add(new CharacterRange( (char) (Character.toUpperCase(diffUpperCaseRanges[j]) + l - diffUpperCaseRanges[j]), Character.toUpperCase(diffUpperCaseRanges[j + 1]))); } j += 2; while (r > diffUpperCaseRanges[j]) { if (r <= diffUpperCaseRanges[j + 1]) { descriptors.add(new CharacterRange( Character.toUpperCase(diffUpperCaseRanges[j]), (char) (Character.toUpperCase(diffUpperCaseRanges[j]) + r - diffUpperCaseRanges[j]))); break; } descriptors.add(new CharacterRange(Character.toUpperCase(diffUpperCaseRanges[j]), Character.toUpperCase(diffUpperCaseRanges[j + 1]))); j += 2; } } } } boolean transformed = false; @Override public Nfa GenerateNfa(final boolean ignoreCase) { if (!transformed) { if (Options.getIgnoreCase() || ignoreCase) { /* int i; System.out.println("Before:"); for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) { char c = ((SingleCharacter)descriptors.get(i)).ch; System.out.print((int)c + " "); } else { char l = ((CharacterRange)descriptors.get(i)).left; char r = ((CharacterRange)descriptors.get(i)).right; System.out.print((int)l + "-" + (int)r + " "); } if ((i + 1) % 6 == 0) System.out.println(""); } System.out.println(""); */ ToCaseNeutral(); SortDescriptors(); /* System.out.println("After:"); for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) { char c = ((SingleCharacter)descriptors.get(i)).ch; System.out.print((int)c + " "); } else { char l = ((CharacterRange)descriptors.get(i)).left; char r = ((CharacterRange)descriptors.get(i)).right; System.out.print((int)l + "-" + (int)r + " "); } if ((i + 1) % 6 == 0) System.out.println(""); } System.out.println(""); */ } if (negated_list) RemoveNegation(); // This also sorts the list else SortDescriptors(); } if (descriptors.size() == 0 && !negated_list) { JavaCCErrors.semantic_error(this, "Empty character set is not allowed as it will not match any character."); return new Nfa(); } transformed = true; final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; int i; for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) startState.AddChar(((SingleCharacter) descriptors.get(i)).ch); else // if (descriptors.get(i) instanceof CharacterRange) { final CharacterRange cr = (CharacterRange) descriptors.get(i); if (cr.getLeft() == cr.getRight()) startState.AddChar(cr.getLeft()); else startState.AddRange(cr.getLeft(), cr.getRight()); } } startState.next = finalState; return retVal; } static boolean Overlaps(final CharacterRange r1, final CharacterRange r2) { return (r1.getLeft() <= r2.getRight() && r1.getRight() > r2.getRight()); } static boolean SubRange(final CharacterRange r1, final CharacterRange r2) { return (r1.getLeft() >= r2.getLeft() && r1.getRight() <= r2.getRight()); } static boolean InRange(final char c, final CharacterRange range) { return (c >= range.getLeft() && c <= range.getRight()); } void SortDescriptors() { // ModMMa : performance improvements (factoring) // int j; // // List newDesc = new ArrayList(descriptors.size()); // int cnt = 0; // // Outer: // for (int i = 0; i < descriptors.size(); i++) // { // SingleCharacter s; // CharacterRange range; // // if (descriptors.get(i) instanceof SingleCharacter) // { // s = (SingleCharacter)descriptors.get(i); // // for (j = 0; j < cnt; j++) // { // if (newDesc.get(j) instanceof SingleCharacter) // { // if (((SingleCharacter)newDesc.get(j)).ch > s.ch) // break; // else if (((SingleCharacter)newDesc.get(j)).ch == s.ch) // continue Outer; // } // else // { // char l = ((CharacterRange)newDesc.get(j)).getLeft(); // // if (InRange(s.ch, (CharacterRange)newDesc.get(j))) // continue Outer; // else if (l > s.ch) // break; // } // } // // newDesc.add(j, s); // cnt++; // } // else // { // range = (CharacterRange)descriptors.get(i); // // for (j = 0; j < cnt; j++) // { // if (newDesc.get(j) instanceof SingleCharacter) // { // if (InRange(((SingleCharacter)newDesc.get(j)).ch, range)) // { // newDesc.remove(j--); // cnt--; // } // else if (((SingleCharacter)newDesc.get(j)).ch > range.getRight()) // break; // } // else // { // if (SubRange(range, (CharacterRange)newDesc.get(j))) // { // continue Outer; // } // else if (SubRange((CharacterRange)newDesc.get(j), range)) // { // newDesc.set(j, range); // continue Outer; // } // else if (Overlaps(range, (CharacterRange)newDesc.get(j))) // { // range.setLeft((char)(((CharacterRange)newDesc.get(j)).getRight() + 1)); // } // else if (Overlaps((CharacterRange)newDesc.get(j), range)) // { // CharacterRange tmp = range; // ((CharacterRange)newDesc.get(j)).setRight((char)(range.getLeft() + 1)); // range = (CharacterRange)newDesc.get(j); // newDesc.set(j, tmp); // } // else if (((CharacterRange)newDesc.get(j)).getLeft() > range.getRight()) // break; // } // } // // newDesc.add(j, range); // cnt++; // } // } // // descriptors = newDesc; int j; final int descSize = descriptors.size(); final List newDesc = new ArrayList(descSize); int cnt = 0; Outer: for (int i = 0; i < descSize; i++) { final Object desci = descriptors.get(i); if (desci instanceof SingleCharacter) { final SingleCharacter s = (SingleCharacter) desci; for (j = 0; j < cnt; j++) { final Object ndj = newDesc.get(j); if (ndj instanceof SingleCharacter) { final char c = ((SingleCharacter) ndj).ch; if (c > s.ch) break; else if (c == s.ch) continue Outer; } else { final char l = ((CharacterRange) ndj).getLeft(); if (InRange(s.ch, (CharacterRange) ndj)) continue Outer; else if (l > s.ch) break; } } newDesc.add(j, s); cnt++; } else { CharacterRange range = (CharacterRange) desci; for (j = 0; j < cnt; j++) { final Object ndj = newDesc.get(j); if (ndj instanceof SingleCharacter) { final char c = ((SingleCharacter) ndj).ch; if (InRange(c, range)) { newDesc.remove(j--); cnt--; } else if (c > range.getRight()) break; } else { final CharacterRange crndj = (CharacterRange) ndj; if (SubRange(range, crndj)) { continue Outer; } else if (SubRange(crndj, range)) { newDesc.set(j, range); continue Outer; } else if (Overlaps(range, crndj)) { range.setLeft((char) (crndj.getRight() + 1)); } else if (Overlaps(crndj, range)) { final CharacterRange tmp = range; crndj.setRight((char) (range.getLeft() + 1)); range = crndj; newDesc.set(j, tmp); } else if (crndj.getLeft() > range.getRight()) break; } } newDesc.add(j, range); cnt++; } } descriptors = newDesc; } void RemoveNegation() { int i; SortDescriptors(); /* System.out.println("REM. NEG Before:"); for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) { char c = ((SingleCharacter)descriptors.get(i)).ch; System.out.print((int)c + " "); } else { char l = ((CharacterRange)descriptors.get(i)).left; char r = ((CharacterRange)descriptors.get(i)).right; System.out.print((int)l + "-" + (int)r + " "); } } System.out.println(""); */ final List newDescriptors = new ArrayList(); int lastRemoved = -1; // One less than the first valid character. for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) { final char c = ((SingleCharacter) descriptors.get(i)).ch; if (c >= 0 && c <= lastRemoved + 1) { lastRemoved = c; continue; } // System.out.println("lastRemoved : " + (int)lastRemoved + "; char : " + (int)c); newDescriptors.add(new CharacterRange((char) (lastRemoved + 1), (char) ((lastRemoved = c) - 1))); } else { final char l = ((CharacterRange) descriptors.get(i)).getLeft(); final char r = ((CharacterRange) descriptors.get(i)).getRight(); if (l >= 0 && l <= lastRemoved + 1) { lastRemoved = r; continue; } // System.out.println("lastRemoved : " + (int)lastRemoved + "; left : " + l + "; right : " + (int)r); newDescriptors.add(new CharacterRange((char) (lastRemoved + 1), (char) (l - 1))); lastRemoved = r; } } // System.out.println("lastRem : " + (int)lastRemoved); if (NfaState.unicodeWarningGiven || Options.getJavaUnicodeEscape()) { if (lastRemoved < (char) 0xffff) newDescriptors.add(new CharacterRange((char) (lastRemoved + 1), (char) 0xffff)); } else { if (lastRemoved < (char) 0xff) newDescriptors.add(new CharacterRange((char) (lastRemoved + 1), (char) 0xff)); } descriptors = newDescriptors; negated_list = false; /* System.out.println("REM NEG After:"); for (i = 0; i < descriptors.size(); i++) { if (descriptors.get(i) instanceof SingleCharacter) { char c = ((SingleCharacter)descriptors.get(i)).ch; System.out.print((int)c + " "); } else { char l = ((CharacterRange)descriptors.get(i)).left; char r = ((CharacterRange)descriptors.get(i)).right; System.out.print((int)l + "-" + (int)r + " "); } } System.out.println(""); */ } RCharacterList() { } RCharacterList(final char c) { descriptors = new ArrayList(); descriptors.add(new SingleCharacter(c)); negated_list = false; ordinal = Integer.MAX_VALUE; } @Override public boolean CanMatchAnyChar() { // Return true only if it is ~[] return negated_list && (descriptors == null || descriptors.size() == 0); } } jtb-1.4.4/EDU/purdue/jtb/parser/OneOrMore.java0000644000175000017500000000523511360636752020641 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Set; /** * Describes one-or-more expansions (e.g., foo+). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class OneOrMore extends Expansion_ { /** * The expansion which is repeated one or more times. */ public Expansion_ expansion; public OneOrMore() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.ONE_OR_MORE; } public OneOrMore(final Token t, final Expansion_ e) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(t.beginLine); this.setColumn(t.beginColumn); this.expansion = e; expansion.parent = this; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); sb.append(eol).append(expansion.dump(indent + 1, alreadyDumped)); return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/RegularExpression_.java0000644000175000017500000000755111360636752022617 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Describes regular expressions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public abstract class RegularExpression_ extends Expansion_ { /** * The label of the regular expression (if any). If no label is * present, this is set to "". */ public String label = ""; /** * The ordinal value assigned to the regular expression. It is * used for internal processing and passing information between * the parser and the lexical analyzer. */ // hides Expansion_.ordinal !!! int ordinal; /** * The LHS to which the token value of the regular expression * is assigned. In case there is no LHS, then the list * remains empty. */ public List lhsTokens = new ArrayList(); /** * We now allow qualified access to token members. Store it here. */ public Token rhsToken; /** * This flag is set if the regular expression has a label prefixed * with the # symbol - this indicates that the purpose of the regular * expression is solely for defining other regular expressions. */ public boolean private_rexp = false; /** * If this is a top-level regular expression (nested directly * within a TokenProduction), then this field point to that * TokenProduction object. */ public TokenProduction tpContext = null; public abstract Nfa GenerateNfa(boolean ignoreCase); public boolean CanMatchAnyChar() { return false; } /** * The following variable is used to maintain state information for the * loop determination algorithm: It is initialized to 0, and * set to -1 if this node has been visited in a pre-order walk, and then * it is set to 1 if the pre-order walk of the whole graph from this * node has been traversed. i.e., -1 indicates partially processed, * and 1 indicates fully processed. */ int walkStatus = 0; @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); alreadyDumped.add(this); sb.append(' ').append(label); return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/JavaCharStream.java0000644000175000017500000003573011416555666021640 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package EDU.purdue.jtb.parser; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (with java-like unicode escape processing). */ public class JavaCharStream { /** Whether parser is static. */ public static final boolean staticFlag = false; static final int hexval(char c) throws java.io.IOException { switch(c) { case '0' : return 0; case '1' : return 1; case '2' : return 2; case '3' : return 3; case '4' : return 4; case '5' : return 5; case '6' : return 6; case '7' : return 7; case '8' : return 8; case '9' : return 9; case 'a' : case 'A' : return 10; case 'b' : case 'B' : return 11; case 'c' : case 'C' : return 12; case 'd' : case 'D' : return 13; case 'e' : case 'E' : return 14; case 'f' : case 'F' : return 15; } throw new java.io.IOException(); // Should never come here } /** Position in buffer. */ public int bufpos = -1; int bufsize; int available; int tokenBegin; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] nextCharBuf; protected char[] buffer; protected int maxNextCharInd = 0; protected int nextCharInd = -1; protected int inBuf = 0; protected int tabSize = 8; protected void setTabSize(int i) { tabSize = i; } protected int getTabSize(int i) { return tabSize; } protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; bufpos += (bufsize - tokenBegin); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; bufpos -= tokenBegin; } } catch (Throwable t) { throw new Error(t.getMessage()); } available = (bufsize += 2048); tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { int i; if (maxNextCharInd == 4096) maxNextCharInd = nextCharInd = 0; try { if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { if (bufpos != 0) { --bufpos; backup(0); } else { bufline[bufpos] = line; bufcolumn[bufpos] = column; } throw e; } } protected char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) FillBuff(); return nextCharBuf[nextCharInd]; } /** @return starting character for token. */ public char BeginToken() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; tokenBegin = bufpos; return buffer[bufpos]; } tokenBegin = 0; bufpos = -1; return readChar(); } protected void AdjustBuffSize() { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = 0; available = tokenBegin; } else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (tabSize - (column % tabSize)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } /** Read a character. */ public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } char c; if (++bufpos == available) AdjustBuffSize(); if ((buffer[bufpos] = c = ReadByte()) == '\\') { UpdateLineColumn(c); int backSlashCnt = 1; for (;;) // Read all the backslashes { if (++bufpos == available) AdjustBuffSize(); try { if ((buffer[bufpos] = c = ReadByte()) != '\\') { UpdateLineColumn(c); // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1)) { if (--bufpos < 0) bufpos = bufsize - 1; break; } backup(backSlashCnt); return '\\'; } } catch(java.io.IOException e) { // We are returning one backslash so we should only backup (count-1) if (backSlashCnt > 1) backup(backSlashCnt-1); return '\\'; } UpdateLineColumn(c); backSlashCnt++; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ((c = ReadByte()) == 'u') ++column; buffer[bufpos] = c = (char)(hexval(c) << 12 | hexval(ReadByte()) << 8 | hexval(ReadByte()) << 4 | hexval(ReadByte())); column += 4; } catch(java.io.IOException e) { throw new Error("Invalid escape character at line " + line + " column " + column + "."); } if (backSlashCnt == 1) return c; else { backup(backSlashCnt - 1); return '\\'; } } else { UpdateLineColumn(c); return c; } } @Deprecated /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } @Deprecated /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } /** Get end column. */ public int getEndColumn() { return bufcolumn[bufpos]; } /** Get end line. */ public int getEndLine() { return bufline[bufpos]; } /** @return column of token start */ public int getBeginColumn() { return bufcolumn[tokenBegin]; } /** @return line number of token start */ public int getBeginLine() { return bufline[tokenBegin]; } /** Retreat. */ public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } /** Constructor. */ public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } /** Constructor. */ public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; nextCharInd = bufpos = -1; } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } /** @return token image as String */ public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } /** @return suffix */ public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } /** Set buffers back to null when finished. */ public void Done() { nextCharBuf = null; buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } /* JavaCC - OriginalChecksum=9a4fa06b204567e7e710a0bd0d9352cf (do not edit this line) */ jtb-1.4.4/EDU/purdue/jtb/parser/BNFProduction_.java0000644000175000017500000000512111360636752021601 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes BNF productions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class BNFProduction_ extends NormalProduction { /** * The declarations of this production. */ private final List declaration_tokens = new ArrayList(); /** * This flag keeps track of whether or not return and throw * statements have been patched within this production's actions to * include a preceding "if (true)". */ private boolean jumpPatched; /** * @return the declaration_tokens */ public final List getDeclarationTokens() { return declaration_tokens; } /** * @param jumpPatched the jumpPatched to set */ public final void setJumpPatched(final boolean jp) { jumpPatched = jp; } /** * @return the jumpPatched */ public final boolean isJumpPatched() { return jumpPatched; } } jtb-1.4.4/EDU/purdue/jtb/parser/TokenProduction.java0000644000175000017500000001002111360636752022110 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes the various regular expression productions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class TokenProduction { /** * Definitions of constants that identify the kind of regular * expression production this is. */ public static final int TOKEN = 0, SKIP = 1, MORE = 2, SPECIAL = 3; /** * The image of the above constants. */ public static final String[] kindImage = { "TOKEN", "SKIP", "MORE", "SPECIAL" }; /** * The starting line and column of this token production. */ private int column; private int line; /** * The states in which this regular expression production exists. If * this array is null, then "<*>" has been specified and this regular * expression exists in all states. However, this null value is * replaced by a String array that includes all lexical state names * during the semanticization phase. */ public String[] lexStates; /** * The kind of this token production - TOKEN, SKIP, MORE, or SPECIAL. */ public int kind; /** * The list of regular expression specifications that comprise this * production. Each entry is a "RegExprSpec". */ public List respecs = new ArrayList(); /** * This is true if this corresponds to a production that actually * appears in the input grammar. Otherwise (if this is created to * describe a regular expression that is part of the BNF) this is set * to false. */ public boolean isExplicit = true; /** * This is true if case is to be ignored within the regular expressions * of this token production. */ public boolean ignoreCase = false; /** * The first and last tokens from the input stream that represent this * production. */ public Token firstToken, lastToken; /** * @param line the line to set */ public final void setLine(final int ln) { line = ln; } /** * @return the line */ public final int getLine() { return line; } /** * @param column the column to set */ public final void setColumn(final int cl) { column = cl; } /** * @return the column */ public final int getColumn() { return column; } } jtb-1.4.4/EDU/purdue/jtb/parser/RegExprSpec_.java0000644000175000017500000000451311360636752021320 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * The object type of entries in the vector "respecs" of class * "TokenProduction". */ public class RegExprSpec_ { /** * The regular expression of this specification. */ public RegularExpression_ rexp; /** * The action corresponding to this specification. */ public Action act; /** * The next state corresponding to this specification. If no * next state has been specified, this field is set to "null". */ public String nextState; /** * If the next state specification was explicit in the previous * case, then this token is that of the identifier denoting * the next state. This is used for location information, etc. * in error reporting. */ public Token nsTok; } jtb-1.4.4/EDU/purdue/jtb/parser/JavaCodeProduction_.java0000644000175000017500000000417111360636752022654 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes JAVACODE productions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class JavaCodeProduction_ extends NormalProduction { /** * The tokens that implement this JAVACODE production. */ private final List code_tokens = new ArrayList(); /** * @return the code_tokens */ public final List getCodeTokens() { return code_tokens; } } jtb-1.4.4/EDU/purdue/jtb/parser/ParseEngine.java0000644000175000017500000015325611360636752021203 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; /** * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class ParseEngine extends JavaCCGlobals { static private java.io.PrintWriter ostr; static private int gensymindex = 0; static private int indentamt; static private boolean jj2LA; /** * These lists are used to maintain expansions for which code generation * in phase 2 and phase 3 is required. Whenever a call is generated to * a phase 2 or phase 3 routine, a corresponding entry is added here if * it has not already been added. * The phase 3 routines have been optimized in version 0.7pre2. Essentially * only those methods (and only those portions of these methods) are * generated that are required. The lookahead amount is used to determine * this. This change requires the use of a hash table because it is now * possible for the same phase 3 routine to be requested multiple times * with different lookaheads. The hash table provides a easily searchable * capability to determine the previous requests. * The phase 3 routines now are performed in a two step process - the first * step gathers the requests (replacing requests with lower lookaheads with * those requiring larger lookaheads). The second step then generates these * methods. * This optimization and the hashtable makes it look like we do not need * the flag "phase3done" any more. But this has not been removed yet. */ static private List phase2list = new ArrayList(); static private List phase3list = new ArrayList(); static private Hashtable phase3table = new Hashtable(); /** * The phase 1 routines generates their output into String's and dumps * these String's once for each method. These String's contain the * special characters '\u0001' to indicate a positive indent, and '\u0002' * to indicate a negative indent. '\n' is used to indicate a line terminator. * The characters '\u0003' and '\u0004' are used to delineate portions of * text where '\n's should not be followed by an indentation. */ /** * Returns true if there is a JAVACODE production that the argument expansion * may directly expand to (without consuming tokens or encountering lookahead). */ static private boolean javaCodeCheck(final Expansion_ exp) { if (exp instanceof RegularExpression_) { return false; } else if (exp instanceof NonTerminal) { final NormalProduction prod = ((NonTerminal)exp).getProd(); if (prod instanceof JavaCodeProduction_) { return true; } else { return javaCodeCheck(prod.getExpansion()); } } else if (exp instanceof Choice) { final Choice ch = (Choice)exp; for (int i = 0; i < ch.getChoices().size(); i++) { if (javaCodeCheck((ch.getChoices().get(i)))) { return true; } } return false; } else if (exp instanceof Sequence) { final Sequence seq = (Sequence)exp; for (int i = 0; i < seq.units.size(); i++) { final Expansion_[] units = seq.units.toArray(new Expansion_[seq.units.size()]); if (units[i] instanceof Lookahead && ((Lookahead)units[i]).isExplicit()) { // An explicit lookahead (rather than one generated implicitly). Assume // the user knows what he / she is doing, e.g. // "A" ( "B" | LOOKAHEAD("X") jcode() | "C" )* "D" return false; } else if (javaCodeCheck((units[i]))) { return true; } else if (!Semanticize.emptyExpansionExists(units[i])) { return false; } } return false; } else if (exp instanceof OneOrMore) { final OneOrMore om = (OneOrMore)exp; return javaCodeCheck(om.expansion); } else if (exp instanceof ZeroOrMore) { final ZeroOrMore zm = (ZeroOrMore)exp; return javaCodeCheck(zm.expansion); } else if (exp instanceof ZeroOrOne) { final ZeroOrOne zo = (ZeroOrOne)exp; return javaCodeCheck(zo.expansion); } else if (exp instanceof TryBlock) { final TryBlock tb = (TryBlock)exp; return javaCodeCheck(tb.exp); } else { return false; } } /** * An array used to store the first sets generated by the following method. * A true entry means that the corresponding token is in the first set. */ static private boolean[] firstSet; /** * Sets up the array "firstSet" above based on the Expansion_ argument * passed to it. Since this is a recursive function, it assumes that * "firstSet" has been reset before the first call. */ static private void genFirstSet(final Expansion_ exp) { if (exp instanceof RegularExpression_) { firstSet[((RegularExpression_)exp).ordinal] = true; } else if (exp instanceof NonTerminal) { if (!(((NonTerminal)exp).getProd() instanceof JavaCodeProduction_)) { genFirstSet(((BNFProduction_)(((NonTerminal)exp).getProd())).getExpansion()); } } else if (exp instanceof Choice) { final Choice ch = (Choice)exp; for (int i = 0; i < ch.getChoices().size(); i++) { genFirstSet((ch.getChoices().get(i))); } } else if (exp instanceof Sequence) { final Sequence seq = (Sequence)exp; final Object obj = seq.units.get(0); if ((obj instanceof Lookahead) && (((Lookahead)obj).getActionTokens().size() != 0)) { jj2LA = true; } for (int i = 0; i < seq.units.size(); i++) { final Expansion_ unit = seq.units.get(i); // Javacode productions can not have FIRST sets. Instead we generate the FIRST set // for the preceding LOOKAHEAD (the semantic checks should have made sure that // the LOOKAHEAD is suitable). if (unit instanceof NonTerminal && ((NonTerminal)unit).getProd() instanceof JavaCodeProduction_) { if (i > 0 && seq.units.get(i-1) instanceof Lookahead) { final Lookahead la = (Lookahead)seq.units.get(i-1); genFirstSet(la.getLaExpansion()); } } else { genFirstSet((seq.units.get(i))); } if (!Semanticize.emptyExpansionExists((seq.units.get(i)))) { break; } } } else if (exp instanceof OneOrMore) { final OneOrMore om = (OneOrMore)exp; genFirstSet(om.expansion); } else if (exp instanceof ZeroOrMore) { final ZeroOrMore zm = (ZeroOrMore)exp; genFirstSet(zm.expansion); } else if (exp instanceof ZeroOrOne) { final ZeroOrOne zo = (ZeroOrOne)exp; genFirstSet(zo.expansion); } else if (exp instanceof TryBlock) { final TryBlock tb = (TryBlock)exp; genFirstSet(tb.exp); } } /** * Constants used in the following method "buildLookaheadChecker". */ static final int NOOPENSTM = 0; static final int OPENIF = 1; static final int OPENSWITCH = 2; @SuppressWarnings("unused") private static void dumpLookaheads(final Lookahead[] conds, final String[] actions) { for (int i = 0; i < conds.length; i++) { System.err.println("Lookahead: " + i); System.err.println(conds[i].dump(0, new HashSet())); System.err.println(); } } /** * This method takes two parameters - an array of Lookahead's * "conds", and an array of String's "actions". "actions" contains * exactly one element more than "conds". "actions" are Java source * code, and "conds" translate to conditions - so lets say * "f(conds[i])" is true if the lookahead required by "conds[i]" is * indeed the case. This method returns a string corresponding to * the Java code for: * * if (f(conds[0]) actions[0] * else if (f(conds[1]) actions[1] * . . . * else actions[action.length-1] * * A particular action entry ("actions[i]") can be null, in which * case, a noop is generated for that action. */ @SuppressWarnings("fallthrough") // for case NOOPENSTM: static String buildLookaheadChecker(final Lookahead[] conds, final String[] actions) { // ModMMa : performance improvements (String concatenation) // // The state variables. // int state = NOOPENSTM; // int indentAmt = 0; // boolean[] casedValues = new boolean[tokenCount]; // String retval = ""; // Lookahead la; // Token t = null; // int tokenMaskSize = (tokenCount-1)/32 + 1; // int[] tokenMask = null; // // // Iterate over all the conditions. // int index = 0; // while (index < conds.length) { // // la = conds[index]; // jj2LA = false; // // if ((la.getAmount() == 0) || // Semanticize.emptyExpansionExists(la.getLaExpansion()) || // javaCodeCheck(la.getLaExpansion()) // ) { // // // This handles the following cases: // // . If syntactic lookahead is not wanted (and hence explicitly specified // // as 0). // // . If it is possible for the lookahead expansion to recognize the empty // // string - in which case the lookahead trivially passes. // // . If the lookahead expansion has a JAVACODE production that it directly // // expands to - in which case the lookahead trivially passes. // if (la.getActionTokens().size() == 0) { // // In addition, if there is no semantic lookahead, then the // // lookahead trivially succeeds. So break the main loop and // // treat this case as the default last action. // break; // } else { // // This case is when there is only semantic lookahead // // (without any preceding syntactic lookahead). In this // // case, an "if" statement is generated. // switch (state) { // case NOOPENSTM: // retval += "\n" + "if ("; // indentAmt++; // break; // case OPENIF: // retval += "\u0002\n" + "} else if ("; // break; // case OPENSWITCH: // retval += "\u0002\n" + "default:" + "\u0001"; // if (Options.getErrorReporting()) { // retval += "\njj_la1[" + maskindex + "] = jj_gen;"; // maskindex++; // } // maskVals.add(tokenMask); // retval += "\n" + "if ("; // indentAmt++; // } // printTokenSetup((Token)(la.getActionTokens().get(0))); // for (Iterator it = la.getActionTokens().iterator(); it.hasNext();) { // t = (Token)it.next(); // retval += printToken(t); // } // retval += printTrailingComments(t); // retval += ") {\u0001" + actions[index]; // state = OPENIF; // } // // } else if (la.getAmount() == 1 && la.getActionTokens().size() == 0) { // // Special optimal processing when the lookahead is exactly 1, and there // // is no semantic lookahead. // // if (firstSet == null) { // firstSet = new boolean[tokenCount]; // } // for (int i = 0; i < tokenCount; i++) { // firstSet[i] = false; // } // // jj2LA is set to false at the beginning of the containing "if" statement. // // It is checked immediately after the end of the same statement to determine // // if lookaheads are to be performed using calls to the jj2 methods. // genFirstSet(la.getLaExpansion()); // // genFirstSet may find that semantic attributes are appropriate for the next // // token. In which case, it sets jj2LA to true. // if (!jj2LA) { // // // This case is if there is no applicable semantic lookahead and the lookahead // // is one (excluding the earlier cases such as JAVACODE, etc.). // switch (state) { // case OPENIF: // retval += "\u0002\n" + "} else {\u0001"; // // Control flows through to next case. // case NOOPENSTM: // retval += "\n" + "switch ("; // if (Options.getCacheTokens()) { // retval += "jj_nt.kind) {\u0001"; // } else { // retval += "(jj_ntk==-1)?jj_ntk():jj_ntk) {\u0001"; // } // for (int i = 0; i < tokenCount; i++) { // casedValues[i] = false; // } // indentAmt++; // tokenMask = new int[tokenMaskSize]; // for (int i = 0; i < tokenMaskSize; i++) { // tokenMask[i] = 0; // } // // Don't need to do anything if state is OPENSWITCH. // } // for (int i = 0; i < tokenCount; i++) { // if (firstSet[i]) { // if (!casedValues[i]) { // casedValues[i] = true; // retval += "\u0002\ncase "; // int j1 = i/32; // int j2 = i%32; // tokenMask[j1] |= 1 << j2; // String s = (String)(names_of_tokens.get(new Integer(i))); // if (s == null) { // retval += i; // } else { // retval += s; // } // retval += ":\u0001"; // } // } // } // retval += actions[index]; // retval += "\nbreak;"; // state = OPENSWITCH; // // } // // } else { // // This is the case when lookahead is determined through calls to // // jj2 methods. The other case is when lookahead is 1, but semantic // // attributes need to be evaluated. Hence this crazy control structure. // // jj2LA = true; // // } // // if (jj2LA) { // // In this case lookahead is determined by the jj2 methods. // // switch (state) { // case NOOPENSTM: // retval += "\n" + "if ("; // indentAmt++; // break; // case OPENIF: // retval += "\u0002\n" + "} else if ("; // break; // case OPENSWITCH: // retval += "\u0002\n" + "default:" + "\u0001"; // if (Options.getErrorReporting()) { // retval += "\njj_la1[" + maskindex + "] = jj_gen;"; // maskindex++; // } // maskVals.add(tokenMask); // retval += "\n" + "if ("; // indentAmt++; // } // jj2index++; // // At this point, la.la_expansion.internal_name must be "". // la.getLaExpansion().internal_name = "_" + jj2index; // phase2list.add(la); // retval += "jj_2" + la.getLaExpansion().internal_name + "(" + la.getAmount() + ")"; // if (la.getActionTokens().size() != 0) { // // In addition, there is also a semantic lookahead. So concatenate // // the semantic check with the syntactic one. // retval += " && ("; // printTokenSetup((Token)(la.getActionTokens().get(0))); // for (Iterator it = la.getActionTokens().iterator(); it.hasNext();) { // t = (Token)it.next(); // retval += printToken(t); // } // retval += printTrailingComments(t); // retval += ")"; // } // retval += ") {\u0001" + actions[index]; // state = OPENIF; // } // // index++; // } // // // Generate code for the default case. Note this may not // // be the last entry of "actions" if any condition can be // // statically determined to be always "true". // // switch (state) { // case NOOPENSTM: // retval += actions[index]; // break; // case OPENIF: // retval += "\u0002\n" + "} else {\u0001" + actions[index]; // break; // case OPENSWITCH: // retval += "\u0002\n" + "default:" + "\u0001"; // if (Options.getErrorReporting()) { // retval += "\njj_la1[" + maskindex + "] = jj_gen;"; // maskVals.add(tokenMask); // maskindex++; // } // retval += actions[index]; // } // for (int i = 0; i < indentAmt; i++) { // retval += "\u0002\n}"; // } // // return retval; // // The state variables. int state = NOOPENSTM; int indentAmt = 0; final boolean[] casedValues = new boolean[tokenCount]; final StringBuilder retval = new StringBuilder(1024); Lookahead la; Token t = null; final int tokenMaskSize = (tokenCount-1)/32 + 1; int[] tokenMask = null; // Iterate over all the conditions. int index = 0; while (index < conds.length) { la = conds[index]; jj2LA = false; if ((la.getAmount() == 0) || Semanticize.emptyExpansionExists(la.getLaExpansion()) || javaCodeCheck(la.getLaExpansion()) ) { // This handles the following cases: // . If syntactic lookahead is not wanted (and hence explicitly specified // as 0). // . If it is possible for the lookahead expansion to recognize the empty // string - in which case the lookahead trivially passes. // . If the lookahead expansion has a JAVACODE production that it directly // expands to - in which case the lookahead trivially passes. if (la.getActionTokens().size() == 0) { // In addition, if there is no semantic lookahead, then the // lookahead trivially succeeds. So break the main loop and // treat this case as the default last action. break; } else { // This case is when there is only semantic lookahead // (without any preceding syntactic lookahead). In this // case, an "if" statement is generated. switch (state) { case NOOPENSTM: retval.append("\n").append("if ("); indentAmt++; break; case OPENIF: retval.append("\u0002\n" + "} else if ("); break; case OPENSWITCH: retval.append("\u0002\n" + "default:" + "\u0001"); if (Options.getErrorReporting()) { retval.append("\njj_la1[").append(maskindex).append("] = jj_gen;"); maskindex++; } maskVals.add(tokenMask); retval.append("\n" + "if ("); indentAmt++; } printTokenSetup((la.getActionTokens().get(0))); for (final Iterator it = la.getActionTokens().iterator(); it.hasNext();) { t = it.next(); retval.append(printToken(t)); } retval.append(printTrailingComments(t)); retval.append(") {\u0001").append(actions[index]); state = OPENIF; } } else if (la.getAmount() == 1 && la.getActionTokens().size() == 0) { // Special optimal processing when the lookahead is exactly 1, and there // is no semantic lookahead. if (firstSet == null) { firstSet = new boolean[tokenCount]; } for (int i = 0; i < tokenCount; i++) { firstSet[i] = false; } // jj2LA is set to false at the beginning of the containing "if" statement. // It is checked immediately after the end of the same statement to determine // if lookaheads are to be performed using calls to the jj2 methods. genFirstSet(la.getLaExpansion()); // genFirstSet may find that semantic attributes are appropriate for the next // token. In which case, it sets jj2LA to true. if (!jj2LA) { // This case is if there is no applicable semantic lookahead and the lookahead // is one (excluding the earlier cases such as JAVACODE, etc.). switch (state) { case OPENIF: retval.append("\u0002\n" + "} else {\u0001"); // Control flows through to next case. case NOOPENSTM: retval.append("\n" + "switch ("); if (Options.getCacheTokens()) { retval.append("jj_nt.kind) {\u0001"); } else { retval.append("(jj_ntk==-1)?jj_ntk():jj_ntk) {\u0001"); } for (int i = 0; i < tokenCount; i++) { casedValues[i] = false; } indentAmt++; tokenMask = new int[tokenMaskSize]; for (int i = 0; i < tokenMaskSize; i++) { tokenMask[i] = 0; } // Don't need to do anything if state is OPENSWITCH. } for (int i = 0; i < tokenCount; i++) { if (firstSet[i]) { if (!casedValues[i]) { casedValues[i] = true; retval.append("\u0002\ncase "); final int j1 = i/32; final int j2 = i%32; tokenMask[j1] |= 1 << j2; final String s = (names_of_tokens.get(new Integer(i))); if (s == null) { retval.append(i); } else { retval.append(s); } retval.append(":\u0001"); } } } retval.append(actions[index]); retval.append("\nbreak;"); state = OPENSWITCH; } } else { // This is the case when lookahead is determined through calls to // jj2 methods. The other case is when lookahead is 1, but semantic // attributes need to be evaluated. Hence this crazy control structure. jj2LA = true; } if (jj2LA) { // In this case lookahead is determined by the jj2 methods. switch (state) { case NOOPENSTM: retval.append("\n" + "if ("); indentAmt++; break; case OPENIF: retval.append("\u0002\n" + "} else if ("); break; case OPENSWITCH: retval.append("\u0002\n" + "default:" + "\u0001"); if (Options.getErrorReporting()) { retval.append("\njj_la1[").append(maskindex).append("] = jj_gen;"); maskindex++; } maskVals.add(tokenMask); retval.append("\n" + "if ("); indentAmt++; } jj2index++; // At this point, la.la_expansion.internal_name must be "". la.getLaExpansion().internal_name = "_" + jj2index; phase2list.add(la); retval.append("jj_2").append(la.getLaExpansion().internal_name).append("(").append(la.getAmount() + ")"); if (la.getActionTokens().size() != 0) { // In addition, there is also a semantic lookahead. So concatenate // the semantic check with the syntactic one. retval.append(" && ("); printTokenSetup((la.getActionTokens().get(0))); for (final Iterator it = la.getActionTokens().iterator(); it.hasNext();) { t = it.next(); retval.append(printToken(t)); } retval.append(printTrailingComments(t)); retval.append(")"); } retval.append(") {\u0001").append(actions[index]); state = OPENIF; } index++; } // Generate code for the default case. Note this may not // be the last entry of "actions" if any condition can be // statically determined to be always "true". switch (state) { case NOOPENSTM: retval.append(actions[index]); break; case OPENIF: retval.append("\u0002\n" + "} else {\u0001").append(actions[index]); break; case OPENSWITCH: retval.append("\u0002\n" + "default:" + "\u0001"); if (Options.getErrorReporting()) { retval.append("\njj_la1[").append(maskindex).append("] = jj_gen;"); maskVals.add(tokenMask); maskindex++; } retval.append(actions[index]); } for (int i = 0; i < indentAmt; i++) { retval.append("\u0002\n}"); } return retval.toString(); } static void dumpFormattedString(final String str) { char ch = ' '; char prevChar; boolean indentOn = true; for (int i = 0; i < str.length(); i++) { prevChar = ch; ch = str.charAt(i); if (ch == '\n' && prevChar == '\r') { // do nothing - we've already printed a new line for the '\r' // during the previous iteration. } else if (ch == '\n' || ch == '\r') { if (indentOn) { phase1NewLine(); } else { ostr.println(""); } } else if (ch == '\u0001') { indentamt += 2; } else if (ch == '\u0002') { indentamt -= 2; } else if (ch == '\u0003') { indentOn = false; } else if (ch == '\u0004') { indentOn = true; } else { ostr.print(ch); } } } static void buildPhase1Routine(final BNFProduction_ p) { Token t; t = (p.getReturnTypeTokens().get(0)); boolean voidReturn = false; if (t.kind == JavaCCParserConstants.VOID) { voidReturn = true; } printTokenSetup(t); ccol = 1; printLeadingComments(t, ostr); ostr.print(" " + staticOpt() + "final " +(p.getAccessMod() != null ? p.getAccessMod() : "public")+ " "); cline = t.beginLine; ccol = t.beginColumn; printTokenOnly(t, ostr); for (int i = 1; i < p.getReturnTypeTokens().size(); i++) { t = (p.getReturnTypeTokens().get(i)); printToken(t, ostr); } printTrailingComments(t, ostr); ostr.print(" " + p.getLhs() + "("); if (p.getParameterListTokens().size() != 0) { printTokenSetup((p.getParameterListTokens().get(0))); for (final Iterator it = p.getParameterListTokens().iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } printTrailingComments(t, ostr); } ostr.print(") throws ParseException"); for (final Iterator> it = p.getThrowsList().iterator(); it.hasNext();) { ostr.print(", "); final List name = it.next(); for (final Iterator it2 = name.iterator(); it2.hasNext();) { t = it2.next(); ostr.print(t.image); } } ostr.print(" {"); indentamt = 4; if (Options.getDebugParser()) { ostr.println(""); ostr.println(" trace_call(\"" + p.getLhs() + "\");"); ostr.print(" try {"); indentamt = 6; } if (p.getDeclarationTokens().size() != 0) { printTokenSetup((p.getDeclarationTokens().get(0))); cline--; for (final Iterator it = p.getDeclarationTokens().iterator(); it.hasNext();) { t = it.next(); // ModMMa : added to fix indentation ostr.print(" "); printToken(t, ostr); } printTrailingComments(t, ostr); } final String code = phase1ExpansionGen(p.getExpansion()); dumpFormattedString(code); ostr.println(""); if (p.isJumpPatched() && !voidReturn) { ostr.println(" throw new Error(\"Missing return statement in function\");"); } if (Options.getDebugParser()) { ostr.println(" } finally {"); ostr.println(" trace_return(\"" + p.getLhs() + "\");"); ostr.println(" }"); } ostr.println(" }"); ostr.println(""); } static void phase1NewLine() { ostr.println(""); for (int i = 0; i < indentamt; i++) { ostr.print(" "); } } static String phase1ExpansionGen(final Expansion_ e) { String retval = ""; Token t = null; Lookahead[] conds; String[] actions; if (e instanceof RegularExpression_) { final RegularExpression_ e_nrw = (RegularExpression_)e; retval += "\n"; if (e_nrw.lhsTokens.size() != 0) { printTokenSetup((e_nrw.lhsTokens.get(0))); for (final Iterator it = e_nrw.lhsTokens.iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); retval += " = "; } final String tail = e_nrw.rhsToken == null ? ");" : ")." + e_nrw.rhsToken.image + ";"; if (e_nrw.label.equals("")) { final Object label = names_of_tokens.get(new Integer(e_nrw.ordinal)); if (label != null) { retval += "jj_consume_token(" + (String)label + tail; } else { retval += "jj_consume_token(" + e_nrw.ordinal + tail; } } else { retval += "jj_consume_token(" + e_nrw.label + tail; } } else if (e instanceof NonTerminal) { final NonTerminal e_nrw = (NonTerminal)e; retval += "\n"; if (e_nrw.getLhsTokens().size() != 0) { printTokenSetup((e_nrw.getLhsTokens().get(0))); for (final Iterator it = e_nrw.getLhsTokens().iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); retval += " = "; } retval += e_nrw.getName() + "("; if (e_nrw.getArgumentTokens().size() != 0) { printTokenSetup((e_nrw.getArgumentTokens().get(0))); for (final Iterator it = e_nrw.getArgumentTokens().iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); } retval += ");"; } else if (e instanceof Action) { final Action e_nrw = (Action)e; retval += "\u0003\n"; if (e_nrw.getActionTokens().size() != 0) { printTokenSetup((e_nrw.getActionTokens().get(0))); ccol = 1; for (final Iterator it = e_nrw.getActionTokens().iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); } retval += "\u0004"; } else if (e instanceof Choice) { final Choice e_nrw = (Choice)e; conds = new Lookahead[e_nrw.getChoices().size()]; actions = new String[e_nrw.getChoices().size() + 1]; actions[e_nrw.getChoices().size()] = "\n" + "jj_consume_token(-1);\n" + "throw new ParseException();"; // In previous line, the "throw" never throws an exception since the // evaluation of jj_consume_token(-1) causes ParseException to be // thrown first. Sequence nestedSeq; for (int i = 0; i < e_nrw.getChoices().size(); i++) { nestedSeq = (Sequence)(e_nrw.getChoices().get(i)); actions[i] = phase1ExpansionGen(nestedSeq); conds[i] = (Lookahead)(nestedSeq.units.get(0)); } retval = buildLookaheadChecker(conds, actions); } else if (e instanceof Sequence) { final Sequence e_nrw = (Sequence)e; // We skip the first element in the following iteration since it is the // Lookahead object. for (int i = 1; i < e_nrw.units.size(); i++) { retval += phase1ExpansionGen((e_nrw.units.get(i))); } } else if (e instanceof OneOrMore) { final OneOrMore e_nrw = (OneOrMore)e; final Expansion_ nested_e = e_nrw.expansion; Lookahead la; if (nested_e instanceof Sequence) { la = (Lookahead)(((Sequence)nested_e).units.get(0)); } else { la = new Lookahead(); la.setAmount(Options.getLookahead()); la.setLaExpansion(nested_e); } retval += "\n"; final int labelIndex = ++gensymindex; retval += "label_" + labelIndex + ":\n"; retval += "while (true) {\u0001"; retval += phase1ExpansionGen(nested_e); conds = new Lookahead[1]; conds[0] = la; actions = new String[2]; actions[0] = "\n;"; actions[1] = "\nbreak label_" + labelIndex + ";"; retval += buildLookaheadChecker(conds, actions); retval += "\u0002\n" + "}"; } else if (e instanceof ZeroOrMore) { final ZeroOrMore e_nrw = (ZeroOrMore)e; final Expansion_ nested_e = e_nrw.expansion; Lookahead la; if (nested_e instanceof Sequence) { la = (Lookahead)(((Sequence)nested_e).units.get(0)); } else { la = new Lookahead(); la.setAmount(Options.getLookahead()); la.setLaExpansion(nested_e); } retval += "\n"; final int labelIndex = ++gensymindex; retval += "label_" + labelIndex + ":\n"; retval += "while (true) {\u0001"; conds = new Lookahead[1]; conds[0] = la; actions = new String[2]; actions[0] = "\n;"; actions[1] = "\nbreak label_" + labelIndex + ";"; retval += buildLookaheadChecker(conds, actions); retval += phase1ExpansionGen(nested_e); retval += "\u0002\n" + "}"; } else if (e instanceof ZeroOrOne) { final ZeroOrOne e_nrw = (ZeroOrOne)e; final Expansion_ nested_e = e_nrw.expansion; Lookahead la; if (nested_e instanceof Sequence) { la = (Lookahead)(((Sequence)nested_e).units.get(0)); } else { la = new Lookahead(); la.setAmount(Options.getLookahead()); la.setLaExpansion(nested_e); } conds = new Lookahead[1]; conds[0] = la; actions = new String[2]; actions[0] = phase1ExpansionGen(nested_e); actions[1] = "\n;"; retval += buildLookaheadChecker(conds, actions); } else if (e instanceof TryBlock) { final TryBlock e_nrw = (TryBlock)e; final Expansion_ nested_e = e_nrw.exp; List list; retval += "\n"; retval += "try {\u0001"; retval += phase1ExpansionGen(nested_e); retval += "\u0002\n" + "}"; for (int i = 0; i < e_nrw.catchblks.size(); i++) { retval += " catch ("; list = (e_nrw.types.get(i)); if (list.size() != 0) { printTokenSetup((list.get(0))); for (final Iterator it = list.iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); } retval += " "; t = (e_nrw.ids.get(i)); printTokenSetup(t); retval += printToken(t); retval += printTrailingComments(t); retval += ") {\u0003\n"; list = (e_nrw.catchblks.get(i)); if (list.size() != 0) { printTokenSetup((list.get(0))); ccol = 1; for (final Iterator it = list.iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); } retval += "\u0004\n" + "}"; } if (e_nrw.finallyblk != null) { retval += " finally {\u0003\n"; if (e_nrw.finallyblk.size() != 0) { printTokenSetup((e_nrw.finallyblk.get(0))); ccol = 1; for (final Iterator it = e_nrw.finallyblk.iterator(); it.hasNext();) { t = it.next(); retval += printToken(t); } retval += printTrailingComments(t); } retval += "\u0004\n" + "}"; } } return retval; } static void buildPhase2Routine(final Lookahead la) { final Expansion_ e = la.getLaExpansion(); ostr.println(" " + staticOpt() + "private boolean jj_2" + e.internal_name + "(int xla) {"); ostr.println(" jj_la = xla; jj_lastpos = jj_scanpos = token;"); ostr.println(" try { return !jj_3" + e.internal_name + "(); }"); ostr.println(" catch(LookaheadSuccess ls) { return true; }"); if (Options.getErrorReporting()) ostr.println(" finally { jj_save(" + (Integer.parseInt(e.internal_name.substring(1))-1) + ", xla); }"); ostr.println(" }"); ostr.println(""); final Phase3Data p3d = new Phase3Data(e, la.getAmount()); phase3list.add(p3d); phase3table.put(e, p3d); } static private boolean xsp_declared; static Expansion_ jj3_expansion; static String genReturn(final boolean value) { final String retval = (value ? "true" : "false"); if (Options.getDebugLookahead() && jj3_expansion != null) { String tracecode = "trace_return(\"" + ((NormalProduction)jj3_expansion.parent).getLhs() + "(LOOKAHEAD " + (value ? "FAILED" : "SUCCEEDED") + ")\");"; if (Options.getErrorReporting()) { tracecode = "if (!jj_rescan) " + tracecode; } return "{ " + tracecode + " return " + retval + "; }"; } else { return "return " + retval + ";"; } } private static void generate3R(final Expansion_ e, final Phase3Data inf) { Expansion_ seq = e; if (e.internal_name.equals("")) { while (true) { if (seq instanceof Sequence && ((Sequence)seq).units.size() == 2) { seq = ((Sequence)seq).units.get(1); } else if (seq instanceof NonTerminal) { final NonTerminal e_nrw = (NonTerminal)seq; final NormalProduction ntprod = (production_table.get(e_nrw.getName())); if (ntprod instanceof JavaCodeProduction_) { break; // nothing to do here } else { seq = ntprod.getExpansion(); } } else break; } if (seq instanceof RegularExpression_) { e.internal_name = "jj_scan_token(" + ((RegularExpression_)seq).ordinal + ")"; return; } gensymindex++; // if (gensymindex == 100) // { // new Error().printStackTrace(); // System.out.println(" ***** seq: " + seq.internal_name + "; size: " + ((Sequence)seq).units.size()); // } e.internal_name = "R_" + gensymindex; } Phase3Data p3d = (phase3table.get(e)); if (p3d == null || p3d.count < inf.count) { p3d = new Phase3Data(e, inf.count); phase3list.add(p3d); phase3table.put(e, p3d); } } static void setupPhase3Builds(final Phase3Data inf) { final Expansion_ e = inf.exp; if (e instanceof RegularExpression_) { ; // nothing to here } else if (e instanceof NonTerminal) { // All expansions of non-terminals have the "name" fields set. So // there's no need to check it below for "e_nrw" and "ntexp". In // fact, we rely here on the fact that the "name" fields of both these // variables are the same. final NonTerminal e_nrw = (NonTerminal)e; final NormalProduction ntprod = (production_table.get(e_nrw.getName())); if (ntprod instanceof JavaCodeProduction_) { ; // nothing to do here } else { generate3R(ntprod.getExpansion(), inf); } } else if (e instanceof Choice) { final Choice e_nrw = (Choice)e; for (int i = 0; i < e_nrw.getChoices().size(); i++) { generate3R((e_nrw.getChoices().get(i)), inf); } } else if (e instanceof Sequence) { final Sequence e_nrw = (Sequence)e; // We skip the first element in the following iteration since it is the // Lookahead object. int cnt = inf.count; for (int i = 1; i < e_nrw.units.size(); i++) { final Expansion_ eseq = (e_nrw.units.get(i)); setupPhase3Builds(new Phase3Data(eseq, cnt)); cnt -= minimumSize(eseq); if (cnt <= 0) break; } } else if (e instanceof TryBlock) { final TryBlock e_nrw = (TryBlock)e; setupPhase3Builds(new Phase3Data(e_nrw.exp, inf.count)); } else if (e instanceof OneOrMore) { final OneOrMore e_nrw = (OneOrMore)e; generate3R(e_nrw.expansion, inf); } else if (e instanceof ZeroOrMore) { final ZeroOrMore e_nrw = (ZeroOrMore)e; generate3R(e_nrw.expansion, inf); } else if (e instanceof ZeroOrOne) { final ZeroOrOne e_nrw = (ZeroOrOne)e; generate3R(e_nrw.expansion, inf); } } private static String genjj_3Call(final Expansion_ e) { if (e.internal_name.startsWith("jj_scan_token")) return e.internal_name; else return "jj_3" + e.internal_name + "()"; } // static Hashtable generated = new Hashtable(); static void buildPhase3Routine(final Phase3Data inf, final boolean recursive_call) { final Expansion_ e = inf.exp; Token t = null; if (e.internal_name.startsWith("jj_scan_token")) return; if (!recursive_call) { ostr.println(" " + staticOpt() + "private boolean jj_3" + e.internal_name + "() {"); xsp_declared = false; if (Options.getDebugLookahead() && e.parent instanceof NormalProduction) { ostr.print(" "); if (Options.getErrorReporting()) { ostr.print("if (!jj_rescan) "); } ostr.println("trace_call(\"" + ((NormalProduction)e.parent).getLhs() + "(LOOKING AHEAD...)\");"); jj3_expansion = e; } else { jj3_expansion = null; } } if (e instanceof RegularExpression_) { final RegularExpression_ e_nrw = (RegularExpression_)e; if (e_nrw.label.equals("")) { final Object label = names_of_tokens.get(new Integer(e_nrw.ordinal)); if (label != null) { ostr.println(" if (jj_scan_token(" + (String)label + ")) " + genReturn(true)); } else { ostr.println(" if (jj_scan_token(" + e_nrw.ordinal + ")) " + genReturn(true)); } } else { ostr.println(" if (jj_scan_token(" + e_nrw.label + ")) " + genReturn(true)); } //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); } else if (e instanceof NonTerminal) { // All expansions of non-terminals have the "name" fields set. So // there's no need to check it below for "e_nrw" and "ntexp". In // fact, we rely here on the fact that the "name" fields of both these // variables are the same. final NonTerminal e_nrw = (NonTerminal)e; final NormalProduction ntprod = (production_table.get(e_nrw.getName())); if (ntprod instanceof JavaCodeProduction_) { ostr.println(" if (true) { jj_la = 0; jj_scanpos = jj_lastpos; " + genReturn(false) + "}"); } else { final Expansion_ ntexp = ntprod.getExpansion(); //ostr.println(" if (jj_3" + ntexp.internal_name + "()) " + genReturn(true)); ostr.println(" if (" + genjj_3Call(ntexp)+ ") " + genReturn(true)); //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); } } else if (e instanceof Choice) { Sequence nested_seq; final Choice e_nrw = (Choice)e; if (e_nrw.getChoices().size() != 1) { if (!xsp_declared) { xsp_declared = true; ostr.println(" Token xsp;"); } ostr.println(" xsp = jj_scanpos;"); } for (int i = 0; i < e_nrw.getChoices().size(); i++) { nested_seq = (Sequence)(e_nrw.getChoices().get(i)); final Lookahead la = (Lookahead)(nested_seq.units.get(0)); if (la.getActionTokens().size() != 0) { // We have semantic lookahead that must be evaluated. lookaheadNeeded = true; ostr.println(" jj_lookingAhead = true;"); ostr.print(" jj_semLA = "); printTokenSetup((la.getActionTokens().get(0))); for (final Iterator it = la.getActionTokens().iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } printTrailingComments(t, ostr); ostr.println(";"); ostr.println(" jj_lookingAhead = false;"); } ostr.print(" if ("); if (la.getActionTokens().size() != 0) { ostr.print("!jj_semLA || "); } if (i != e_nrw.getChoices().size() - 1) { //ostr.println("jj_3" + nested_seq.internal_name + "()) {"); ostr.println(genjj_3Call(nested_seq) + ") {"); ostr.println(" jj_scanpos = xsp;"); } else { //ostr.println("jj_3" + nested_seq.internal_name + "()) " + genReturn(true)); ostr.println(genjj_3Call(nested_seq) + ") " + genReturn(true)); //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); } } for (int i = 1; i < e_nrw.getChoices().size(); i++) { //ostr.println(" } else if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); ostr.println(" }"); } } else if (e instanceof Sequence) { final Sequence e_nrw = (Sequence)e; // We skip the first element in the following iteration since it is the // Lookahead object. int cnt = inf.count; for (int i = 1; i < e_nrw.units.size(); i++) { final Expansion_ eseq = (e_nrw.units.get(i)); buildPhase3Routine(new Phase3Data(eseq, cnt), true); // System.out.println("minimumSize: line: " + eseq.line + ", column: " + eseq.column + ": " + // minimumSize(eseq));//Test Code cnt -= minimumSize(eseq); if (cnt <= 0) break; } } else if (e instanceof TryBlock) { final TryBlock e_nrw = (TryBlock)e; buildPhase3Routine(new Phase3Data(e_nrw.exp, inf.count), true); } else if (e instanceof OneOrMore) { if (!xsp_declared) { xsp_declared = true; ostr.println(" Token xsp;"); } final OneOrMore e_nrw = (OneOrMore)e; final Expansion_ nested_e = e_nrw.expansion; //ostr.println(" if (jj_3" + nested_e.internal_name + "()) " + genReturn(true)); ostr.println(" if (" + genjj_3Call(nested_e) + ") " + genReturn(true)); //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); ostr.println(" while (true) {"); ostr.println(" xsp = jj_scanpos;"); //ostr.println(" if (jj_3" + nested_e.internal_name + "()) { jj_scanpos = xsp; break; }"); ostr.println(" if (" + genjj_3Call(nested_e) + ") { jj_scanpos = xsp; break; }"); //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); ostr.println(" }"); } else if (e instanceof ZeroOrMore) { if (!xsp_declared) { xsp_declared = true; ostr.println(" Token xsp;"); } final ZeroOrMore e_nrw = (ZeroOrMore)e; final Expansion_ nested_e = e_nrw.expansion; ostr.println(" while (true) {"); ostr.println(" xsp = jj_scanpos;"); //ostr.println(" if (jj_3" + nested_e.internal_name + "()) { jj_scanpos = xsp; break; }"); ostr.println(" if (" + genjj_3Call(nested_e) + ") { jj_scanpos = xsp; break; }"); //ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); ostr.println(" }"); } else if (e instanceof ZeroOrOne) { if (!xsp_declared) { xsp_declared = true; ostr.println(" Token xsp;"); } final ZeroOrOne e_nrw = (ZeroOrOne)e; final Expansion_ nested_e = e_nrw.expansion; ostr.println(" xsp = jj_scanpos;"); //ostr.println(" if (jj_3" + nested_e.internal_name + "()) jj_scanpos = xsp;"); ostr.println(" if (" + genjj_3Call(nested_e) + ") jj_scanpos = xsp;"); //ostr.println(" else if (jj_la == 0 && jj_scanpos == jj_lastpos) " + genReturn(false)); } if (!recursive_call) { ostr.println(" " + genReturn(false)); ostr.println(" }"); ostr.println(""); } } static int minimumSize(final Expansion_ e) { return minimumSize(e, Integer.MAX_VALUE); } /* * Returns the minimum number of tokens that can parse to this expansion. */ static int minimumSize(final Expansion_ e, final int oldMin) { int retval = 0; // should never be used. Will be bad if it is. if (e.inMinimumSize) { // recursive search for minimum size unnecessary. return Integer.MAX_VALUE; } e.inMinimumSize = true; if (e instanceof RegularExpression_) { retval = 1; } else if (e instanceof NonTerminal) { final NonTerminal e_nrw = (NonTerminal)e; final NormalProduction ntprod = (production_table.get(e_nrw.getName())); if (ntprod instanceof JavaCodeProduction_) { retval = Integer.MAX_VALUE; // Make caller think this is unending (for we do not go beyond JAVACODE during // phase3 execution). } else { final Expansion_ ntexp = ntprod.getExpansion(); retval = minimumSize(ntexp); } } else if (e instanceof Choice) { int min = oldMin; Expansion_ nested_e; final Choice e_nrw = (Choice)e; for (int i = 0; min > 1 && i < e_nrw.getChoices().size(); i++) { nested_e = (e_nrw.getChoices().get(i)); final int min1 = minimumSize(nested_e, min); if (min > min1) min = min1; } retval = min; } else if (e instanceof Sequence) { int min = 0; final Sequence e_nrw = (Sequence)e; // We skip the first element in the following iteration since it is the // Lookahead object. for (int i = 1; i < e_nrw.units.size(); i++) { final Expansion_ eseq = (e_nrw.units.get(i)); final int mineseq = minimumSize(eseq); if (min == Integer.MAX_VALUE || mineseq == Integer.MAX_VALUE) { min = Integer.MAX_VALUE; // Adding infinity to something results in infinity. } else { min += mineseq; if (min > oldMin) break; } } retval = min; } else if (e instanceof TryBlock) { final TryBlock e_nrw = (TryBlock)e; retval = minimumSize(e_nrw.exp); } else if (e instanceof OneOrMore) { final OneOrMore e_nrw = (OneOrMore)e; retval = minimumSize(e_nrw.expansion); } else if (e instanceof ZeroOrMore) { retval = 0; } else if (e instanceof ZeroOrOne) { retval = 0; } else if (e instanceof Lookahead) { retval = 0; } else if (e instanceof Action) { retval = 0; } e.inMinimumSize = false; return retval; } static void build(final java.io.PrintWriter ps) { NormalProduction p; JavaCodeProduction_ jp; Token t = null; ostr = ps; for (final Iterator prodIterator = bnfproductions.iterator(); prodIterator.hasNext();) { p = prodIterator.next(); if (p instanceof JavaCodeProduction_) { jp = (JavaCodeProduction_)p; t = (jp.getReturnTypeTokens().get(0)); printTokenSetup(t); ccol = 1; printLeadingComments(t, ostr); ostr.print(" " + staticOpt() + (p.getAccessMod() != null ? p.getAccessMod() + " " : "")); cline = t.beginLine; ccol = t.beginColumn; printTokenOnly(t, ostr); for (int i = 1; i < jp.getReturnTypeTokens().size(); i++) { t = (jp.getReturnTypeTokens().get(i)); printToken(t, ostr); } printTrailingComments(t, ostr); ostr.print(" " + jp.getLhs() + "("); if (jp.getParameterListTokens().size() != 0) { printTokenSetup((jp.getParameterListTokens().get(0))); for (final Iterator it = jp.getParameterListTokens().iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } printTrailingComments(t, ostr); } ostr.print(") throws ParseException"); for (final Iterator> it = jp.getThrowsList().iterator(); it.hasNext();) { ostr.print(", "); final List name = it.next(); for (final Iterator it2 = name.iterator(); it2.hasNext();) { t = it2.next(); ostr.print(t.image); } } ostr.print(" {"); if (Options.getDebugParser()) { ostr.println(""); ostr.println(" trace_call(\"" + jp.getLhs() + "\");"); ostr.print(" try {"); } if (jp.getCodeTokens().size() != 0) { printTokenSetup((jp.getCodeTokens().get(0))); cline--; printTokenList(jp.getCodeTokens(), ostr); } ostr.println(""); if (Options.getDebugParser()) { ostr.println(" } finally {"); ostr.println(" trace_return(\"" + jp.getLhs() + "\");"); ostr.println(" }"); } ostr.println(" }"); ostr.println(""); } else { buildPhase1Routine((BNFProduction_)p); } } for (int phase2index = 0; phase2index < phase2list.size(); phase2index++) { buildPhase2Routine((phase2list.get(phase2index))); } int phase3index = 0; while (phase3index < phase3list.size()) { for (; phase3index < phase3list.size(); phase3index++) { setupPhase3Builds((phase3list.get(phase3index))); } } for (final Enumeration enumeration = phase3table.elements(); enumeration.hasMoreElements();) { buildPhase3Routine((enumeration.nextElement()), false); } } public static void reInit() { ostr = null; gensymindex = 0; indentamt = 0; jj2LA = false; phase2list = new ArrayList(); phase3list = new ArrayList(); phase3table = new Hashtable(); firstSet = null; xsp_declared = false; jj3_expansion = null; } } /** * This class stores information to pass from phase 2 to phase 3. */ class Phase3Data { /* * This is the expansion to generate the jj3 method for. */ Expansion_ exp; /* * This is the number of tokens that can still be consumed. This * number is used to limit the number of jj3 methods generated. */ int count; Phase3Data(final Expansion_ e, final int c) { exp = e; count = c; } } jtb-1.4.4/EDU/purdue/jtb/parser/Expansion_.java0000644000175000017500000001330511360636752021074 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Set; /** * Describes expansions - entities that may occur on the * right hand sides of productions. This is the base class of * a bunch of other more specific classes. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Expansion_ { /** * The line and column number of the construct that corresponds * most closely to this node. */ private int line; private int column; /** * A reimplementing of Object.hashCode() to be deterministic. This uses * the line and column fields to generate an arbitrary number - we assume * that this method is called only after line and column are set to * their actual values. */ @Override public int hashCode() { return getLine() + getColumn(); } /** * An internal name for this expansion. This is used to generate parser * routines. */ String internal_name = ""; /** * The parser routines are generated in three phases. The generation * of the second and third phase are on demand only, and the third phase * can be recursive. This variable is used to keep track of the * expansions for which phase 3 generations have been already added to * a list so that the recursion can be terminated. */ boolean phase3done = false; /** * The parent of this expansion node. In case this is the top level * expansion of the production it is a reference to the production node * otherwise it is a reference to another Expansion node. In case this * is the top level of a lookahead expansion,then the parent is null. */ public Object parent; /** * The ordinal of this node with respect to its parent. */ int ordinal; /** * To avoid right-recursive loops when calculating follow sets, we use * a generation number which indicates if this expansion was visited * by LookaheadWalk.genFollowSet in the same generation. New generations * are obtained by incrementing the static counter below, and the current * generation is stored in the non-static variable below. */ public static long nextGenerationIndex = 1; public long myGeneration = 0; /** * This flag is used for bookkeeping by the minimumSize method in class * ParseEngine. */ public boolean inMinimumSize = false; public static void reInit() { nextGenerationIndex = 1; } private String getSimpleName() { final String name = getClass().getName(); return name.substring(name.lastIndexOf(".") + 1); // strip the package name } @Override public String toString() { return "[" + getLine() + "," + getColumn() + " " + System.identityHashCode(this) + " " + getSimpleName() + "]"; } protected static final String eol = System.getProperty("line.separator", "\n"); protected StringBuffer dumpPrefix(final int indent) { final StringBuffer sb = new StringBuffer(128); for (int i = 0; i < indent; i++) sb.append(" "); return sb; } public StringBuffer dump(final int indent, @SuppressWarnings("unused") final Set alreadyDumped) { final StringBuffer value = dumpPrefix(indent).append(System.identityHashCode(this)).append(" ") .append(getSimpleName()); return value; } /** * @param column the column to set */ final void setColumn(final int cl) { column = cl; } /** * @return the column */ final int getColumn() { return column; } /** * @param line the line to set */ final void setLine(final int ln) { line = ln; } /** * @return the line */ final int getLine() { return line; } // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker /** * Subclass type */ EXP_TYPE expType; /** * Subclasses enum type */ public enum EXP_TYPE {CHOICE, SEQUENCE, ONE_OR_MORE, ZERO_OR_MORE, ZERO_OR_ONE, LOOKAHEAD, TRY_BLOCK, R_CHOICE, R_SEQUENCE, R_ONE_OR_MORE, R_ZERO_OR_MORE, R_ZERO_OR_ONE, R_REPETITION_RANGE}; } jtb-1.4.4/EDU/purdue/jtb/parser/NfaState.java0000644000175000017500000026171211360636752020505 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; import java.util.Vector; /** * The state of a Non-deterministic Finite Automaton. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class NfaState { public static boolean unicodeWarningGiven = false; public static int generatedStates = 0; private static int idCnt = 0; private static int lohiByteCnt; private static int dummyStateIndex = -1; private static boolean done; private static boolean mark[]; private static boolean stateDone[]; private static List allStates = new ArrayList(); private static List indexedAllStates = new ArrayList(); private static List nonAsciiTableForMethod = new ArrayList(); private static Hashtable equivStatesTable = new Hashtable(); private static Hashtable allNextStates = new Hashtable(); private static Hashtable lohiByteTab = new Hashtable(); private static Hashtable stateNameForComposite = new Hashtable(); private static Hashtable compositeStateTable = new Hashtable(); private static Hashtable stateBlockTable = new Hashtable(); private static Hashtable stateSetsToFix = new Hashtable(); private static boolean jjCheckNAddStatesUnaryNeeded = false; private static boolean jjCheckNAddStatesDualNeeded = false; public static void ReInit() { generatedStates = 0; idCnt = 0; dummyStateIndex = -1; done = false; mark = null; stateDone = null; allStates.clear(); indexedAllStates.clear(); equivStatesTable.clear(); allNextStates.clear(); compositeStateTable.clear(); stateBlockTable.clear(); stateNameForComposite.clear(); stateSetsToFix.clear(); } long[] asciiMoves = new long[2]; char[] charMoves = null; private char[] rangeMoves = null; NfaState next = null; private NfaState stateForCase; Vector epsilonMoves = new Vector(); private String epsilonMovesString; private NfaState[] epsilonMoveArray; private final int id; int stateName = -1; int kind = Integer.MAX_VALUE; private int lookingFor; private int usefulEpsilonMoves = 0; int inNextOf; private int lexState; private int nonAsciiMethod = -1; private int kindToPrint = Integer.MAX_VALUE; boolean dummy = false; private boolean isComposite = false; private int[] compositeStates = null; boolean isFinal = false; private Vector loByteVec; private int[] nonAsciiMoveIndices; private int round = 0; private int onlyChar = 0; private char matchSingleChar; NfaState() { id = idCnt++; allStates.add(this); lexState = LexGen.lexStateIndex; lookingFor = LexGen.curKind; } NfaState CreateClone() { final NfaState retVal = new NfaState(); retVal.isFinal = isFinal; retVal.kind = kind; retVal.lookingFor = lookingFor; retVal.lexState = lexState; retVal.inNextOf = inNextOf; retVal.MergeMoves(this); return retVal; } static void InsertInOrder(final List v, final NfaState s) { int j; for (j = 0; j < v.size(); j++) if (v.get(j).id > s.id) break; else if (v.get(j).id == s.id) return; v.add(j, s); } private static char[] ExpandCharArr(final char[] oldArr, final int incr) { final char[] ret = new char[oldArr.length + incr]; System.arraycopy(oldArr, 0, ret, 0, oldArr.length); return ret; } void AddMove(final NfaState newState) { if (!epsilonMoves.contains(newState)) InsertInOrder(epsilonMoves, newState); } private final void AddASCIIMove(final char c) { asciiMoves[c / 64] |= (1L << (c % 64)); } void AddChar(final char c) { onlyChar++; matchSingleChar = c; int i; char temp; char temp1; if (c < 128) // ASCII char { AddASCIIMove(c); return; } if (charMoves == null) charMoves = new char[10]; int len = charMoves.length; if (charMoves[len - 1] != 0) { charMoves = ExpandCharArr(charMoves, 10); len += 10; } for (i = 0; i < len; i++) if (charMoves[i] == 0 || charMoves[i] > c) break; if (!unicodeWarningGiven && c > 0xff && !Options.getJavaUnicodeEscape() && !Options.getUserCharStream()) { unicodeWarningGiven = true; JavaCCErrors .warning( LexGen.curRE, "Non-ASCII characters used in regular expression.\n" + "Please make sure you use the correct Reader when you create the parser, " + "one that can handle your character set."); } temp = charMoves[i]; charMoves[i] = c; for (i++; i < len; i++) { if (temp == 0) break; temp1 = charMoves[i]; charMoves[i] = temp; temp = temp1; } } void AddRange(final char left, final char right) { char lft = left; onlyChar = 2; int i; char tempLeft1, tempLeft2, tempRight1, tempRight2; if (lft < 128) { if (right < 128) { for (; lft <= right; lft++) AddASCIIMove(lft); return; } for (; lft < 128; lft++) AddASCIIMove(lft); } if (!unicodeWarningGiven && (lft > 0xff || right > 0xff) && !Options.getJavaUnicodeEscape() && !Options.getUserCharStream()) { unicodeWarningGiven = true; JavaCCErrors .warning( LexGen.curRE, "Non-ASCII characters used in regular expression.\n" + "Please make sure you use the correct Reader when you create the parser, " + "one that can handle your character set."); } if (rangeMoves == null) rangeMoves = new char[20]; int len = rangeMoves.length; if (rangeMoves[len - 1] != 0) { rangeMoves = ExpandCharArr(rangeMoves, 20); len += 20; } for (i = 0; i < len; i += 2) if (rangeMoves[i] == 0 || (rangeMoves[i] > lft) || ((rangeMoves[i] == lft) && (rangeMoves[i + 1] > right))) break; tempLeft1 = rangeMoves[i]; tempRight1 = rangeMoves[i + 1]; rangeMoves[i] = lft; rangeMoves[i + 1] = right; for (i += 2; i < len; i += 2) { if (tempLeft1 == 0) break; tempLeft2 = rangeMoves[i]; tempRight2 = rangeMoves[i + 1]; rangeMoves[i] = tempLeft1; rangeMoves[i + 1] = tempRight1; tempLeft1 = tempLeft2; tempRight1 = tempRight2; } } // From hereon down all the functions are used for code generation private static boolean EqualCharArr(final char[] arr1, final char[] arr2) { if (arr1 == arr2) return true; if (arr1 != null && arr2 != null && arr1.length == arr2.length) { for (int i = arr1.length; i-- > 0;) if (arr1[i] != arr2[i]) return false; return true; } return false; } private boolean closureDone = false; /** This function computes the closure and also updates the kind so that * any time there is a move to this state, it can go on epsilon to a * new state in the epsilon moves that might have a lower kind of token * number for the same length. */ private void EpsilonClosure() { int i = 0; if (closureDone || mark[id]) return; mark[id] = true; // Recursively do closure for (i = 0; i < epsilonMoves.size(); i++) (epsilonMoves.get(i)).EpsilonClosure(); final Enumeration e = epsilonMoves.elements(); while (e.hasMoreElements()) { final NfaState tmp = e.nextElement(); for (i = 0; i < tmp.epsilonMoves.size(); i++) { final NfaState tmp1 = tmp.epsilonMoves.get(i); if (tmp1.UsefulState() && !epsilonMoves.contains(tmp1)) { InsertInOrder(epsilonMoves, tmp1); done = false; } } if (kind > tmp.kind) kind = tmp.kind; } if (HasTransitions() && !epsilonMoves.contains(this)) InsertInOrder(epsilonMoves, this); } private boolean UsefulState() { return isFinal || HasTransitions(); } public boolean HasTransitions() { return (asciiMoves[0] != 0L || asciiMoves[1] != 0L || (charMoves != null && charMoves[0] != 0) || (rangeMoves != null && rangeMoves[0] != 0)); } void MergeMoves(final NfaState other) { // Warning : This function does not merge epsilon moves if (asciiMoves == other.asciiMoves) { JavaCCErrors.semantic_error("Bug in JavaCC : Please send " + "a report along with the input that caused this. Thank you."); throw new Error(); } asciiMoves[0] = asciiMoves[0] | other.asciiMoves[0]; asciiMoves[1] = asciiMoves[1] | other.asciiMoves[1]; if (other.charMoves != null) { if (charMoves == null) charMoves = other.charMoves; else { final char[] tmpCharMoves = new char[charMoves.length + other.charMoves.length]; System.arraycopy(charMoves, 0, tmpCharMoves, 0, charMoves.length); charMoves = tmpCharMoves; for (int i = 0; i < other.charMoves.length; i++) AddChar(other.charMoves[i]); } } if (other.rangeMoves != null) { if (rangeMoves == null) rangeMoves = other.rangeMoves; else { final char[] tmpRangeMoves = new char[rangeMoves.length + other.rangeMoves.length]; System.arraycopy(rangeMoves, 0, tmpRangeMoves, 0, rangeMoves.length); rangeMoves = tmpRangeMoves; for (int i = 0; i < other.rangeMoves.length; i += 2) AddRange(other.rangeMoves[i], other.rangeMoves[i + 1]); } } if (other.kind < kind) kind = other.kind; if (other.kindToPrint < kindToPrint) kindToPrint = other.kindToPrint; isFinal |= other.isFinal; } NfaState CreateEquivState(final List states) { final NfaState newState = (states.get(0)).CreateClone(); newState.next = new NfaState(); InsertInOrder(newState.next.epsilonMoves, (states.get(0)).next); for (int i = 1; i < states.size(); i++) { final NfaState tmp2 = (states.get(i)); if (tmp2.kind < newState.kind) newState.kind = tmp2.kind; newState.isFinal |= tmp2.isFinal; InsertInOrder(newState.next.epsilonMoves, tmp2.next); } return newState; } private NfaState GetEquivalentRunTimeState() { Outer: for (int i = allStates.size(); i-- > 0;) { final NfaState other = allStates.get(i); if (this != other && other.stateName != -1 && kindToPrint == other.kindToPrint && asciiMoves[0] == other.asciiMoves[0] && asciiMoves[1] == other.asciiMoves[1] && EqualCharArr(charMoves, other.charMoves) && EqualCharArr(rangeMoves, other.rangeMoves)) { if (next == other.next) return other; else if (next != null && other.next != null) { if (next.epsilonMoves.size() == other.next.epsilonMoves.size()) { for (int j = 0; j < next.epsilonMoves.size(); j++) if (next.epsilonMoves.get(j) != other.next.epsilonMoves.get(j)) continue Outer; return other; } } } } return null; } // generates code (without outputting it) and returns the name used. void GenerateCode() { if (stateName != -1) return; if (next != null) { next.GenerateCode(); if (next.kind != Integer.MAX_VALUE) kindToPrint = next.kind; } if (stateName == -1 && HasTransitions()) { final NfaState tmp = GetEquivalentRunTimeState(); if (tmp != null) { stateName = tmp.stateName; //???? //tmp.inNextOf += inNextOf; //???? dummy = true; return; } stateName = generatedStates++; indexedAllStates.add(this); GenerateNextStatesCode(); } } public static void ComputeClosures() { for (int i = allStates.size(); i-- > 0;) { final NfaState tmp = allStates.get(i); if (!tmp.closureDone) tmp.OptimizeEpsilonMoves(true); } for (int i = 0; i < allStates.size(); i++) { final NfaState tmp = allStates.get(i); if (!tmp.closureDone) tmp.OptimizeEpsilonMoves(false); } for (int i = 0; i < allStates.size(); i++) { final NfaState tmp = allStates.get(i); tmp.epsilonMoveArray = new NfaState[tmp.epsilonMoves.size()]; tmp.epsilonMoves.copyInto(tmp.epsilonMoveArray); } } void OptimizeEpsilonMoves(final boolean optReqd) { // ModMMa : performance improvements (factoring) // int i; // // // First do epsilon closure // done = false; // while (!done) // { // if (mark == null || mark.length < allStates.size()) // mark = new boolean[allStates.size()]; // // for (i = allStates.size(); i-- > 0;) // mark[i] = false; // // done = true; // EpsilonClosure(); // } // // for (i = allStates.size(); i-- > 0;) // ((NfaState)allStates.get(i)).closureDone = // mark[((NfaState)allStates.get(i)).id]; // // // Warning : The following piece of code is just an optimization. // // in case of trouble, just remove this piece. // // boolean sometingOptimized = true; // // NfaState newState = null; // NfaState tmp1, tmp2; // int j; // List equivStates = null; // // while (sometingOptimized) // { // sometingOptimized = false; // for (i = 0; optReqd && i < epsilonMoves.size(); i++) // { // if ((tmp1 = (NfaState)epsilonMoves.get(i)).HasTransitions()) // { // for (j = i + 1; j < epsilonMoves.size(); j++) // { // if ((tmp2 = (NfaState)epsilonMoves.get(j)). // HasTransitions() && // (tmp1.asciiMoves[0] == tmp2.asciiMoves[0] && // tmp1.asciiMoves[1] == tmp2.asciiMoves[1] && // EqualCharArr(tmp1.charMoves, tmp2.charMoves) && // EqualCharArr(tmp1.rangeMoves, tmp2.rangeMoves))) // { // if (equivStates == null) // { // equivStates = new ArrayList(); // equivStates.add(tmp1); // } // // InsertInOrder(equivStates, tmp2); // epsilonMoves.removeElementAt(j--); // } // } // } // // if (equivStates != null) // { // sometingOptimized = true; // String tmp = ""; // for (int l = 0; l < equivStates.size(); l++) // tmp += String.valueOf( // ((NfaState)equivStates.get(l)).id) + ", "; // // if ((newState = (NfaState)equivStatesTable.get(tmp)) == null) // { // newState = CreateEquivState(equivStates); // equivStatesTable.put(tmp, newState); // } // // epsilonMoves.removeElementAt(i--); // epsilonMoves.add(newState); // equivStates = null; // newState = null; // } // } // // for (i = 0; i < epsilonMoves.size(); i++) // { // //if ((tmp1 = (NfaState)epsilonMoves.elementAt(i)).next == null) // //continue; // tmp1 = (NfaState)epsilonMoves.get(i); // // for (j = i + 1; j < epsilonMoves.size(); j++) // { // tmp2 = (NfaState)epsilonMoves.get(j); // // if (tmp1.next == tmp2.next) // { // if (newState == null) // { // newState = tmp1.CreateClone(); // newState.next = tmp1.next; // sometingOptimized = true; // } // // newState.MergeMoves(tmp2); // epsilonMoves.removeElementAt(j--); // } // } // // if (newState != null) // { // epsilonMoves.removeElementAt(i--); // epsilonMoves.add(newState); // newState = null; // } // } // } // // // End Warning // // // Generate an array of states for epsilon moves (not vector) // if (epsilonMoves.size() > 0) // { // for (i = 0; i < epsilonMoves.size(); i++) // // Since we are doing a closure, just epsilon moves are unncessary // if (((NfaState)epsilonMoves.get(i)).HasTransitions()) // usefulEpsilonMoves++; // else // epsilonMoves.removeElementAt(i--); // } int i; final int ass = allStates.size(); // First do epsilon closure done = false; while (!done) { if (mark == null || mark.length < ass) mark = new boolean[ass]; for (i = ass; i-- > 0;) mark[i] = false; done = true; EpsilonClosure(); } for (i = allStates.size(); i-- > 0;) (allStates.get(i)).closureDone = mark[(allStates.get(i)).id]; // Warning : The following piece of code is just an optimization. // in case of trouble, just remove this piece. boolean sometingOptimized = true; NfaState newState = null; NfaState tmp1, tmp2; int j; List equivStates = null; while (sometingOptimized) { sometingOptimized = false; for (i = 0; optReqd && i < epsilonMoves.size(); i++) { if ((tmp1 = epsilonMoves.get(i)).HasTransitions()) { for (j = i + 1; j < epsilonMoves.size(); j++) { if ((tmp2 = epsilonMoves.get(j)).HasTransitions() && (tmp1.asciiMoves[0] == tmp2.asciiMoves[0] && tmp1.asciiMoves[1] == tmp2.asciiMoves[1] && EqualCharArr(tmp1.charMoves, tmp2.charMoves) && EqualCharArr(tmp1.rangeMoves, tmp2.rangeMoves))) { if (equivStates == null) { equivStates = new ArrayList(); equivStates.add(tmp1); } InsertInOrder(equivStates, tmp2); epsilonMoves.removeElementAt(j--); } } } if (equivStates != null) { sometingOptimized = true; final int ess = equivStates.size(); final StringBuilder tmpsb = new StringBuilder(8 * ess); for (int l = 0; l < ess; l++) tmpsb.append(String.valueOf((equivStates.get(l)).id)).append(", "); final String tmp = tmpsb.toString(); if ((newState = equivStatesTable.get(tmp)) == null) { newState = CreateEquivState(equivStates); equivStatesTable.put(tmp, newState); } epsilonMoves.removeElementAt(i--); epsilonMoves.add(newState); equivStates = null; newState = null; } } for (i = 0; i < epsilonMoves.size(); i++) { //if ((tmp1 = (NfaState)epsilonMoves.elementAt(i)).next == null) //continue; tmp1 = epsilonMoves.get(i); for (j = i + 1; j < epsilonMoves.size(); j++) { tmp2 = epsilonMoves.get(j); if (tmp1.next == tmp2.next) { if (newState == null) { newState = tmp1.CreateClone(); newState.next = tmp1.next; sometingOptimized = true; } newState.MergeMoves(tmp2); epsilonMoves.removeElementAt(j--); } } if (newState != null) { epsilonMoves.removeElementAt(i--); epsilonMoves.add(newState); newState = null; } } } // End Warning // Generate an array of states for epsilon moves (not vector) if (epsilonMoves.size() > 0) { for (i = 0; i < epsilonMoves.size(); i++) // Since we are doing a closure, just epsilon moves are unncessary if ((epsilonMoves.get(i)).HasTransitions()) usefulEpsilonMoves++; else epsilonMoves.removeElementAt(i--); } } void GenerateNextStatesCode() { if (next.usefulEpsilonMoves > 0) next.GetEpsilonMovesString(); } String GetEpsilonMovesString() { final int[] stateNames = new int[usefulEpsilonMoves]; int cnt = 0; if (epsilonMovesString != null) return epsilonMovesString; if (usefulEpsilonMoves > 0) { NfaState tempState; epsilonMovesString = "{ "; for (int i = 0; i < epsilonMoves.size(); i++) { if ((tempState = epsilonMoves.get(i)).HasTransitions()) { if (tempState.stateName == -1) tempState.GenerateCode(); (indexedAllStates.get(tempState.stateName)).inNextOf++; stateNames[cnt] = tempState.stateName; epsilonMovesString += tempState.stateName + ", "; if (cnt++ > 0 && cnt % 16 == 0) epsilonMovesString += "\n"; } } epsilonMovesString += "};"; } usefulEpsilonMoves = cnt; if (epsilonMovesString != null && allNextStates.get(epsilonMovesString) == null) { final int[] statesToPut = new int[usefulEpsilonMoves]; System.arraycopy(stateNames, 0, statesToPut, 0, cnt); allNextStates.put(epsilonMovesString, statesToPut); } return epsilonMovesString; } public static boolean CanStartNfaUsingAscii(final char c) { if (c >= 128) throw new Error("JavaCC Bug: Please send mail to sankar@cs.stanford.edu"); final String s = LexGen.initialState.GetEpsilonMovesString(); if (s == null || s.equals("null;")) return false; final int[] states = allNextStates.get(s); for (int i = 0; i < states.length; i++) { final NfaState tmp = indexedAllStates.get(states[i]); if ((tmp.asciiMoves[c / 64] & (1L << c % 64)) != 0L) return true; } return false; } final boolean CanMoveUsingChar(final char c) { int i; if (onlyChar == 1) return c == matchSingleChar; if (c < 128) return ((asciiMoves[c / 64] & (1L << c % 64)) != 0L); // Just check directly if there is a move for this char if (charMoves != null && charMoves[0] != 0) { for (i = 0; i < charMoves.length; i++) { if (c == charMoves[i]) return true; else if (c < charMoves[i] || charMoves[i] == 0) break; } } // For ranges, iterate thru the table to see if the current char // is in some range if (rangeMoves != null && rangeMoves[0] != 0) for (i = 0; i < rangeMoves.length; i += 2) if (c >= rangeMoves[i] && c <= rangeMoves[i + 1]) return true; else if (c < rangeMoves[i] || rangeMoves[i] == 0) break; //return (nextForNegatedList != null); return false; } public int getFirstValidPos(final String s, final int j, final int len) { int i = j; if (onlyChar == 1) { final char c = matchSingleChar; while (c != s.charAt(i) && ++i < len) ; return i; } do { if (CanMoveUsingChar(s.charAt(i))) return i; } while (++i < len); return i; } public int MoveFrom(final char c, final List newStates) { if (CanMoveUsingChar(c)) { for (int i = next.epsilonMoves.size(); i-- > 0;) InsertInOrder(newStates, next.epsilonMoves.get(i)); return kindToPrint; } return Integer.MAX_VALUE; } public static int MoveFromSet(final char c, final List states, final List newStates) { int tmp; int retVal = Integer.MAX_VALUE; for (int i = states.size(); i-- > 0;) if (retVal > (tmp = (states.get(i)).MoveFrom(c, newStates))) retVal = tmp; return retVal; } public static int moveFromSetForRegEx(final char c, final NfaState[] states, final NfaState[] newStates, final int round) { int start = 0; final int sz = states.length; for (int i = 0; i < sz; i++) { NfaState tmp1, tmp2; if ((tmp1 = states[i]) == null) break; if (tmp1.CanMoveUsingChar(c)) { if (tmp1.kindToPrint != Integer.MAX_VALUE) { newStates[start] = null; return 1; } final NfaState[] v = tmp1.next.epsilonMoveArray; for (int j = v.length; j-- > 0;) { if ((tmp2 = v[j]).round != round) { tmp2.round = round; newStates[start++] = tmp2; } } } } newStates[start] = null; return Integer.MAX_VALUE; } static List allBitVectors = new ArrayList(); /* This function generates the bit vectors of low and hi bytes for common bit vectors and returns those that are not common with anything (in loBytes) and returns an array of indices that can be used to generate the function names for char matching using the common bit vectors. It also generates code to match a char with the common bit vectors. (Need a better comment). */ static int[] tmpIndices = new int[512]; // 2 * 256 void GenerateNonAsciiMoves(final java.io.PrintWriter ostr) { int i = 0, j = 0; char hiByte; int cnt = 0; final long[][] loBytes = new long[256][4]; if ((charMoves == null || charMoves[0] == 0) && (rangeMoves == null || rangeMoves[0] == 0)) return; if (charMoves != null) { for (i = 0; i < charMoves.length; i++) { if (charMoves[i] == 0) break; hiByte = (char) (charMoves[i] >> 8); loBytes[hiByte][(charMoves[i] & 0xff) / 64] |= (1L << ((charMoves[i] & 0xff) % 64)); } } if (rangeMoves != null) { for (i = 0; i < rangeMoves.length; i += 2) { if (rangeMoves[i] == 0) break; char c, r; r = (char) (rangeMoves[i + 1] & 0xff); hiByte = (char) (rangeMoves[i] >> 8); if (hiByte == (char) (rangeMoves[i + 1] >> 8)) { for (c = (char) (rangeMoves[i] & 0xff); c <= r; c++) loBytes[hiByte][c / 64] |= (1L << (c % 64)); continue; } for (c = (char) (rangeMoves[i] & 0xff); c <= 0xff; c++) loBytes[hiByte][c / 64] |= (1L << (c % 64)); while (++hiByte < (char) (rangeMoves[i + 1] >> 8)) { loBytes[hiByte][0] |= 0xffffffffffffffffL; loBytes[hiByte][1] |= 0xffffffffffffffffL; loBytes[hiByte][2] |= 0xffffffffffffffffL; loBytes[hiByte][3] |= 0xffffffffffffffffL; } for (c = 0; c <= r; c++) loBytes[hiByte][c / 64] |= (1L << (c % 64)); } } long[] common = null; final boolean[] fini = new boolean[256]; for (i = 0; i <= 255; i++) { if (fini[i] || (fini[i] = loBytes[i][0] == 0 && loBytes[i][1] == 0 && loBytes[i][2] == 0 && loBytes[i][3] == 0)) continue; for (j = i + 1; j < 256; j++) { if (fini[j]) continue; if (loBytes[i][0] == loBytes[j][0] && loBytes[i][1] == loBytes[j][1] && loBytes[i][2] == loBytes[j][2] && loBytes[i][3] == loBytes[j][3]) { fini[j] = true; if (common == null) { fini[i] = true; common = new long[4]; common[i / 64] |= (1L << (i % 64)); } common[j / 64] |= (1L << (j % 64)); } } if (common != null) { Integer ind; String tmp; tmp = "{\n 0x" + Long.toHexString(common[0]) + "L, " + "0x" + Long.toHexString(common[1]) + "L, " + "0x" + Long.toHexString(common[2]) + "L, " + "0x" + Long.toHexString(common[3]) + "L\n};"; if ((ind = lohiByteTab.get(tmp)) == null) { allBitVectors.add(tmp); if (!AllBitsSet(tmp)) ostr.println("static final long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } tmpIndices[cnt++] = ind.intValue(); tmp = "{\n 0x" + Long.toHexString(loBytes[i][0]) + "L, " + "0x" + Long.toHexString(loBytes[i][1]) + "L, " + "0x" + Long.toHexString(loBytes[i][2]) + "L, " + "0x" + Long.toHexString(loBytes[i][3]) + "L\n};"; if ((ind = lohiByteTab.get(tmp)) == null) { allBitVectors.add(tmp); if (!AllBitsSet(tmp)) ostr.println("static final long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } tmpIndices[cnt++] = ind.intValue(); common = null; } } nonAsciiMoveIndices = new int[cnt]; System.arraycopy(tmpIndices, 0, nonAsciiMoveIndices, 0, cnt); /* System.out.println("state : " + stateName + " cnt : " + cnt); while (cnt > 0) { System.out.print(nonAsciiMoveIndices[cnt - 1] + ", " + nonAsciiMoveIndices[cnt - 2] + ", "); cnt -= 2; } System.out.println(""); */ for (i = 0; i < 256; i++) { if (fini[i]) loBytes[i] = null; else { //System.out.print(i + ", "); String tmp; Integer ind; tmp = "{\n 0x" + Long.toHexString(loBytes[i][0]) + "L, " + "0x" + Long.toHexString(loBytes[i][1]) + "L, " + "0x" + Long.toHexString(loBytes[i][2]) + "L, " + "0x" + Long.toHexString(loBytes[i][3]) + "L\n};"; if ((ind = lohiByteTab.get(tmp)) == null) { allBitVectors.add(tmp); if (!AllBitsSet(tmp)) ostr.println("static final long[] jjbitVec" + lohiByteCnt + " = " + tmp); lohiByteTab.put(tmp, ind = new Integer(lohiByteCnt++)); } if (loByteVec == null) loByteVec = new Vector(); loByteVec.add(new Integer(i)); loByteVec.add(ind); } } //System.out.println(""); UpdateDuplicateNonAsciiMoves(); } private void UpdateDuplicateNonAsciiMoves() { for (int i = 0; i < nonAsciiTableForMethod.size(); i++) { final NfaState tmp = nonAsciiTableForMethod.get(i); if (EqualLoByteVectors(loByteVec, tmp.loByteVec) && EqualNonAsciiMoveIndices(nonAsciiMoveIndices, tmp.nonAsciiMoveIndices)) { nonAsciiMethod = i; return; } } nonAsciiMethod = nonAsciiTableForMethod.size(); nonAsciiTableForMethod.add(this); } private static boolean EqualLoByteVectors(final List vec1, final List vec2) { if (vec1 == null || vec2 == null) return false; if (vec1 == vec2) return true; if (vec1.size() != vec2.size()) return false; for (int i = 0; i < vec1.size(); i++) { if ((vec1.get(i)).intValue() != (vec2.get(i)).intValue()) return false; } return true; } private static boolean EqualNonAsciiMoveIndices(final int[] moves1, final int[] moves2) { if (moves1 == moves2) return true; if (moves1 == null || moves2 == null) return false; if (moves1.length != moves2.length) return false; for (int i = 0; i < moves1.length; i++) { if (moves1[i] != moves2[i]) return false; } return true; } static String allBits = "{\n 0xffffffffffffffffL, " + "0xffffffffffffffffL, " + "0xffffffffffffffffL, " + "0xffffffffffffffffL\n};"; static boolean AllBitsSet(final String bitVec) { return bitVec.equals(allBits); } static int AddStartStateSet(final String stateSetString) { return AddCompositeStateSet(stateSetString, true); } private static int AddCompositeStateSet(final String stateSetString, final boolean starts) { Integer stateNameToReturn; if ((stateNameToReturn = stateNameForComposite.get(stateSetString)) != null) return stateNameToReturn.intValue(); int toRet = 0; final int[] nameSet = allNextStates.get(stateSetString); if (!starts) stateBlockTable.put(stateSetString, stateSetString); if (nameSet == null) throw new Error( "JavaCC Bug: Please send mail to sankar@cs.stanford.edu; nameSet null for : " + stateSetString); if (nameSet.length == 1) { stateNameToReturn = new Integer(nameSet[0]); stateNameForComposite.put(stateSetString, stateNameToReturn); return nameSet[0]; } for (int i = 0; i < nameSet.length; i++) { if (nameSet[i] == -1) continue; final NfaState st = indexedAllStates.get(nameSet[i]); st.isComposite = true; st.compositeStates = nameSet; } while (toRet < nameSet.length && (starts && (indexedAllStates.get(nameSet[toRet])).inNextOf > 1)) toRet++; final Enumeration e = compositeStateTable.keys(); String s; while (e.hasMoreElements()) { s = e.nextElement(); if (!s.equals(stateSetString) && Intersect(stateSetString, s)) { final int[] other = compositeStateTable.get(s); while (toRet < nameSet.length && ((starts && (indexedAllStates.get(nameSet[toRet])).inNextOf > 1) || ElemOccurs( nameSet[toRet], other) >= 0)) toRet++; } } int tmp; if (toRet >= nameSet.length) { if (dummyStateIndex == -1) tmp = dummyStateIndex = generatedStates; else tmp = ++dummyStateIndex; } else tmp = nameSet[toRet]; stateNameToReturn = new Integer(tmp); stateNameForComposite.put(stateSetString, stateNameToReturn); compositeStateTable.put(stateSetString, nameSet); return tmp; } private static int StateNameForComposite(final String stateSetString) { return (stateNameForComposite.get(stateSetString)).intValue(); } static int InitStateName() { final String s = LexGen.initialState.GetEpsilonMovesString(); if (LexGen.initialState.usefulEpsilonMoves != 0) return StateNameForComposite(s); return -1; } // public void GenerateInitMoves(final java.io.PrintWriter ostr) { public void GenerateInitMoves() { GetEpsilonMovesString(); if (epsilonMovesString == null) epsilonMovesString = "null;"; AddStartStateSet(epsilonMovesString); } static Hashtable tableToDump = new Hashtable(); static List orderedStateSet = new ArrayList(); static int lastIndex = 0; private static int[] GetStateSetIndicesForUse(final String arrayString) { int[] ret; final int[] set = allNextStates.get(arrayString); if ((ret = tableToDump.get(arrayString)) == null) { ret = new int[2]; ret[0] = lastIndex; ret[1] = lastIndex + set.length - 1; lastIndex += set.length; tableToDump.put(arrayString, ret); orderedStateSet.add(set); } return ret; } public static void DumpStateSets(final java.io.PrintWriter ostr) { int cnt = 0; ostr.print("static final int[] jjnextStates = {"); for (int i = 0; i < orderedStateSet.size(); i++) { final int[] set = orderedStateSet.get(i); for (int j = 0; j < set.length; j++) { if (cnt++ % 16 == 0) ostr.print("\n "); ostr.print(set[j] + ", "); } } ostr.println("\n};"); } static String GetStateSetString(final int[] states) { String retVal = "{ "; for (int i = 0; i < states.length;) { retVal += states[i] + ", "; if (i++ > 0 && i % 16 == 0) retVal += "\n"; } retVal += "};"; allNextStates.put(retVal, states); return retVal; } static String GetStateSetString(final List states) { if (states == null || states.size() == 0) return "null;"; final int[] set = new int[states.size()]; String retVal = "{ "; for (int i = 0; i < states.size();) { int k; retVal += (k = (states.get(i)).stateName) + ", "; set[i] = k; if (i++ > 0 && i % 16 == 0) retVal += "\n"; } retVal += "};"; allNextStates.put(retVal, set); return retVal; } static int NumberOfBitsSet(final long l) { int ret = 0; for (int i = 0; i < 63; i++) if (((l >> i) & 1L) != 0L) ret++; return ret; } static int OnlyOneBitSet(final long l) { int oneSeen = -1; for (int i = 0; i < 64; i++) if (((l >> i) & 1L) != 0L) { if (oneSeen >= 0) return -1; oneSeen = i; } return oneSeen; } private static int ElemOccurs(final int elem, final int[] arr) { for (int i = arr.length; i-- > 0;) if (arr[i] == elem) return i; return -1; } @SuppressWarnings("unused") private boolean FindCommonBlocks() { if (next == null || next.usefulEpsilonMoves <= 1) return false; if (stateDone == null) stateDone = new boolean[generatedStates]; final String set = next.epsilonMovesString; final int[] nameSet = allNextStates.get(set); if (nameSet.length <= 2 || compositeStateTable.get(set) != null) return false; int i; final int freq[] = new int[nameSet.length]; final boolean live[] = new boolean[nameSet.length]; final int[] count = new int[allNextStates.size()]; for (i = 0; i < nameSet.length; i++) { if (nameSet[i] != -1) { live[i] = !stateDone[nameSet[i]]; if (live[i]) count[0]++; } } int j, blockLen = 0, commonFreq = 0; Enumeration e = allNextStates.keys(); boolean needUpdate; while (e.hasMoreElements()) { final int[] tmpSet = allNextStates.get(e.nextElement()); if (tmpSet == nameSet) continue; needUpdate = false; for (j = 0; j < nameSet.length; j++) { if (nameSet[j] == -1) continue; if (live[j] && ElemOccurs(nameSet[j], tmpSet) >= 0) { if (!needUpdate) { needUpdate = true; commonFreq++; } count[freq[j]]--; count[commonFreq]++; freq[j] = commonFreq; } } if (needUpdate) { int foundFreq = -1; blockLen = 0; for (j = 0; j <= commonFreq; j++) if (count[j] > blockLen) { foundFreq = j; blockLen = count[j]; } if (blockLen <= 1) return false; for (j = 0; j < nameSet.length; j++) if (nameSet[j] != -1 && freq[j] != foundFreq) { live[j] = false; count[freq[j]]--; } } } if (blockLen <= 1) return false; final int[] commonBlock = new int[blockLen]; int cnt = 0; //System.out.println("Common Block for " + set + " :"); for (i = 0; i < nameSet.length; i++) { if (live[i]) { if ((indexedAllStates.get(nameSet[i])).isComposite) return false; stateDone[nameSet[i]] = true; commonBlock[cnt++] = nameSet[i]; //System.out.print(nameSet[i] + ", "); } } //System.out.println(""); final String s = GetStateSetString(commonBlock); e = allNextStates.keys(); Outer: while (e.hasMoreElements()) { int at; boolean firstOne = true; String stringToFix; final int[] setToFix = allNextStates.get(stringToFix = e.nextElement()); if (setToFix == commonBlock) continue; for (int k = 0; k < cnt; k++) { if ((at = ElemOccurs(commonBlock[k], setToFix)) >= 0) { if (!firstOne) setToFix[at] = -1; firstOne = false; } else continue Outer; } if (stateSetsToFix.get(stringToFix) == null) stateSetsToFix.put(stringToFix, setToFix); } next.usefulEpsilonMoves -= blockLen - 1; AddCompositeStateSet(s, false); return true; } @SuppressWarnings("unused") private boolean CheckNextOccursTogether() { if (next == null || next.usefulEpsilonMoves <= 1) return true; final String set = next.epsilonMovesString; final int[] nameSet = allNextStates.get(set); if (nameSet.length == 1 || compositeStateTable.get(set) != null || stateSetsToFix.get(set) != null) return false; int i; final Hashtable occursIn = new Hashtable(); final NfaState tmp = allStates.get(nameSet[0]); for (i = 1; i < nameSet.length; i++) { final NfaState tmp1 = allStates.get(nameSet[i]); if (tmp.inNextOf != tmp1.inNextOf) return false; } int isPresent, j; Enumeration e = allNextStates.keys(); while (e.hasMoreElements()) { String s; final int[] tmpSet = allNextStates.get(s = e.nextElement()); if (tmpSet == nameSet) continue; isPresent = 0; for (j = 0; j < nameSet.length; j++) { if (ElemOccurs(nameSet[j], tmpSet) >= 0) isPresent++; else if (isPresent > 0) return false; } if (isPresent == j) { if (tmpSet.length > nameSet.length) occursIn.put(s, tmpSet); //May not need. But safe. if (compositeStateTable.get(s) != null || stateSetsToFix.get(s) != null) return false; } else if (isPresent != 0) return false; } e = occursIn.keys(); while (e.hasMoreElements()) { String s; final int[] setToFix = occursIn.get(s = e.nextElement()); if (stateSetsToFix.get(s) == null) stateSetsToFix.put(s, setToFix); for (int k = 0; k < setToFix.length; k++) if (ElemOccurs(setToFix[k], nameSet) > 0) // Not >= since need the first one (0) setToFix[k] = -1; } next.usefulEpsilonMoves = 1; AddCompositeStateSet(next.epsilonMovesString, false); return true; } private static void FixStateSets() { final Hashtable fixedSets = new Hashtable(); final Enumeration e = stateSetsToFix.keys(); final int[] tmp = new int[generatedStates]; int i; while (e.hasMoreElements()) { String s; final int[] toFix = stateSetsToFix.get(s = e.nextElement()); int cnt = 0; //System.out.print("Fixing : "); for (i = 0; i < toFix.length; i++) { //System.out.print(toFix[i] + ", "); if (toFix[i] != -1) tmp[cnt++] = toFix[i]; } final int[] fixed = new int[cnt]; System.arraycopy(tmp, 0, fixed, 0, cnt); fixedSets.put(s, fixed); allNextStates.put(s, fixed); //System.out.println(" as " + GetStateSetString(fixed)); } for (i = 0; i < allStates.size(); i++) { final NfaState tmpState = allStates.get(i); int[] newSet; if (tmpState.next == null || tmpState.next.usefulEpsilonMoves == 0) continue; /*if (compositeStateTable.get(tmpState.next.epsilonMovesString) != null) tmpState.next.usefulEpsilonMoves = 1; else*/if ((newSet = fixedSets.get(tmpState.next.epsilonMovesString)) != null) tmpState.FixNextStates(newSet); } } private final void FixNextStates(final int[] newSet) { next.usefulEpsilonMoves = newSet.length; //next.epsilonMovesString = GetStateSetString(newSet); } private static boolean Intersect(final String set1, final String set2) { if (set1 == null || set2 == null) return false; final int[] nameSet1 = allNextStates.get(set1); final int[] nameSet2 = allNextStates.get(set2); if (nameSet1 == null || nameSet2 == null) return false; if (nameSet1 == nameSet2) return true; for (int i = nameSet1.length; i-- > 0;) for (int j = nameSet2.length; j-- > 0;) if (nameSet1[i] == nameSet2[j]) return true; return false; } private static void DumpHeadForCase(final java.io.PrintWriter ostr, final int byteNum) { if (byteNum == 0) ostr.println(" long l = 1L << curChar;"); else if (byteNum == 1) ostr.println(" long l = 1L << (curChar & 077);"); else { if (Options.getJavaUnicodeEscape() || unicodeWarningGiven) { ostr.println(" int hiByte = (curChar >> 8);"); ostr.println(" int i1 = hiByte >> 6;"); ostr.println(" long l1 = 1L << (hiByte & 077);"); } ostr.println(" int i2 = (curChar & 0xff) >> 6;"); ostr.println(" long l2 = 1L << (curChar & 077);"); } //ostr.println(" MatchLoop: do"); ostr.println(" do"); ostr.println(" {"); ostr.println(" switch(jjstateSet[--i])"); ostr.println(" {"); } private static Vector> PartitionStatesSetForAscii(final int[] states, final int byteNum) { final int[] cardinalities = new int[states.length]; final Vector original = new Vector(); final Vector> partition = new Vector>(); NfaState tmp; original.setSize(states.length); int cnt = 0; for (int i = 0; i < states.length; i++) { tmp = allStates.get(states[i]); if (tmp.asciiMoves[byteNum] != 0L) { int j; final int p = NumberOfBitsSet(tmp.asciiMoves[byteNum]); for (j = 0; j < i; j++) if (cardinalities[j] <= p) break; for (int k = i; k > j; k--) cardinalities[k] = cardinalities[k - 1]; cardinalities[j] = p; original.insertElementAt(tmp, j); cnt++; } } original.setSize(cnt); while (original.size() > 0) { tmp = original.get(0); original.removeElement(tmp); long bitVec = tmp.asciiMoves[byteNum]; final List subSet = new ArrayList(); subSet.add(tmp); for (int j = 0; j < original.size(); j++) { final NfaState tmp1 = original.get(j); if ((tmp1.asciiMoves[byteNum] & bitVec) == 0L) { bitVec |= tmp1.asciiMoves[byteNum]; subSet.add(tmp1); original.removeElementAt(j--); } } partition.add(subSet); } return partition; } private String PrintNoBreak(final java.io.PrintWriter ostr, final int byteNum, final boolean[] dumped) { if (inNextOf != 1) throw new Error("JavaCC Bug: Please send mail to sankar@cs.stanford.edu"); dumped[stateName] = true; if (byteNum >= 0) { if (asciiMoves[byteNum] != 0L) { ostr.println(" case " + stateName + ":"); DumpAsciiMoveForCompositeState(ostr, byteNum, false); return ""; } } else if (nonAsciiMethod != -1) { ostr.println(" case " + stateName + ":"); DumpNonAsciiMoveForCompositeState(ostr); return ""; } return (" case " + stateName + ":\n"); } private static void DumpCompositeStatesAsciiMoves(final java.io.PrintWriter ostr, final String key, final int byteNum, final boolean[] dumped) { int i; final int[] nameSet = allNextStates.get(key); if (nameSet.length == 1 || dumped[StateNameForComposite(key)]) return; NfaState toBePrinted = null; int neededStates = 0; NfaState tmp; NfaState stateForCase = null; String toPrint = ""; final boolean stateBlock = (stateBlockTable.get(key) != null); for (i = 0; i < nameSet.length; i++) { tmp = allStates.get(nameSet[i]); if (tmp.asciiMoves[byteNum] != 0L) { if (neededStates++ == 1) break; else toBePrinted = tmp; } else dumped[tmp.stateName] = true; if (tmp.stateForCase != null) { if (stateForCase != null) throw new Error("JavaCC Bug: Please send mail to sankar@cs.stanford.edu : "); stateForCase = tmp.stateForCase; } } if (stateForCase != null) toPrint = stateForCase.PrintNoBreak(ostr, byteNum, dumped); if (neededStates == 0) { if (stateForCase != null && toPrint.equals("")) ostr.println(" break;"); return; } if (neededStates == 1) { //if (byteNum == 1) //System.out.println(toBePrinted.stateName + " is the only state for " //+ key + " ; and key is : " + StateNameForComposite(key)); if (!toPrint.equals("")) ostr.print(toPrint); ostr.println(" case " + StateNameForComposite(key) + ":"); if (!dumped[toBePrinted.stateName] && !stateBlock && toBePrinted.inNextOf > 1) ostr.println(" case " + toBePrinted.stateName + ":"); dumped[toBePrinted.stateName] = true; toBePrinted.DumpAsciiMove(ostr, byteNum, dumped); return; } final List> partition = PartitionStatesSetForAscii(nameSet, byteNum); if (!toPrint.equals("")) ostr.print(toPrint); final int keyState = StateNameForComposite(key); ostr.println(" case " + keyState + ":"); if (keyState < generatedStates) dumped[keyState] = true; for (i = 0; i < partition.size(); i++) { final List subSet = partition.get(i); for (int j = 0; j < subSet.size(); j++) { tmp = subSet.get(j); if (stateBlock) dumped[tmp.stateName] = true; tmp.DumpAsciiMoveForCompositeState(ostr, byteNum, j != 0); } } if (stateBlock) ostr.println(" break;"); else ostr.println(" break;"); } private boolean selfLoop() { if (next == null || next.epsilonMovesString == null) return false; final int[] set = allNextStates.get(next.epsilonMovesString); return ElemOccurs(stateName, set) >= 0; } private void DumpAsciiMoveForCompositeState(final java.io.PrintWriter ostr, final int byteNum, final boolean elseNeeded) { boolean nextIntersects = selfLoop(); for (int j = 0; j < allStates.size(); j++) { final NfaState temp1 = allStates.get(j); if (this == temp1 || temp1.stateName == -1 || temp1.dummy || stateName == temp1.stateName || temp1.asciiMoves[byteNum] == 0L) continue; if (!nextIntersects && Intersect(temp1.next.epsilonMovesString, next.epsilonMovesString)) { nextIntersects = true; break; } } //System.out.println(stateName + " \'s nextIntersects : " + nextIntersects); String prefix = ""; if (asciiMoves[byteNum] != 0xffffffffffffffffL) { final int oneBit = OnlyOneBitSet(asciiMoves[byteNum]); if (oneBit != -1) ostr.println(" " + (elseNeeded ? "else " : "") + "if (curChar == " + (64 * byteNum + oneBit) + ")"); else ostr.println(" " + (elseNeeded ? "else " : "") + "if ((0x" + Long.toHexString(asciiMoves[byteNum]) + "L & l) != 0L)"); prefix = " "; } if (kindToPrint != Integer.MAX_VALUE) { if (asciiMoves[byteNum] != 0xffffffffffffffffL) { ostr.println(" {"); } ostr.println(prefix + " if (kind > " + kindToPrint + ")"); ostr.println(prefix + " kind = " + kindToPrint + ";"); } if (next != null && next.usefulEpsilonMoves > 0) { final int[] stateNames = allNextStates.get(next.epsilonMovesString); if (next.usefulEpsilonMoves == 1) { final int name = stateNames[0]; if (nextIntersects) ostr.println(prefix + " jjCheckNAdd(" + name + ");"); else ostr.println(prefix + " jjstateSet[jjnewStateCnt++] = " + name + ";"); } else if (next.usefulEpsilonMoves == 2 && nextIntersects) { ostr.println(prefix + " jjCheckNAddTwoStates(" + stateNames[0] + ", " + stateNames[1] + ");"); } else { final int[] indices = GetStateSetIndicesForUse(next.epsilonMovesString); final boolean notTwo = (indices[0] + 1 != indices[1]); if (nextIntersects) { ostr.print(prefix + " jjCheckNAddStates(" + indices[0]); if (notTwo) { jjCheckNAddStatesDualNeeded = true; ostr.print(", " + indices[1]); } else { jjCheckNAddStatesUnaryNeeded = true; } ostr.println(");"); } else ostr.println(prefix + " jjAddStates(" + indices[0] + ", " + indices[1] + ");"); } } if (asciiMoves[byteNum] != 0xffffffffffffffffL && kindToPrint != Integer.MAX_VALUE) ostr.println(" }"); } private void DumpAsciiMove(final java.io.PrintWriter ostr, final int byteNum, final boolean dumped[]) { boolean nextIntersects = selfLoop() && isComposite; boolean onlyState = true; for (int j = 0; j < allStates.size(); j++) { final NfaState temp1 = allStates.get(j); if (this == temp1 || temp1.stateName == -1 || temp1.dummy || stateName == temp1.stateName || temp1.asciiMoves[byteNum] == 0L) continue; if (onlyState && (asciiMoves[byteNum] & temp1.asciiMoves[byteNum]) != 0L) onlyState = false; if (!nextIntersects && Intersect(temp1.next.epsilonMovesString, next.epsilonMovesString)) nextIntersects = true; if (!dumped[temp1.stateName] && !temp1.isComposite && asciiMoves[byteNum] == temp1.asciiMoves[byteNum] && kindToPrint == temp1.kindToPrint && (next.epsilonMovesString == temp1.next.epsilonMovesString || (next.epsilonMovesString != null && temp1.next.epsilonMovesString != null && next.epsilonMovesString .equals(temp1.next.epsilonMovesString)))) { dumped[temp1.stateName] = true; ostr.println(" case " + temp1.stateName + ":"); } } //if (onlyState) //nextIntersects = false; final int oneBit = OnlyOneBitSet(asciiMoves[byteNum]); if (asciiMoves[byteNum] != 0xffffffffffffffffL) { if ((next == null || next.usefulEpsilonMoves == 0) && kindToPrint != Integer.MAX_VALUE) { String kindCheck = ""; if (!onlyState) kindCheck = " && kind > " + kindToPrint; if (oneBit != -1) ostr.println(" if (curChar == " + (64 * byteNum + oneBit) + kindCheck + ")"); else ostr.println(" if ((0x" + Long.toHexString(asciiMoves[byteNum]) + "L & l) != 0L" + kindCheck + ")"); ostr.println(" kind = " + kindToPrint + ";"); if (onlyState) ostr.println(" break;"); else ostr.println(" break;"); return; } } String prefix = ""; if (kindToPrint != Integer.MAX_VALUE) { if (oneBit != -1) { ostr.println(" if (curChar != " + (64 * byteNum + oneBit) + ")"); ostr.println(" break;"); } else if (asciiMoves[byteNum] != 0xffffffffffffffffL) { ostr.println(" if ((0x" + Long.toHexString(asciiMoves[byteNum]) + "L & l) == 0L)"); ostr.println(" break;"); } if (onlyState) { ostr.println(" kind = " + kindToPrint + ";"); } else { ostr.println(" if (kind > " + kindToPrint + ")"); ostr.println(" kind = " + kindToPrint + ";"); } } else { if (oneBit != -1) { ostr.println(" if (curChar == " + (64 * byteNum + oneBit) + ")"); prefix = " "; } else if (asciiMoves[byteNum] != 0xffffffffffffffffL) { ostr.println(" if ((0x" + Long.toHexString(asciiMoves[byteNum]) + "L & l) != 0L)"); prefix = " "; } } if (next != null && next.usefulEpsilonMoves > 0) { final int[] stateNames = allNextStates.get(next.epsilonMovesString); if (next.usefulEpsilonMoves == 1) { final int name = stateNames[0]; if (nextIntersects) ostr.println(prefix + " jjCheckNAdd(" + name + ");"); else ostr.println(prefix + " jjstateSet[jjnewStateCnt++] = " + name + ";"); } else if (next.usefulEpsilonMoves == 2 && nextIntersects) { ostr.println(prefix + " jjCheckNAddTwoStates(" + stateNames[0] + ", " + stateNames[1] + ");"); } else { final int[] indices = GetStateSetIndicesForUse(next.epsilonMovesString); final boolean notTwo = (indices[0] + 1 != indices[1]); if (nextIntersects) { ostr.print(prefix + " jjCheckNAddStates(" + indices[0]); if (notTwo) { jjCheckNAddStatesDualNeeded = true; ostr.print(", " + indices[1]); } else { jjCheckNAddStatesUnaryNeeded = true; } ostr.println(");"); } else ostr.println(prefix + " jjAddStates(" + indices[0] + ", " + indices[1] + ");"); } } if (onlyState) ostr.println(" break;"); else ostr.println(" break;"); } private static void DumpAsciiMoves(final java.io.PrintWriter ostr, final int byteNum) { final boolean[] dumped = new boolean[Math.max(generatedStates, dummyStateIndex + 1)]; final Enumeration e = compositeStateTable.keys(); DumpHeadForCase(ostr, byteNum); while (e.hasMoreElements()) DumpCompositeStatesAsciiMoves(ostr, e.nextElement(), byteNum, dumped); for (int i = 0; i < allStates.size(); i++) { final NfaState temp = allStates.get(i); if (dumped[temp.stateName] || temp.lexState != LexGen.lexStateIndex || !temp.HasTransitions() || temp.dummy || temp.stateName == -1) continue; String toPrint = ""; if (temp.stateForCase != null) { if (temp.inNextOf == 1) continue; if (dumped[temp.stateForCase.stateName]) continue; toPrint = (temp.stateForCase.PrintNoBreak(ostr, byteNum, dumped)); if (temp.asciiMoves[byteNum] == 0L) { if (toPrint.equals("")) ostr.println(" break;"); continue; } } if (temp.asciiMoves[byteNum] == 0L) continue; if (!toPrint.equals("")) ostr.print(toPrint); dumped[temp.stateName] = true; ostr.println(" case " + temp.stateName + ":"); temp.DumpAsciiMove(ostr, byteNum, dumped); } ostr.println(" default : break;"); ostr.println(" }"); ostr.println(" } while(i != startsAt);"); } private static void DumpCompositeStatesNonAsciiMoves(final java.io.PrintWriter ostr, final String key, final boolean[] dumped) { int i; final int[] nameSet = allNextStates.get(key); if (nameSet.length == 1 || dumped[StateNameForComposite(key)]) return; NfaState toBePrinted = null; int neededStates = 0; NfaState tmp; NfaState stateForCase = null; String toPrint = ""; final boolean stateBlock = (stateBlockTable.get(key) != null); for (i = 0; i < nameSet.length; i++) { tmp = allStates.get(nameSet[i]); if (tmp.nonAsciiMethod != -1) { if (neededStates++ == 1) break; else toBePrinted = tmp; } else dumped[tmp.stateName] = true; if (tmp.stateForCase != null) { if (stateForCase != null) throw new Error("JavaCC Bug: Please send mail to sankar@cs.stanford.edu : "); stateForCase = tmp.stateForCase; } } if (stateForCase != null) toPrint = stateForCase.PrintNoBreak(ostr, -1, dumped); if (neededStates == 0) { if (stateForCase != null && toPrint.equals("")) ostr.println(" break;"); return; } if (neededStates == 1) { if (!toPrint.equals("")) ostr.print(toPrint); ostr.println(" case " + StateNameForComposite(key) + ":"); if (!dumped[toBePrinted.stateName] && !stateBlock && toBePrinted.inNextOf > 1) ostr.println(" case " + toBePrinted.stateName + ":"); dumped[toBePrinted.stateName] = true; toBePrinted.DumpNonAsciiMove(ostr, dumped); return; } if (!toPrint.equals("")) ostr.print(toPrint); final int keyState = StateNameForComposite(key); ostr.println(" case " + keyState + ":"); if (keyState < generatedStates) dumped[keyState] = true; for (i = 0; i < nameSet.length; i++) { tmp = allStates.get(nameSet[i]); if (tmp.nonAsciiMethod != -1) { if (stateBlock) dumped[tmp.stateName] = true; tmp.DumpNonAsciiMoveForCompositeState(ostr); } } if (stateBlock) ostr.println(" break;"); else ostr.println(" break;"); } private final void DumpNonAsciiMoveForCompositeState(final java.io.PrintWriter ostr) { boolean nextIntersects = selfLoop(); for (int j = 0; j < allStates.size(); j++) { final NfaState temp1 = allStates.get(j); if (this == temp1 || temp1.stateName == -1 || temp1.dummy || stateName == temp1.stateName || (temp1.nonAsciiMethod == -1)) continue; if (!nextIntersects && Intersect(temp1.next.epsilonMovesString, next.epsilonMovesString)) { nextIntersects = true; break; } } if (!Options.getJavaUnicodeEscape() && !unicodeWarningGiven) { if (loByteVec != null && loByteVec.size() > 1) ostr.println(" if ((jjbitVec" + loByteVec.get(1).intValue() + "[i2" + "] & l2) != 0L)"); } else { ostr.println(" if (jjCanMove_" + nonAsciiMethod + "(hiByte, i1, i2, l1, l2))"); } if (kindToPrint != Integer.MAX_VALUE) { ostr.println(" {"); ostr.println(" if (kind > " + kindToPrint + ")"); ostr.println(" kind = " + kindToPrint + ";"); } if (next != null && next.usefulEpsilonMoves > 0) { final int[] stateNames = allNextStates.get(next.epsilonMovesString); if (next.usefulEpsilonMoves == 1) { final int name = stateNames[0]; if (nextIntersects) ostr.println(" jjCheckNAdd(" + name + ");"); else ostr.println(" jjstateSet[jjnewStateCnt++] = " + name + ";"); } else if (next.usefulEpsilonMoves == 2 && nextIntersects) { ostr.println(" jjCheckNAddTwoStates(" + stateNames[0] + ", " + stateNames[1] + ");"); } else { final int[] indices = GetStateSetIndicesForUse(next.epsilonMovesString); final boolean notTwo = (indices[0] + 1 != indices[1]); if (nextIntersects) { ostr.print(" jjCheckNAddStates(" + indices[0]); if (notTwo) { jjCheckNAddStatesDualNeeded = true; ostr.print(", " + indices[1]); } else { jjCheckNAddStatesUnaryNeeded = true; } ostr.println(");"); } else ostr.println(" jjAddStates(" + indices[0] + ", " + indices[1] + ");"); } } if (kindToPrint != Integer.MAX_VALUE) ostr.println(" }"); } private final void DumpNonAsciiMove(final java.io.PrintWriter ostr, final boolean dumped[]) { boolean nextIntersects = selfLoop() && isComposite; for (int j = 0; j < allStates.size(); j++) { final NfaState temp1 = allStates.get(j); if (this == temp1 || temp1.stateName == -1 || temp1.dummy || stateName == temp1.stateName || (temp1.nonAsciiMethod == -1)) continue; if (!nextIntersects && Intersect(temp1.next.epsilonMovesString, next.epsilonMovesString)) nextIntersects = true; if (!dumped[temp1.stateName] && !temp1.isComposite && nonAsciiMethod == temp1.nonAsciiMethod && kindToPrint == temp1.kindToPrint && (next.epsilonMovesString == temp1.next.epsilonMovesString || (next.epsilonMovesString != null && temp1.next.epsilonMovesString != null && next.epsilonMovesString .equals(temp1.next.epsilonMovesString)))) { dumped[temp1.stateName] = true; ostr.println(" case " + temp1.stateName + ":"); } } if (next == null || next.usefulEpsilonMoves <= 0) { final String kindCheck = " && kind > " + kindToPrint; if (!Options.getJavaUnicodeEscape() && !unicodeWarningGiven) { if (loByteVec != null && loByteVec.size() > 1) ostr.println(" if ((jjbitVec" + loByteVec.get(1).intValue() + "[i2" + "] & l2) != 0L" + kindCheck + ")"); } else { ostr.println(" if (jjCanMove_" + nonAsciiMethod + "(hiByte, i1, i2, l1, l2)" + kindCheck + ")"); } ostr.println(" kind = " + kindToPrint + ";"); ostr.println(" break;"); return; } String prefix = " "; if (kindToPrint != Integer.MAX_VALUE) { if (!Options.getJavaUnicodeEscape() && !unicodeWarningGiven) { if (loByteVec != null && loByteVec.size() > 1) { ostr.println(" if ((jjbitVec" + loByteVec.get(1).intValue() + "[i2" + "] & l2) == 0L)"); ostr.println(" break;"); } } else { ostr.println(" if (!jjCanMove_" + nonAsciiMethod + "(hiByte, i1, i2, l1, l2))"); ostr.println(" break;"); } ostr.println(" if (kind > " + kindToPrint + ")"); ostr.println(" kind = " + kindToPrint + ";"); prefix = ""; } else if (!Options.getJavaUnicodeEscape() && !unicodeWarningGiven) { if (loByteVec != null && loByteVec.size() > 1) ostr.println(" if ((jjbitVec" + loByteVec.get(1).intValue() + "[i2" + "] & l2) != 0L)"); } else { ostr.println(" if (jjCanMove_" + nonAsciiMethod + "(hiByte, i1, i2, l1, l2))"); } if (next != null && next.usefulEpsilonMoves > 0) { final int[] stateNames = allNextStates.get(next.epsilonMovesString); if (next.usefulEpsilonMoves == 1) { final int name = stateNames[0]; if (nextIntersects) ostr.println(prefix + " jjCheckNAdd(" + name + ");"); else ostr.println(prefix + " jjstateSet[jjnewStateCnt++] = " + name + ";"); } else if (next.usefulEpsilonMoves == 2 && nextIntersects) { ostr.println(prefix + " jjCheckNAddTwoStates(" + stateNames[0] + ", " + stateNames[1] + ");"); } else { final int[] indices = GetStateSetIndicesForUse(next.epsilonMovesString); final boolean notTwo = (indices[0] + 1 != indices[1]); if (nextIntersects) { ostr.print(prefix + " jjCheckNAddStates(" + indices[0]); if (notTwo) { jjCheckNAddStatesDualNeeded = true; ostr.print(", " + indices[1]); } else { jjCheckNAddStatesUnaryNeeded = true; } ostr.println(");"); } else ostr.println(prefix + " jjAddStates(" + indices[0] + ", " + indices[1] + ");"); } } ostr.println(" break;"); } public static void DumpCharAndRangeMoves(final java.io.PrintWriter ostr) { final boolean[] dumped = new boolean[Math.max(generatedStates, dummyStateIndex + 1)]; final Enumeration e = compositeStateTable.keys(); int i; DumpHeadForCase(ostr, -1); while (e.hasMoreElements()) DumpCompositeStatesNonAsciiMoves(ostr, e.nextElement(), dumped); for (i = 0; i < allStates.size(); i++) { final NfaState temp = allStates.get(i); if (temp.stateName == -1 || dumped[temp.stateName] || temp.lexState != LexGen.lexStateIndex || !temp.HasTransitions() || temp.dummy) continue; String toPrint = ""; if (temp.stateForCase != null) { if (temp.inNextOf == 1) continue; if (dumped[temp.stateForCase.stateName]) continue; toPrint = (temp.stateForCase.PrintNoBreak(ostr, -1, dumped)); if (temp.nonAsciiMethod == -1) { if (toPrint.equals("")) ostr.println(" break;"); continue; } } if (temp.nonAsciiMethod == -1) continue; if (!toPrint.equals("")) ostr.print(toPrint); dumped[temp.stateName] = true; //System.out.println("case : " + temp.stateName); ostr.println(" case " + temp.stateName + ":"); temp.DumpNonAsciiMove(ostr, dumped); } ostr.println(" default : break;"); ostr.println(" }"); ostr.println(" } while(i != startsAt);"); } public static void DumpNonAsciiMoveMethods(final java.io.PrintWriter ostr) { if (!Options.getJavaUnicodeEscape() && !unicodeWarningGiven) return; if (nonAsciiTableForMethod.size() <= 0) return; for (int i = 0; i < nonAsciiTableForMethod.size(); i++) { final NfaState tmp = nonAsciiTableForMethod.get(i); tmp.DumpNonAsciiMoveMethod(ostr); } } void DumpNonAsciiMoveMethod(final java.io.PrintWriter ostr) { int j; ostr.println("private static final boolean jjCanMove_" + nonAsciiMethod + "(int hiByte, int i1, int i2, long l1, long l2)"); ostr.println("{"); ostr.println(" switch(hiByte)"); ostr.println(" {"); if (loByteVec != null && loByteVec.size() > 0) { for (j = 0; j < loByteVec.size(); j += 2) { ostr.println(" case " + loByteVec.get(j).intValue() + ":"); if (!AllBitsSet(allBitVectors.get(loByteVec.get(j + 1).intValue()))) { ostr.println(" return ((jjbitVec" + loByteVec.get(j + 1).intValue() + "[i2" + "] & l2) != 0L);"); } else ostr.println(" return true;"); } } ostr.println(" default :"); if (nonAsciiMoveIndices != null && (j = nonAsciiMoveIndices.length) > 0) { do { if (!AllBitsSet(allBitVectors.get(nonAsciiMoveIndices[j - 2]))) ostr.println(" if ((jjbitVec" + nonAsciiMoveIndices[j - 2] + "[i1] & l1) != 0L)"); if (!AllBitsSet(allBitVectors.get(nonAsciiMoveIndices[j - 1]))) { ostr.println(" if ((jjbitVec" + nonAsciiMoveIndices[j - 1] + "[i2] & l2) == 0L)"); ostr.println(" return false;"); ostr.println(" else"); } ostr.println(" return true;"); } while ((j -= 2) > 0); } ostr.println(" return false;"); ostr.println(" }"); ostr.println("}"); } private static void ReArrange() { final List v = allStates; // ModMMa : modified to get rid of warning // allStates = new ArrayList(Collections.nCopies(generatedStates, null)); final List l = Collections.nCopies(generatedStates, null); allStates = new ArrayList(l); if (allStates.size() != generatedStates) throw new Error("What??"); for (int j = 0; j < v.size(); j++) { final NfaState tmp = v.get(j); if (tmp.stateName != -1 && !tmp.dummy) allStates.set(tmp.stateName, tmp); } } //private static boolean boilerPlateDumped = false; static void PrintBoilerPlate(final java.io.PrintWriter ostr) { ostr.println((Options.getStatic() ? "static " : "") + "private void " + "jjCheckNAdd(int state)"); ostr.println("{"); ostr.println(" if (jjrounds[state] != jjround)"); ostr.println(" {"); ostr.println(" jjstateSet[jjnewStateCnt++] = state;"); ostr.println(" jjrounds[state] = jjround;"); ostr.println(" }"); ostr.println("}"); ostr.println((Options.getStatic() ? "static " : "") + "private void " + "jjAddStates(int start, int end)"); ostr.println("{"); ostr.println(" do {"); ostr.println(" jjstateSet[jjnewStateCnt++] = jjnextStates[start];"); ostr.println(" } while (start++ != end);"); ostr.println("}"); ostr.println((Options.getStatic() ? "static " : "") + "private void " + "jjCheckNAddTwoStates(int state1, int state2)"); ostr.println("{"); ostr.println(" jjCheckNAdd(state1);"); ostr.println(" jjCheckNAdd(state2);"); ostr.println("}"); ostr.println(""); if (jjCheckNAddStatesDualNeeded) { ostr.println((Options.getStatic() ? "static " : "") + "private void " + "jjCheckNAddStates(int start, int end)"); ostr.println("{"); ostr.println(" do {"); ostr.println(" jjCheckNAdd(jjnextStates[start]);"); ostr.println(" } while (start++ != end);"); ostr.println("}"); ostr.println(""); } if (jjCheckNAddStatesUnaryNeeded) { ostr.println((Options.getStatic() ? "static " : "") + "private void " + "jjCheckNAddStates(int start)"); ostr.println("{"); ostr.println(" jjCheckNAdd(jjnextStates[start]);"); ostr.println(" jjCheckNAdd(jjnextStates[start + 1]);"); ostr.println("}"); ostr.println(""); } } @SuppressWarnings("unused") private static void FindStatesWithNoBreak() { final Hashtable printed = new Hashtable(); final boolean[] put = new boolean[generatedStates]; int cnt = 0; int i, j, foundAt = 0; Outer: for (j = 0; j < allStates.size(); j++) { NfaState stateForCase = null; final NfaState tmpState = allStates.get(j); if (tmpState.stateName == -1 || tmpState.dummy || !tmpState.UsefulState() || tmpState.next == null || tmpState.next.usefulEpsilonMoves < 1) continue; final String s = tmpState.next.epsilonMovesString; if (compositeStateTable.get(s) != null || printed.get(s) != null) continue; printed.put(s, s); final int[] nexts = allNextStates.get(s); if (nexts.length == 1) continue; int state = cnt; //System.out.println("State " + tmpState.stateName + " : " + s); for (i = 0; i < nexts.length; i++) { if ((state = nexts[i]) == -1) continue; final NfaState tmp = allStates.get(state); if (!tmp.isComposite && tmp.inNextOf == 1) { if (put[state]) throw new Error("JavaCC Bug: Please send mail to sankar@cs.stanford.edu"); foundAt = i; cnt++; stateForCase = tmp; put[state] = true; //System.out.print(state + " : " + tmp.inNextOf + ", "); break; } } //System.out.println(""); if (stateForCase == null) continue; for (i = 0; i < nexts.length; i++) { if ((state = nexts[i]) == -1) continue; final NfaState tmp = allStates.get(state); if (!put[state] && tmp.inNextOf > 1 && !tmp.isComposite && tmp.stateForCase == null) { cnt++; nexts[i] = -1; put[state] = true; final int toSwap = nexts[0]; nexts[0] = nexts[foundAt]; nexts[foundAt] = toSwap; tmp.stateForCase = stateForCase; stateForCase.stateForCase = tmp; stateSetsToFix.put(s, nexts); //System.out.println("For : " + s + "; " + stateForCase.stateName + //" and " + tmp.stateName); continue Outer; } } for (i = 0; i < nexts.length; i++) { if ((state = nexts[i]) == -1) continue; final NfaState tmp = allStates.get(state); if (tmp.inNextOf <= 1) put[state] = false; } } } static int[][] kinds; static int[][][] statesForState; public static void DumpMoveNfa(final java.io.PrintWriter ostr) { //if (!boilerPlateDumped) // PrintBoilerPlate(ostr); //boilerPlateDumped = true; int i; int[] kindsForStates = null; if (kinds == null) { kinds = new int[LexGen.maxLexStates][]; statesForState = new int[LexGen.maxLexStates][][]; } ReArrange(); for (i = 0; i < allStates.size(); i++) { final NfaState temp = allStates.get(i); if (temp.lexState != LexGen.lexStateIndex || !temp.HasTransitions() || temp.dummy || temp.stateName == -1) continue; if (kindsForStates == null) { kindsForStates = new int[generatedStates]; statesForState[LexGen.lexStateIndex] = new int[Math.max(generatedStates, dummyStateIndex + 1)][]; } kindsForStates[temp.stateName] = temp.lookingFor; statesForState[LexGen.lexStateIndex][temp.stateName] = temp.compositeStates; temp.GenerateNonAsciiMoves(ostr); } final Enumeration e = stateNameForComposite.keys(); while (e.hasMoreElements()) { final String s = e.nextElement(); final int state = stateNameForComposite.get(s).intValue(); if (state >= generatedStates) statesForState[LexGen.lexStateIndex][state] = allNextStates.get(s); } if (stateSetsToFix.size() != 0) FixStateSets(); kinds[LexGen.lexStateIndex] = kindsForStates; ostr.println((Options.getStatic() ? "static " : "") + "private int " + "jjMoveNfa" + LexGen.lexStateSuffix + "(int startState, int curPos)"); ostr.println("{"); if (generatedStates == 0) { ostr.println(" return curPos;"); ostr.println("}"); return; } if (LexGen.mixed[LexGen.lexStateIndex]) { ostr.println(" int strKind = jjmatchedKind;"); ostr.println(" int strPos = jjmatchedPos;"); ostr.println(" int seenUpto;"); ostr.println(" input_stream.backup(seenUpto = curPos + 1);"); ostr.println(" try { curChar = input_stream.readChar(); }"); ostr.println(" catch(java.io.IOException e) { throw new Error(\"Internal Error\"); }"); ostr.println(" curPos = 0;"); } ostr.println(" int startsAt = 0;"); ostr.println(" jjnewStateCnt = " + generatedStates + ";"); ostr.println(" int i = 1;"); ostr.println(" jjstateSet[0] = startState;"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\" Starting NFA to match one of : \" + " + "jjKindsForStateVector(curLexState, jjstateSet, 0, 1));"); if (Options.getDebugTokenManager()) ostr .println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(" int kind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); ostr.println(" for (;;)"); ostr.println(" {"); ostr.println(" if (++jjround == 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr.println(" ReInitRounds();"); ostr.println(" if (curChar < 64)"); ostr.println(" {"); DumpAsciiMoves(ostr, 0); ostr.println(" }"); ostr.println(" else if (curChar < 128)"); ostr.println(" {"); DumpAsciiMoves(ostr, 1); ostr.println(" }"); ostr.println(" else"); ostr.println(" {"); DumpCharAndRangeMoves(ostr); ostr.println(" }"); ostr.println(" if (kind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr.println(" {"); ostr.println(" jjmatchedKind = kind;"); ostr.println(" jjmatchedPos = curPos;"); ostr.println(" kind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); ostr.println(" }"); ostr.println(" ++curPos;"); if (Options.getDebugTokenManager()) { ostr.println(" if (jjmatchedKind != 0 && jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr.println(" debugStream.println(" + "\" Currently matched the first \" + (jjmatchedPos + 1) + \" characters as" + " a \" + tokenImage[jjmatchedKind] + \" token.\");"); } ostr.println(" if ((i = jjnewStateCnt) == (startsAt = " + generatedStates + " - (jjnewStateCnt = startsAt)))"); if (LexGen.mixed[LexGen.lexStateIndex]) ostr.println(" break;"); else ostr.println(" return curPos;"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\" Possible kinds of longer matches : \" + " + "jjKindsForStateVector(curLexState, jjstateSet, startsAt, i));"); ostr.println(" try { curChar = input_stream.readChar(); }"); if (LexGen.mixed[LexGen.lexStateIndex]) ostr.println(" catch(java.io.IOException e) { break; }"); else ostr.println(" catch(java.io.IOException e) { return curPos; }"); if (Options.getDebugTokenManager()) ostr .println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(" }"); if (LexGen.mixed[LexGen.lexStateIndex]) { ostr.println(" if (jjmatchedPos > strPos)"); ostr.println(" return curPos;"); ostr.println(""); ostr.println(" int toRet = Math.max(curPos, seenUpto);"); ostr.println(""); ostr.println(" if (curPos < toRet)"); ostr.println(" for (i = toRet - Math.min(curPos, seenUpto); i-- > 0; )"); ostr.println(" try { curChar = input_stream.readChar(); }"); ostr.println(" catch(java.io.IOException e) { " + "throw new Error(\"Internal Error : Please send a bug report.\"); }"); ostr.println(""); ostr.println(" if (jjmatchedPos < strPos)"); ostr.println(" {"); ostr.println(" jjmatchedKind = strKind;"); ostr.println(" jjmatchedPos = strPos;"); ostr.println(" }"); ostr.println(" else if (jjmatchedPos == strPos && jjmatchedKind > strKind)"); ostr.println(" jjmatchedKind = strKind;"); ostr.println(""); ostr.println(" return toRet;"); } ostr.println("}"); allStates.clear(); } public static void DumpStatesForState(final java.io.PrintWriter ostr) { ostr.print("protected static final int[][][] statesForState = "); if (statesForState == null) { ostr.println("null;"); return; } else ostr.println("{"); for (int i = 0; i < statesForState.length; i++) { if (statesForState[i] == null) { ostr.println(" null,"); continue; } ostr.println(" {"); for (int j = 0; j < statesForState[i].length; j++) { final int[] stateSet = statesForState[i][j]; if (stateSet == null) { ostr.println(" { " + j + " },"); continue; } ostr.print(" { "); for (int k = 0; k < stateSet.length; k++) ostr.print(stateSet[k] + ", "); ostr.println("},"); } ostr.println(" },"); } ostr.println("\n};"); } public static void DumpStatesForKind(final java.io.PrintWriter ostr) { DumpStatesForState(ostr); boolean moreThanOne = false; int cnt = 0; ostr.print("protected static final int[][] kindForState = "); if (kinds == null) { ostr.println("null;"); return; } else ostr.println("{"); for (int i = 0; i < kinds.length; i++) { if (moreThanOne) ostr.println(","); moreThanOne = true; if (kinds[i] == null) ostr.println("null"); else { cnt = 0; ostr.print("{ "); for (int j = 0; j < kinds[i].length; j++) { if (cnt++ > 0) ostr.print(","); if (cnt % 15 == 0) ostr.print("\n "); else if (cnt > 1) ostr.print(" "); ostr.print(kinds[i][j]); } ostr.print("}"); } } ostr.println("\n};"); } public static void reInit() { unicodeWarningGiven = false; generatedStates = 0; idCnt = 0; lohiByteCnt = 0; dummyStateIndex = -1; done = false; mark = null; stateDone = null; allStates = new ArrayList(); indexedAllStates = new ArrayList(); nonAsciiTableForMethod = new ArrayList(); equivStatesTable = new Hashtable(); allNextStates = new Hashtable(); lohiByteTab = new Hashtable(); stateNameForComposite = new Hashtable(); compositeStateTable = new Hashtable(); stateBlockTable = new Hashtable(); stateSetsToFix = new Hashtable(); allBitVectors = new ArrayList(); tmpIndices = new int[512]; allBits = "{\n 0xffffffffffffffffL, " + "0xffffffffffffffffL, " + "0xffffffffffffffffL, " + "0xffffffffffffffffL\n};"; tableToDump = new Hashtable(); orderedStateSet = new ArrayList(); lastIndex = 0; //boilerPlateDumped = false; jjCheckNAddStatesUnaryNeeded = false; jjCheckNAddStatesDualNeeded = false; kinds = null; statesForState = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/Version.java0000644000175000017500000000350511360636752020417 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Supply the version number. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public interface Version { String version = "4.2.mma"; } jtb-1.4.4/EDU/purdue/jtb/parser/JavaFiles.java0000644000175000017500000004046411360636752020643 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import EDU.purdue.jtb.utils.JavaFileGenerator; /** * Generate CharStream, TokenManager and Exceptions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class JavaFiles extends JavaCCGlobals implements JavaCCParserConstants { /** * ID of the latest version (of JavaCC) in which one of the CharStream classes * or the CharStream interface is modified. */ static final String charStreamVersion = "4.2.j.m"; /** * ID of the latest version (of JavaCC) in which the TokenManager interface is modified. */ static final String tokenManagerVersion = "4.2.j.m"; /** * ID of the latest version (of JavaCC) in which the Token class is modified. */ static final String tokenVersion = "4.2.j.m"; /** * ID of the latest version (of JavaCC) in which the ParseException class is * modified. */ static final String parseExceptionVersion = "4.2.j.m"; /** * ID of the latest version (of JavaCC) in which the TokenMgrError class is * modified. */ static final String tokenMgrErrorVersion = "4.2.j.m"; /** * Replaces all backslahes with double backslashes. */ static String replaceBackslash(final String str) { StringBuffer b; int i = 0; final int len = str.length(); while (i < len && str.charAt(i++) != '\\') ; if (i == len) // No backslash found. return str; char c; b = new StringBuffer(); for (i = 0; i < len; i++) if ((c = str.charAt(i)) == '\\') b.append("\\\\"); else b.append(c); return b.toString(); } /** * Read the version from the comment in the specified file. * This method does not try to recover from invalid comment syntax, but * rather returns version 0.0 (which will always be taken to mean the file * is out of date). * @param fileName eg Token.java * @return The version as a double, eg 4.1 * @since 4.1 */ static double getVersion(final String fn) { final String commentHeader = "/* " + getIdString(toolName, fn) + " Version "; final File file = new File(Options.getOutputDirectory(), replaceBackslash(fn)); if (!file.exists()) { // Has not yet been created, so it must be up to date. try { final String majorVersion = Version.version.replaceAll("[^0-9.]+.*", ""); return Double.parseDouble(majorVersion); } catch (final NumberFormatException e) { return 0.0; // Should never happen } } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String str; double version = 0.0; // Although the version comment should be the first line, sometimes the // user might have put comments before it. while ((str = reader.readLine()) != null) { if (str.startsWith(commentHeader)) { str = str.substring(commentHeader.length()); final int pos = str.indexOf(' '); if (pos >= 0) str = str.substring(0, pos); if (str.length() > 0) { try { version = Double.parseDouble(str); } catch (final NumberFormatException nfe) { // Ignore - leave version as 0.0 } } break; } } return version; } catch (final IOException ioe) { return 0.0; } finally { if (reader != null) { try { reader.close(); } catch (final IOException e) { } } } } public static void gen_JavaCharStream() { try { final File file = new File(Options.getOutputDirectory(), "JavaCharStream.java"); final OutputFile outputFile = new OutputFile(file, charStreamVersion, new String[] { "STATIC", "SUPPORT_CLASS_VISIBILITY_PUBLIC" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final String prefix = (Options.getStatic() ? "static " : ""); final Map options = new HashMap(Options.getOptions()); options.put("PREFIX", prefix); final JavaFileGenerator generator = new JavaFileGenerator( "/templates/JavaCharStream.template", options); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create JavaCharStream " + e); JavaCCErrors.semantic_error("Could not open file JavaCharStream.java for writing."); throw new Error(); } } public static void gen_SimpleCharStream() { try { final File file = new File(Options.getOutputDirectory(), "SimpleCharStream.java"); final OutputFile outputFile = new OutputFile(file, charStreamVersion, new String[] { "STATIC", "SUPPORT_CLASS_VISIBILITY_PUBLIC" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final String prefix = (Options.getStatic() ? "static " : ""); final Map options = new HashMap(Options.getOptions()); options.put("PREFIX", prefix); final JavaFileGenerator generator = new JavaFileGenerator( "/templates/SimpleCharStream.template", options); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create SimpleCharStream " + e); JavaCCErrors.semantic_error("Could not open file SimpleCharStream.java for writing."); throw new Error(); } } public static void gen_CharStream() { try { final File file = new File(Options.getOutputDirectory(), "CharStream.java"); final OutputFile outputFile = new OutputFile(file, charStreamVersion, new String[] { "STATIC", "SUPPORT_CLASS_VISIBILITY_PUBLIC" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final JavaFileGenerator generator = new JavaFileGenerator("/templates/CharStream.template", Options.getOptions()); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create CharStream " + e); JavaCCErrors.semantic_error("Could not open file CharStream.java for writing."); throw new Error(); } } public static void gen_ParseException() { try { final File file = new File(Options.getOutputDirectory(), "ParseException.java"); final OutputFile outputFile = new OutputFile(file, parseExceptionVersion, new String[] { "KEEP_LINE_COL" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final JavaFileGenerator generator = new JavaFileGenerator( "/templates/ParseException.template", Options.getOptions()); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create ParseException " + e); JavaCCErrors.semantic_error("Could not open file ParseException.java for writing."); throw new Error(); } } public static void gen_TokenMgrError() { try { final File file = new File(Options.getOutputDirectory(), "TokenMgrError.java"); final OutputFile outputFile = new OutputFile(file, tokenMgrErrorVersion, new String[0]); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final JavaFileGenerator generator = new JavaFileGenerator( "/templates/TokenMgrError.template", Options.getOptions()); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create TokenMgrError " + e); JavaCCErrors.semantic_error("Could not open file TokenMgrError.java for writing."); throw new Error(); } } // ModMMa : modified for Token.template with GTToken //public static void gen_Token() { public static void gen_Token(final String pn) { try { final File file = new File(Options.getOutputDirectory(), "Token.java"); final OutputFile outputFile = new OutputFile(file, tokenVersion, new String[] { "TOKEN_EXTENDS", "KEEP_LINE_COL", "SUPPORT_CLASS_VISIBILITY_PUBLIC" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } // ModMMa : added for Token.template with GTToken final HashMap options = new HashMap(Options.getOptions()); options.put("PARSER_NAME", pn); // ModMMa : modified for Token.template with GTToken final JavaFileGenerator generator = new JavaFileGenerator( // "/templates/Token.template", Options.getOptions()); "/templates/Token.template", options); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create Token " + e); JavaCCErrors.semantic_error("Could not open file Token.java for writing."); throw new Error(); } } public static void gen_TokenManager() { try { final File file = new File(Options.getOutputDirectory(), "TokenManager.java"); final OutputFile outputFile = new OutputFile(file, tokenManagerVersion, new String[] { "SUPPORT_CLASS_VISIBILITY_PUBLIC" }); if (!outputFile.needToWrite) { return; } final PrintWriter ostr = outputFile.getPrintWriter(); if (cu_to_insertion_point_1.size() != 0 && (cu_to_insertion_point_1.get(0)).kind == PACKAGE) { for (int i = 1; i < cu_to_insertion_point_1.size(); i++) { if ((cu_to_insertion_point_1.get(i)).kind == SEMICOLON) { cline = ((cu_to_insertion_point_1.get(0))).beginLine; ccol = ((cu_to_insertion_point_1.get(0))).beginColumn; for (int j = 0; j <= i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } ostr.println(""); ostr.println(""); break; } } } final JavaFileGenerator generator = new JavaFileGenerator("/templates/TokenManager.template", Options.getOptions()); generator.generate(ostr); ostr.close(); } catch (final IOException e) { System.err.println("Failed to create TokenManager " + e); JavaCCErrors.semantic_error("Could not open file TokenManager.java for writing."); throw new Error(); } } public static void reInit() { } } jtb-1.4.4/EDU/purdue/jtb/parser/JTBParser.java0000644000175000017500000121346011416555666020600 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. JTBParser.java */ package EDU.purdue.jtb.parser; import java.util.List; import java.util.ArrayList; import EDU.purdue.jtb.syntaxtree.*; /** * This file contains the code for JavaCCParser generated * by JavaCCParser itself. */ // MMa : adapted from JavaCC.jj to fit to JTB class name public class JTBParser extends JavaCCParserInternals implements JTBParserConstants { /* * JTB generated return variables declarations */ /** Return variable for {@link #LocalLookahead} production */ Lookahead jtbrt_LocalLookahead; /** Return variable for {@link #Identifier} production */ String jtbrt_Identifier; /** Return variable for {@link #JavaIdentifier} production */ Token jtbrt_JavaIdentifier; /** Return variable for {@link #Modifiers} production */ int jtbrt_Modifiers; /** Return variable for {@link #IntegerLiteral} production */ int jtbrt_IntegerLiteral; /** Return variable for {@link #BooleanLiteral} production */ boolean jtbrt_BooleanLiteral; /** Return variable for {@link #StringLiteral} production */ String jtbrt_StringLiteral; /** * The name of the parser class. */ String parser_class_name; /** * This flag is set to true when the part between PARSER_BEGIN and * PARSER_END is being parsed. */ boolean processing_cu = false; /** * The level of class nesting. */ int class_nesting = 0; /** * This int variable is incremented while parsing local lookaheads. * Hence it keeps track of *syntactic* lookahead nesting. * This is used to provide warnings when actions and nested lookaheads * are used in syntactic lookahead productions. This is to prevent * typos such as leaving out the comma in LOOKAHEAD( foo(), {check()} ). */ int inLocalLA = 0; /** * Set to true when the parser is within an action. */ boolean inAction = false; /** * This flag keeps track of whether or not return and throw * statements have been patched during the parsing of a production. * The value of this flag is assigned the field with the same * name in BNFProduction_.java. */ boolean jumpPatched = false; /* * Returns true if the next token is not in the FOLLOW list of "expansion". * It is used to decide when the end of an "expansion" has been reached. */ private boolean notTailOfExpansionUnit() { final Token t = getToken(1); if (t.kind == BIT_OR || t.kind == COMMA || t.kind == RPAREN || t.kind == RBRACE || t.kind == RBRACKET) return false; return true; } /** * Class to hold modifiers. */ static public final class ModifierSet { /* Definitions of the bits in the modifiers field */ public static final int M_PUBLIC = 0x0001; public static final int M_PROTECTED = 0x0002; public static final int M_PRIVATE = 0x0004; public static final int M_ABSTRACT = 0x0008; public static final int M_STATIC = 0x0010; public static final int M_FINAL = 0x0020; public static final int M_SYNCHRONIZED = 0x0040; public static final int M_NATIVE = 0x0080; public static final int M_TRANSIENT = 0x0100; public static final int M_VOLATILE = 0x0200; public static final int M_STRICTFP = 0x1000; /* A set of accessors that indicate whether the specified modifier is in the set */ public boolean isPublic(int modifiers) { return (modifiers & M_PUBLIC) != 0; } public boolean isProtected(int modifiers) { return (modifiers & M_PROTECTED) != 0; } public boolean isPrivate(int modifiers) { return (modifiers & M_PRIVATE) != 0; } public boolean isStatic(int modifiers) { return (modifiers & M_STATIC) != 0; } public boolean isAbstract(int modifiers) { return (modifiers & M_ABSTRACT) != 0; } public boolean isFinal(int modifiers) { return (modifiers & M_FINAL) != 0; } public boolean isNative(int modifiers) { return (modifiers & M_NATIVE) != 0; } public boolean isStrictfp(int modifiers) { return (modifiers & M_STRICTFP) != 0; } public boolean isSynchronized(int modifiers) { return (modifiers & M_SYNCHRONIZED) != 0; } public boolean isTransient(int modifiers) { return (modifiers & M_TRANSIENT) != 0; } public boolean isVolatile(int modifiers) { return (modifiers & M_VOLATILE) != 0; } /* Removes the given modifier */ static int removeModifier(int modifiers, int mod) { return modifiers & ~mod; } } /************************************************ * THE JAVACC GRAMMAR SPECIFICATION STARTS HERE * ************************************************/ // ModMMa: added to test try-expansion_choices-catch-finally syntax final public AFancyProduction AFancyProduction() throws ParseException { // --- JTB generated node declarations --- NodeSequence n0 = null; NodeListOptional n1 = new NodeListOptional(); Annotation n2 = null; NodeChoice n3 = null; LabeledStatement n4 = null; AssertStatement n5 = null; Block n6 = null; EmptyStatement n7 = null; NodeSequence n8 = null; StatementExpression n9 = null; NodeToken n10 = null; Token n11 = null; SwitchStatement n12 = null; TryStatement n13 = null; NodeOptional n14 = new NodeOptional(); MarkerAnnotation n15 = null; try { n0 = new NodeSequence(3); label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 140: ; break; default: jj_la1[0] = jj_gen; break label_1; } n2 = Annotation(); n1.addNode(n2); } n1.nodes.trimToSize(); n0.addNode(n1); if (jj_2_1(2)) { n4 = LabeledStatement(); n3 = new NodeChoice(n4, 0, 7); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSERT: n5 = AssertStatement(); n3 = new NodeChoice(n5, 1, 7); break; case LBRACE: n6 = Block(null); n3 = new NodeChoice(n6, 2, 7); break; case SEMICOLON: n7 = EmptyStatement(); n3 = new NodeChoice(n7, 3, 7); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case INCR: case DECR: case IDENTIFIER: n8 = new NodeSequence(2); n9 = StatementExpression(); n8.addNode(n9); n11 = jj_consume_token(SEMICOLON); n10 = JTBToolkit.makeNodeToken(n11); n8.addNode(n10); n3 = new NodeChoice(n8, 4, 7); break; case SWITCH: n12 = SwitchStatement(); n3 = new NodeChoice(n12, 5, 7); break; case TRY: n13 = TryStatement(); n3 = new NodeChoice(n13, 6, 7); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } n0.addNode(n3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 140: n15 = MarkerAnnotation(); n14.addNode(n15); break; default: jj_la1[2] = jj_gen; ; } n0.addNode(n14); } catch (Exception fancy_e) { fancy_e = null; } catch (Throwable fancy_t) { fancy_t = null; } finally { String fancy_s = ""; if (fancy_s == " ") fancy_s = null; // if (ls != null) // ls = null; } {if (true) return new AFancyProduction(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all javacc_input into JavaCCInput to conform to class name convention final public JavaCCInput JavaCCInput() throws ParseException { // --- JTB generated node declarations --- JavaCCOptions n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; Identifier n5 = null; NodeToken n6 = null; Token n7 = null; CompilationUnit n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; Identifier n13 = null; NodeToken n14 = null; Token n15 = null; NodeList n16 = new NodeList(); Production n17 = null; // --- user BNFProduction java block --- String id1, id2; initialize(); // MMa : added to JavaCC as called in parser.Main in Javacc 4.2 Options.init(); n0 = JavaCCOptions(); n2 = jj_consume_token(_PARSER_BEGIN); n1 = JTBToolkit.makeNodeToken(n2); n4 = jj_consume_token(LPAREN); n3 = JTBToolkit.makeNodeToken(n4); n5 = Identifier(); id1 = jtbrt_Identifier; addcuname(id1); n7 = jj_consume_token(RPAREN); n6 = JTBToolkit.makeNodeToken(n7); processing_cu = true; parser_class_name = id1; n8 = CompilationUnit(); processing_cu = false; n10 = jj_consume_token(_PARSER_END); n9 = JTBToolkit.makeNodeToken(n10); n12 = jj_consume_token(LPAREN); n11 = JTBToolkit.makeNodeToken(n12); n13 = Identifier(); id2 = jtbrt_Identifier; compare(getToken(0), id1, id2); n15 = jj_consume_token(RPAREN); n14 = JTBToolkit.makeNodeToken(n15); label_2: while (true) { n17 = Production(); n16.addNode(n17); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case VOID: case LANGLE: case IDENTIFIER: ; break; default: jj_la1[3] = jj_gen; break label_2; } } n16.nodes.trimToSize(); {if (true) return new JavaCCInput(n0, n1, n3, n5, n6, n8, n9, n11, n13, n14, n16);} throw new Error("Missing return statement in function"); } // MMa : changed all javacc_options into JavaCCOptions to conform to class name convention final public JavaCCOptions JavaCCOptions() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeListOptional n6 = null; OptionBinding n7 = null; NodeToken n8 = null; Token n9 = null; if (getToken(1).image.equals("options")) { n6 = new NodeListOptional(); n1 = new NodeSequence(4); n3 = jj_consume_token(133); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n5 = jj_consume_token(LBRACE); n4 = JTBToolkit.makeNodeToken(n5); n1.addNode(n4); label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case STATIC: case IDENTIFIER: ; break; default: jj_la1[4] = jj_gen; break label_3; } n7 = OptionBinding(); n6.addNode(n7); } n6.nodes.trimToSize(); n1.addNode(n6); n9 = jj_consume_token(RBRACE); n8 = JTBToolkit.makeNodeToken(n9); n1.addNode(n8); n0.addNode(n1); } else { ; } Options.normalize(); {if (true) return new JavaCCOptions(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all option_binding into OptionBinding to conform to class name convention final public OptionBinding OptionBinding() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeChoice n11 = null; IntegerLiteral n12 = null; BooleanLiteral n13 = null; StringLiteral n14 = null; NodeToken n15 = null; Token n16 = null; // --- user BNFProduction java block --- String option_name; int int_val; boolean bool_val; String string_val; Token t = getToken(1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: n2 = jj_consume_token(IDENTIFIER); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 4); break; case _LOOKAHEAD: n4 = jj_consume_token(_LOOKAHEAD); n3 = JTBToolkit.makeNodeToken(n4); n0 = new NodeChoice(n3, 1, 4); break; case _IGNORE_CASE: n6 = jj_consume_token(_IGNORE_CASE); n5 = JTBToolkit.makeNodeToken(n6); n0 = new NodeChoice(n5, 2, 4); break; case STATIC: n8 = jj_consume_token(STATIC); n7 = JTBToolkit.makeNodeToken(n8); n0 = new NodeChoice(n7, 3, 4); break; default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } option_name = t.image; n10 = jj_consume_token(ASSIGN); n9 = JTBToolkit.makeNodeToken(n10); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: n12 = IntegerLiteral(); int_val = jtbrt_IntegerLiteral; Options.setInputFileOption(t, getToken(0), option_name, new Integer(int_val)); n11 = new NodeChoice(n12, 0, 3); break; case FALSE: case TRUE: n13 = BooleanLiteral(); bool_val = jtbrt_BooleanLiteral; Options.setInputFileOption(t, getToken(0), option_name, new Boolean(bool_val)); n11 = new NodeChoice(n13, 1, 3); break; case STRING_LITERAL: n14 = StringLiteral(); string_val = jtbrt_StringLiteral; Options.setInputFileOption(t, getToken(0), option_name, string_val); n11 = new NodeChoice(n14, 2, 3); break; default: jj_la1[6] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n16 = jj_consume_token(SEMICOLON); n15 = JTBToolkit.makeNodeToken(n16); {if (true) return new OptionBinding(n0, n9, n11, n15);} throw new Error("Missing return statement in function"); } // MMa : changed all production into Production to conform to class name convention final public Production Production() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; JavaCodeProduction n1 = null; RegularExprProduction n2 = null; TokenManagerDecls n3 = null; BNFProduction n4 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _JAVACODE: n1 = JavaCodeProduction(); n0 = new NodeChoice(n1, 0, 4); break; case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case LANGLE: n2 = RegularExprProduction(); n0 = new NodeChoice(n2, 1, 4); break; case _TOKEN_MGR_DECLS: n3 = TokenManagerDecls(); n0 = new NodeChoice(n3, 2, 4); break; case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case VOID: case IDENTIFIER: n4 = BNFProduction(); n0 = new NodeChoice(n4, 3, 4); break; default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new Production(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all JavaCodeProduction into JavaCodeProduction_ (JavaCC specific class) // MMa : changed all javacode_production into JavaCodeProduction to conform to class name convention final public JavaCodeProduction JavaCodeProduction() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; AccessModifier n2 = null; ResultType n3 = null; Identifier n4 = null; FormalParameters n5 = null; NodeOptional n6 = new NodeOptional(); NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; Name n10 = null; NodeListOptional n11 = null; NodeSequence n12 = null; NodeToken n13 = null; Token n14 = null; Name n15 = null; Block n16 = null; // --- user BNFProduction java block --- JavaCodeProduction_ p = new JavaCodeProduction_(); String lhs; Token t = getToken(1); p.setFirstToken(t); List excName; p.setThrowsList(new ArrayList>()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); n1 = jj_consume_token(_JAVACODE); n0 = JTBToolkit.makeNodeToken(n1); n2 = AccessModifier(p); n3 = ResultType(p.getReturnTypeTokens()); n4 = Identifier(); lhs = jtbrt_Identifier; p.setLhs(lhs); n5 = FormalParameters(p.getParameterListTokens()); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case THROWS: n11 = new NodeListOptional(); n7 = new NodeSequence(5); n9 = jj_consume_token(THROWS); n8 = JTBToolkit.makeNodeToken(n9); n7.addNode(n8); excName = new ArrayList(); n10 = Name(excName); n7.addNode(n10); p.getThrowsList().add(excName); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[8] = jj_gen; break label_4; } n12 = new NodeSequence(4); excName = new ArrayList(); n14 = jj_consume_token(COMMA); n13 = JTBToolkit.makeNodeToken(n14); n12.addNode(n13); n15 = Name(excName); n12.addNode(n15); p.getThrowsList().add(excName); n11.addNode(n12); } n11.nodes.trimToSize(); n7.addNode(n11); n6.addNode(n7); break; default: jj_la1[9] = jj_gen; ; } n16 = Block(p.getCodeTokens()); p.setLastToken(getToken(0)); addproduction(p); {if (true) return new JavaCodeProduction(n0, n2, n3, n4, n5, n6, n16);} throw new Error("Missing return statement in function"); } // MMa : changed all BNFProduction into BNFProduction_ (JavaCC specific class) // MMa : changed all bnf_production into BNFProduction to conform to class name convention final public BNFProduction BNFProduction() throws ParseException { // --- JTB generated node declarations --- AccessModifier n0 = null; ResultType n1 = null; Identifier n2 = null; FormalParameters n3 = null; NodeOptional n4 = new NodeOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; Name n8 = null; NodeListOptional n9 = null; NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; Name n13 = null; NodeToken n14 = null; Token n15 = null; Block n16 = null; NodeToken n17 = null; Token n18 = null; ExpansionChoices n19 = null; NodeToken n20 = null; Token n21 = null; // --- user BNFProduction java block --- BNFProduction_ p = new BNFProduction_(); Container c = new Container(); Token t = getToken(1); p.setFirstToken(t); List excName; String lhs; p.setThrowsList(new ArrayList>()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); jumpPatched = false; n0 = AccessModifier(p); n1 = ResultType(p.getReturnTypeTokens()); n2 = Identifier(); lhs = jtbrt_Identifier; p.setLhs(lhs); n3 = FormalParameters(p.getParameterListTokens()); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case THROWS: n9 = new NodeListOptional(); n5 = new NodeSequence(5); n7 = jj_consume_token(THROWS); n6 = JTBToolkit.makeNodeToken(n7); n5.addNode(n6); excName = new ArrayList(); n8 = Name(excName); n5.addNode(n8); p.getThrowsList().add(excName); label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[10] = jj_gen; break label_5; } n10 = new NodeSequence(4); excName = new ArrayList(); n12 = jj_consume_token(COMMA); n11 = JTBToolkit.makeNodeToken(n12); n10.addNode(n11); n13 = Name(excName); n10.addNode(n13); p.getThrowsList().add(excName); n9.addNode(n10); } n9.nodes.trimToSize(); n5.addNode(n9); n4.addNode(n5); break; default: jj_la1[11] = jj_gen; ; } n15 = jj_consume_token(COLON); n14 = JTBToolkit.makeNodeToken(n15); n16 = Block(p.getDeclarationTokens()); n18 = jj_consume_token(LBRACE); n17 = JTBToolkit.makeNodeToken(n18); n19 = ExpansionChoices(c); n21 = jj_consume_token(RBRACE); n20 = JTBToolkit.makeNodeToken(n21); t = n21; p.setLastToken(t); p.setJumpPatched(jumpPatched); production_addexpansion(p, (Expansion_)(c.member)); addproduction(p); {if (true) return new BNFProduction(n0, n1, n2, n3, n4, n14, n16, n17, n19, n20);} throw new Error("Missing return statement in function"); } final public AccessModifier AccessModifier(NormalProduction p) throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeChoice n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; // --- user BNFProduction java block --- Token t = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PRIVATE: case PROTECTED: case PUBLIC: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PUBLIC: n3 = jj_consume_token(PUBLIC); n2 = JTBToolkit.makeNodeToken(n3); t = n3; n1 = new NodeChoice(n2, 0, 3); break; case PROTECTED: n5 = jj_consume_token(PROTECTED); n4 = JTBToolkit.makeNodeToken(n5); t = n5; n1 = new NodeChoice(n4, 1, 3); break; case PRIVATE: n7 = jj_consume_token(PRIVATE); n6 = JTBToolkit.makeNodeToken(n7); t = n7; n1 = new NodeChoice(n6, 2, 3); break; default: jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n0.addNode(n1); break; default: jj_la1[13] = jj_gen; ; } if (t != null) { p.setAccessMod(t.image); } {if (true) return new AccessModifier(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all regular_expr_production into RegularExprProduction to conform to class name convention final public RegularExprProduction RegularExprProduction() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeChoice n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; NodeListOptional n14 = null; NodeSequence n15 = null; NodeToken n16 = null; Token n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; RegExprKind n22 = null; NodeOptional n23 = new NodeOptional(); NodeSequence n24 = null; NodeToken n25 = null; Token n26 = null; NodeToken n27 = null; Token n28 = null; NodeToken n29 = null; Token n30 = null; NodeToken n31 = null; Token n32 = null; NodeToken n33 = null; Token n34 = null; RegExprSpec n35 = null; NodeListOptional n36 = new NodeListOptional(); NodeSequence n37 = null; NodeToken n38 = null; Token n39 = null; RegExprSpec n40 = null; NodeToken n41 = null; Token n42 = null; // --- user BNFProduction java block --- TokenProduction p = new TokenProduction(); List states; Token t = p.firstToken = getToken(1); p.setLine(t.beginLine); p.setColumn(t.beginColumn); // set p.lexStates assuming there is no state spec. // and then override if necessary. p.lexStates = new String[]{ "DEFAULT" }; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n14 = new NodeListOptional(); if (jj_2_2(2)) { n2 = new NodeSequence(4); n4 = jj_consume_token(LANGLE); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n6 = jj_consume_token(STAR); n5 = JTBToolkit.makeNodeToken(n6); n2.addNode(n5); n8 = jj_consume_token(RANGLE); n7 = JTBToolkit.makeNodeToken(n8); n2.addNode(n7); p.lexStates = null; n1 = new NodeChoice(n2, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n9 = new NodeSequence(7); n11 = jj_consume_token(LANGLE); n10 = JTBToolkit.makeNodeToken(n11); n9.addNode(n10); states = new ArrayList(); n13 = jj_consume_token(IDENTIFIER); n12 = JTBToolkit.makeNodeToken(n13); t = n13; n9.addNode(n12); states.add(t.image); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[14] = jj_gen; break label_6; } n15 = new NodeSequence(3); n17 = jj_consume_token(COMMA); n16 = JTBToolkit.makeNodeToken(n17); n15.addNode(n16); n19 = jj_consume_token(IDENTIFIER); n18 = JTBToolkit.makeNodeToken(n19); t = n19; n15.addNode(n18); states.add(t.image); n14.addNode(n15); } n14.nodes.trimToSize(); n9.addNode(n14); n21 = jj_consume_token(RANGLE); n20 = JTBToolkit.makeNodeToken(n21); n9.addNode(n20); p.lexStates = new String[states.size()]; for (int i = 0; // ModMMa : workaround for sf plugin color syntaxing problem // i < states.size(); i != states.size(); i++) { p.lexStates[i] = states.get(i); } n1 = new NodeChoice(n9, 1, 2); break; default: jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } n0.addNode(n1); break; default: jj_la1[16] = jj_gen; ; } n22 = RegExprKind(p); if (p.kind != TokenProduction.TOKEN && Options.getUserTokenManager()) { JavaCCErrors.warning(getToken(0), "Regular expression is being treated as if it were a TOKEN since option USER_TOKEN_MANAGER has been set to true."); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: n24 = new NodeSequence(4); n26 = jj_consume_token(LBRACKET); n25 = JTBToolkit.makeNodeToken(n26); n24.addNode(n25); n28 = jj_consume_token(_IGNORE_CASE); n27 = JTBToolkit.makeNodeToken(n28); t = n28; n24.addNode(n27); n30 = jj_consume_token(RBRACKET); n29 = JTBToolkit.makeNodeToken(n30); n24.addNode(n29); p.ignoreCase = true; if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring \u005c"IGNORE_CASE\u005c" specification since option USER_TOKEN_MANAGER has been set to true."); } n23.addNode(n24); break; default: jj_la1[17] = jj_gen; ; } n32 = jj_consume_token(COLON); n31 = JTBToolkit.makeNodeToken(n32); n34 = jj_consume_token(LBRACE); n33 = JTBToolkit.makeNodeToken(n34); n35 = RegExprSpec(p); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_OR: ; break; default: jj_la1[18] = jj_gen; break label_7; } n37 = new NodeSequence(2); n39 = jj_consume_token(BIT_OR); n38 = JTBToolkit.makeNodeToken(n39); n37.addNode(n38); n40 = RegExprSpec(p); n37.addNode(n40); n36.addNode(n37); } n36.nodes.trimToSize(); n42 = jj_consume_token(RBRACE); n41 = JTBToolkit.makeNodeToken(n42); t = n42; p.lastToken = t; addregexpr(p); {if (true) return new RegularExprProduction(n0, n22, n23, n31, n33, n35, n36, n41);} throw new Error("Missing return statement in function"); } // MMa : changed all token_manager_decls into TokenManagerDecls to conform to class name convention final public TokenManagerDecls TokenManagerDecls() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; ClassOrInterfaceBody n4 = null; // --- user BNFProduction java block --- List decls = new ArrayList(); Token t; n1 = jj_consume_token(_TOKEN_MGR_DECLS); n0 = JTBToolkit.makeNodeToken(n1); t = n1; n3 = jj_consume_token(COLON); n2 = JTBToolkit.makeNodeToken(n3); n4 = ClassOrInterfaceBody(false, decls); add_token_manager_decls(t, decls); {if (true) return new TokenManagerDecls(n0, n2, n4);} throw new Error("Missing return statement in function"); } // MMa : changed all regexpr_kind into RegExprKind to conform to class name convention final public RegExprKind RegExprKind(TokenProduction p) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _TOKEN: n2 = jj_consume_token(_TOKEN); n1 = JTBToolkit.makeNodeToken(n2); p.kind = TokenProduction.TOKEN; n0 = new NodeChoice(n1, 0, 4); break; case _SPECIAL_TOKEN: n4 = jj_consume_token(_SPECIAL_TOKEN); n3 = JTBToolkit.makeNodeToken(n4); p.kind = TokenProduction.SPECIAL; n0 = new NodeChoice(n3, 1, 4); break; case _SKIP: n6 = jj_consume_token(_SKIP); n5 = JTBToolkit.makeNodeToken(n6); p.kind = TokenProduction.SKIP; n0 = new NodeChoice(n5, 2, 4); break; case _MORE: n8 = jj_consume_token(_MORE); n7 = JTBToolkit.makeNodeToken(n8); p.kind = TokenProduction.MORE; n0 = new NodeChoice(n7, 3, 4); break; default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new RegExprKind(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all RegExprSpec into RegExprSpec_ (JavaCC specific class) // MMa : changed all regexpr_spec into RegExprSpec to conform to class name convention final public RegExprSpec RegExprSpec(TokenProduction p) throws ParseException { // --- JTB generated node declarations --- RegularExpression n0 = null; NodeOptional n1 = new NodeOptional(); Block n2 = null; NodeOptional n3 = new NodeOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; // --- user BNFProduction java block --- Container c = new Container(); Action act = new Action(); Token t = null; RegExprSpec_ res = new RegExprSpec_(); n0 = RegularExpression(c); res.rexp = (RegularExpression_)c.member; res.rexp.tpContext = p; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: t = getToken(1); n2 = Block(act.getActionTokens()); if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring action in regular expression specification since option USER_TOKEN_MANAGER has been set to true."); } if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Actions are not permitted on private (#) regular expressions."); } n1.addNode(n2); break; default: jj_la1[20] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COLON: n4 = new NodeSequence(3); n6 = jj_consume_token(COLON); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n8 = jj_consume_token(IDENTIFIER); n7 = JTBToolkit.makeNodeToken(n8); t = n8; n4.addNode(n7); res.nextState = t.image; if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Lexical state changes are not permitted after private (#) regular expressions."); } n3.addNode(n4); break; default: jj_la1[21] = jj_gen; ; } res.act = act; res.nsTok = t; p.respecs.add(res); {if (true) return new RegExprSpec(n0, n1, n3);} throw new Error("Missing return statement in function"); } // MMa : changed all expansion_choices into ExpansionChoices to conform to class name convention final public ExpansionChoices ExpansionChoices(Container c1) throws ParseException { // --- JTB generated node declarations --- Expansion n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expansion n5 = null; // --- user BNFProduction java block --- boolean morethanone = false; Choice ch = new Choice(); Container c2 = new Container(); n0 = Expansion(c1); label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_OR: ; break; default: jj_la1[22] = jj_gen; break label_8; } n2 = new NodeSequence(3); n4 = jj_consume_token(BIT_OR); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Expansion(c2); n2.addNode(n5); if (morethanone) { ch.getChoices().add((Expansion_)c2.member); ((Expansion_)c2.member).parent = ch; } else { morethanone = true; ch = new Choice((Expansion_)c1.member); ((Expansion_)c1.member).parent = ch; ch.getChoices().add((Expansion_)c2.member); ((Expansion_)c2.member).parent = ch; } n1.addNode(n2); } n1.nodes.trimToSize(); if (morethanone) { c1.member = ch; } {if (true) return new ExpansionChoices(n0, n1);} throw new Error("Missing return statement in function"); } // MMa : changed all Expansion into Expansion_ (JavaCC specific class) // MMa : changed all expansion into Expansion to conform to class name convention final public Expansion Expansion(Container c1) throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; LocalLookahead n6 = null; NodeToken n7 = null; Token n8 = null; NodeList n9 = new NodeList(); ExpansionUnit n10 = null; // --- user BNFProduction java block --- Sequence seq = new Sequence(); Container c2 = new Container(); Lookahead la = new Lookahead(); Token t = getToken(1); seq.setLine(t.beginLine); seq.setColumn(t.beginColumn); la.setLine(t.beginLine); la.setColumn(t.beginColumn); la.setAmount(Options.getLookahead()); la.setLaExpansion(null); la.setExplicit(false); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: n1 = new NodeSequence(5); n3 = jj_consume_token(_LOOKAHEAD); n2 = JTBToolkit.makeNodeToken(n3); t = n3; n1.addNode(n2); n5 = jj_consume_token(LPAREN); n4 = JTBToolkit.makeNodeToken(n5); n1.addNode(n4); n6 = LocalLookahead(); la = jtbrt_LocalLookahead; n1.addNode(n6); n8 = jj_consume_token(RPAREN); n7 = JTBToolkit.makeNodeToken(n8); n1.addNode(n7); if (inLocalLA != 0 && la.getAmount() != 0) { JavaCCErrors.warning(t, "Only semantic lookahead specifications within other lookahead specifications is considered. Syntactic lookahead is ignored."); } n0.addNode(n1); break; default: jj_la1[23] = jj_gen; ; } seq.units.add(la); label_9: while (true) { n10 = ExpansionUnit(c2); seq.units.add((Expansion_)c2.member); ((Expansion_)c2.member).parent = seq; ((Expansion_)c2.member).ordinal = seq.units.size() - 1; n9.addNode(n10); if (notTailOfExpansionUnit()) { ; } else { break label_9; } } n9.nodes.trimToSize(); if (la.getLaExpansion() == null) { la.setLaExpansion(seq); } c1.member = seq; {if (true) return new Expansion(n0, n9);} throw new Error("Missing return statement in function"); } // MMa : changed all local_lookahead into LocalLookahead to conform to class name convention final public LocalLookahead LocalLookahead() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); IntegerLiteral n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); ExpansionChoices n6 = null; NodeOptional n7 = new NodeOptional(); NodeToken n8 = null; Token n9 = null; NodeOptional n10 = new NodeOptional(); NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; // --- user BNFProduction java block --- Lookahead la = new Lookahead(); la.setExplicit(true); Token t = getToken(1); la.setLine(t.beginLine); la.setColumn(t.beginColumn); la.setLaExpansion(null); Container c = new Container(); boolean commaAtEnd = false, emptyLA = true; int laAmount; inLocalLA++; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: n1 = IntegerLiteral(); laAmount = jtbrt_IntegerLiteral; emptyLA = false; la.setAmount(laAmount); n0.addNode(n1); break; default: jj_la1[24] = jj_gen; ; } if (!emptyLA && (getToken(1).kind != RPAREN)) { n4 = jj_consume_token(COMMA); n3 = JTBToolkit.makeNodeToken(n4); commaAtEnd = true; n2.addNode(n3); } else { ; } if (getToken(1).kind != RPAREN && getToken(1).kind != LBRACE) { n6 = ExpansionChoices(c); emptyLA = false; commaAtEnd = false; la.setLaExpansion((Expansion_)c.member); n5.addNode(n6); } else { ; } if (!emptyLA && !commaAtEnd && (getToken(1).kind != RPAREN)) { n9 = jj_consume_token(COMMA); n8 = JTBToolkit.makeNodeToken(n9); commaAtEnd = true; n7.addNode(n8); } else { ; } if (emptyLA || commaAtEnd) { n11 = new NodeSequence(4); n13 = jj_consume_token(LBRACE); n12 = JTBToolkit.makeNodeToken(n13); n11.addNode(n12); n14 = Expression(la.getActionTokens()); n11.addNode(n14); n16 = jj_consume_token(RBRACE); n15 = JTBToolkit.makeNodeToken(n16); n11.addNode(n15); if (emptyLA) { la.setAmount(0); } n10.addNode(n11); } else { ; } inLocalLA--; jtbrt_LocalLookahead = la; {if (true) return new LocalLookahead(n0, n2, n5, n7, n10);} throw new Error("Missing return statement in function"); } // MMa : changed all expansion_unit into ExpansionUnit to conform to class name convention final public ExpansionUnit ExpansionUnit(Container c) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; LocalLookahead n6 = null; NodeToken n7 = null; Token n8 = null; Block n9 = null; NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; ExpansionChoices n13 = null; NodeToken n14 = null; Token n15 = null; ExpansionUnitInTCF n16 = null; NodeSequence n17 = null; NodeOptional n18 = new NodeOptional(); NodeSequence n19 = null; PrimaryExpression n20 = null; NodeToken n21 = null; Token n22 = null; NodeChoice n23 = null; NodeSequence n24 = null; Identifier n25 = null; Arguments n26 = null; NodeSequence n27 = null; RegularExpression n28 = null; NodeOptional n29 = new NodeOptional(); NodeSequence n30 = null; NodeToken n31 = null; Token n32 = null; NodeToken n33 = null; Token n34 = null; NodeSequence n35 = null; NodeToken n36 = null; Token n37 = null; ExpansionChoices n38 = null; NodeToken n39 = null; Token n40 = null; NodeOptional n41 = new NodeOptional(); NodeChoice n42 = null; NodeToken n43 = null; Token n44 = null; NodeToken n45 = null; Token n46 = null; NodeToken n47 = null; Token n48 = null; // --- user BNFProduction java block --- String name; List lhsTokens = new ArrayList(); NonTerminal nt; Action act; Token t; Lookahead la; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: n1 = new NodeSequence(5); n3 = jj_consume_token(_LOOKAHEAD); n2 = JTBToolkit.makeNodeToken(n3); /* * We give this priority over primary expressions which use LOOKAHEAD as the * name of its identifier. */ t = n3; n1.addNode(n2); n5 = jj_consume_token(LPAREN); n4 = JTBToolkit.makeNodeToken(n5); n1.addNode(n4); n6 = LocalLookahead(); la = jtbrt_LocalLookahead; n1.addNode(n6); n8 = jj_consume_token(RPAREN); n7 = JTBToolkit.makeNodeToken(n8); n1.addNode(n7); // Now set the la_expansion field of la with a dummy expansion (we use EOF). la.setLaExpansion(new REndOfFile()); // Create a singleton choice with an empty action. Choice ch = new Choice(t); Sequence seq = new Sequence(t, la); la.parent = seq; la.ordinal = 0; act = new Action(); act.setLine(t.beginLine); act.setColumn(t.beginColumn); seq.units.add(act); act.parent = seq; act.ordinal = 1; ch.getChoices().add(seq); seq.parent = ch; seq.ordinal = 0; if (la.getAmount() != 0) { if (la.getActionTokens().size() != 0) { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. Only semantic lookahead will be considered here."); } else { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. This will be ignored."); } } c.member = ch; n0 = new NodeChoice(n1, 0, 6); break; case LBRACE: act = new Action(); t = getToken(1); act.setLine(t.beginLine); act.setColumn(t.beginColumn); inAction = true; n9 = Block(act.getActionTokens()); inAction = false; if (inLocalLA != 0) { JavaCCErrors.warning(t, "Action within lookahead specification will be ignored."); } c.member = act; n0 = new NodeChoice(n9, 1, 6); break; case LBRACKET: n10 = new NodeSequence(4); n12 = jj_consume_token(LBRACKET); n11 = JTBToolkit.makeNodeToken(n12); t = n12; n10.addNode(n11); n13 = ExpansionChoices(c); n10.addNode(n13); n15 = jj_consume_token(RBRACKET); n14 = JTBToolkit.makeNodeToken(n15); n10.addNode(n14); c.member = new ZeroOrOne(t, (Expansion_)c.member); n0 = new NodeChoice(n10, 2, 6); break; case TRY: n16 = ExpansionUnitInTCF(c); n0 = new NodeChoice(n16, 3, 6); break; default: jj_la1[29] = jj_gen; if (jj_2_5(2147483647)) { n17 = new NodeSequence(2); if (jj_2_3(2147483647)) { n19 = new NodeSequence(5); Token first = getToken(1); n20 = PrimaryExpression(); n19.addNode(n20); Token last = getToken(0); n22 = jj_consume_token(ASSIGN); n21 = JTBToolkit.makeNodeToken(n22); n19.addNode(n21); t = first; while (true) { lhsTokens.add(t); if (t == last) break; t = t.next; } n18.addNode(n19); } else { ; } n17.addNode(n18); if (jj_2_4(2147483647)) { n24 = new NodeSequence(4); nt = new NonTerminal(); t = getToken(1); nt.setLine(t.beginLine); nt.setColumn(t.beginColumn); nt.setLhsTokens(lhsTokens); n25 = Identifier(); name = jtbrt_Identifier; n24.addNode(n25); n26 = Arguments(nt.getArgumentTokens()); n24.addNode(n26); nt.setName(name); c.member = nt; n23 = new NodeChoice(n24, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: case LANGLE: n27 = new NodeSequence(3); n28 = RegularExpression(c); n27.addNode(n28); ((RegularExpression_)(c.member)).lhsTokens = lhsTokens; add_inline_regexpr((RegularExpression_)(c.member)); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOT: n30 = new NodeSequence(3); n32 = jj_consume_token(DOT); n31 = JTBToolkit.makeNodeToken(n32); n30.addNode(n31); n34 = jj_consume_token(IDENTIFIER); n33 = JTBToolkit.makeNodeToken(n34); t = n34; n30.addNode(n33); ((RegularExpression_)(c.member)).rhsToken = t; n29.addNode(n30); break; default: jj_la1[25] = jj_gen; ; } n27.addNode(n29); n23 = new NodeChoice(n27, 1, 2); break; default: jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } n17.addNode(n23); n0 = new NodeChoice(n17, 4, 6); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: n35 = new NodeSequence(4); n37 = jj_consume_token(LPAREN); n36 = JTBToolkit.makeNodeToken(n37); t = n37; n35.addNode(n36); n38 = ExpansionChoices(c); n35.addNode(n38); n40 = jj_consume_token(RPAREN); n39 = JTBToolkit.makeNodeToken(n40); n35.addNode(n39); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case HOOK: case PLUS: case STAR: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: n44 = jj_consume_token(PLUS); n43 = JTBToolkit.makeNodeToken(n44); c.member = new OneOrMore(t, (Expansion_)c.member); n42 = new NodeChoice(n43, 0, 3); break; case STAR: n46 = jj_consume_token(STAR); n45 = JTBToolkit.makeNodeToken(n46); c.member = new ZeroOrMore(t, (Expansion_)c.member); n42 = new NodeChoice(n45, 1, 3); break; case HOOK: n48 = jj_consume_token(HOOK); n47 = JTBToolkit.makeNodeToken(n48); c.member = new ZeroOrOne(t, (Expansion_)c.member); n42 = new NodeChoice(n47, 2, 3); break; default: jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n41.addNode(n42); break; default: jj_la1[28] = jj_gen; ; } n35.addNode(n41); n0 = new NodeChoice(n35, 5, 6); break; default: jj_la1[30] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } {if (true) return new ExpansionUnit(n0);} throw new Error("Missing return statement in function"); } // MMa : added to create a node final public ExpansionUnitInTCF ExpansionUnitInTCF(Container c) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; ExpansionChoices n4 = null; NodeToken n5 = null; Token n6 = null; NodeListOptional n7 = new NodeListOptional(); NodeSequence n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; Name n13 = null; NodeToken n14 = null; Token n15 = null; NodeToken n16 = null; Token n17 = null; Block n18 = null; NodeOptional n19 = new NodeOptional(); NodeSequence n20 = null; NodeToken n21 = null; Token n22 = null; Block n23 = null; // --- user BNFProduction java block --- Token t; Container expch = new Container(); List> types = new ArrayList>(); List ids = new ArrayList(); List> catchblks = new ArrayList>(); List finallyblk = null; List vec = new ArrayList(); Token t0; n1 = jj_consume_token(TRY); n0 = JTBToolkit.makeNodeToken(n1); t0 = n1; n3 = jj_consume_token(LBRACE); n2 = JTBToolkit.makeNodeToken(n3); n4 = ExpansionChoices(expch); n6 = jj_consume_token(RBRACE); n5 = JTBToolkit.makeNodeToken(n6); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CATCH: ; break; default: jj_la1[31] = jj_gen; break label_10; } n8 = new NodeSequence(8); n10 = jj_consume_token(CATCH); n9 = JTBToolkit.makeNodeToken(n10); n8.addNode(n9); n12 = jj_consume_token(LPAREN); n11 = JTBToolkit.makeNodeToken(n12); n8.addNode(n11); n13 = Name(vec); n8.addNode(n13); n15 = jj_consume_token(IDENTIFIER); n14 = JTBToolkit.makeNodeToken(n15); t = n15; n8.addNode(n14); n17 = jj_consume_token(RPAREN); n16 = JTBToolkit.makeNodeToken(n17); n8.addNode(n16); types.add(vec); ids.add(t); vec = new ArrayList(); inAction = true; n18 = Block(vec); n8.addNode(n18); inAction = false; catchblks.add(vec); vec = new ArrayList(); n7.addNode(n8); } n7.nodes.trimToSize(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FINALLY: n20 = new NodeSequence(4); inAction = true; n22 = jj_consume_token(FINALLY); n21 = JTBToolkit.makeNodeToken(n22); n20.addNode(n21); n23 = Block(vec); n20.addNode(n23); inAction = false; finallyblk = vec; n19.addNode(n20); break; default: jj_la1[32] = jj_gen; ; } makeTryBlock(t0, c, expch, types, ids, catchblks, finallyblk); {if (true) return new ExpansionUnitInTCF(n0, n2, n4, n5, n7, n19);} throw new Error("Missing return statement in function"); } // MMa : changed all RegularExpression into RegularExpression_ (JavaCC specific class) // MMa : changed all regular_expression into RegularExpression to conform to class name convention final public RegularExpression RegularExpression(Container c) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; StringLiteral n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; NodeOptional n7 = null; NodeToken n8 = null; Token n9 = null; Identifier n10 = null; NodeToken n11 = null; Token n12 = null; ComplexRegularExpressionChoices n13 = null; NodeToken n14 = null; Token n15 = null; NodeSequence n16 = null; NodeToken n17 = null; Token n18 = null; Identifier n19 = null; NodeToken n20 = null; Token n21 = null; NodeSequence n22 = null; NodeToken n23 = null; Token n24 = null; NodeToken n25 = null; Token n26 = null; NodeToken n27 = null; Token n28 = null; // --- user BNFProduction java block --- REndOfFile ef; String image; boolean private_rexp = false; Token t = getToken(1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: n1 = StringLiteral(); image = jtbrt_StringLiteral; c.member = new RStringLiteral(t, image); n0 = new NodeChoice(n1, 0, 4); break; default: jj_la1[35] = jj_gen; if (jj_2_6(3)) { n2 = new NodeSequence(6); image = ""; n4 = jj_consume_token(LANGLE); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 134: case IDENTIFIER: n7 = new NodeOptional(); n6 = new NodeSequence(3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 134: n9 = jj_consume_token(134); n8 = JTBToolkit.makeNodeToken(n9); private_rexp = true; n7.addNode(n8); break; default: jj_la1[33] = jj_gen; ; } n6.addNode(n7); n10 = Identifier(); image = jtbrt_Identifier; n6.addNode(n10); n12 = jj_consume_token(COLON); n11 = JTBToolkit.makeNodeToken(n12); n6.addNode(n11); n5.addNode(n6); break; default: jj_la1[34] = jj_gen; ; } n2.addNode(n5); n13 = ComplexRegularExpressionChoices(c); n2.addNode(n13); n15 = jj_consume_token(RANGLE); n14 = JTBToolkit.makeNodeToken(n15); n2.addNode(n14); RegularExpression_ re; if (c.member instanceof RJustName) { RSequence seq = new RSequence(); seq.units.add((RegularExpression_)c.member); re = seq; } else { re = (RegularExpression_)c.member; } re.label = image; re.private_rexp = private_rexp; re.setLine(t.beginLine); re.setColumn(t.beginColumn); c.member = re; n0 = new NodeChoice(n2, 1, 4); } else if (jj_2_7(2)) { n16 = new NodeSequence(4); n18 = jj_consume_token(LANGLE); n17 = JTBToolkit.makeNodeToken(n18); n16.addNode(n17); n19 = Identifier(); image = jtbrt_Identifier; n16.addNode(n19); n21 = jj_consume_token(RANGLE); n20 = JTBToolkit.makeNodeToken(n21); n16.addNode(n20); c.member = new RJustName(t, image); n0 = new NodeChoice(n16, 2, 4); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n22 = new NodeSequence(4); n24 = jj_consume_token(LANGLE); n23 = JTBToolkit.makeNodeToken(n24); n22.addNode(n23); n26 = jj_consume_token(_EOF); n25 = JTBToolkit.makeNodeToken(n26); n22.addNode(n25); n28 = jj_consume_token(RANGLE); n27 = JTBToolkit.makeNodeToken(n28); n22.addNode(n27); ef = new REndOfFile(); ef.setLine(t.beginLine); ef.setColumn(t.beginColumn); ef.ordinal = 0; c.member = ef; n0 = new NodeChoice(n22, 3, 4); break; default: jj_la1[36] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } {if (true) return new RegularExpression(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all complex_regular_expression_choices into ComplexRegularExpressionChoices to conform to class name convention final public ComplexRegularExpressionChoices ComplexRegularExpressionChoices(Container c1) throws ParseException { // --- JTB generated node declarations --- ComplexRegularExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ComplexRegularExpression n5 = null; // --- user BNFProduction java block --- boolean morethanone = false; RChoice ch = new RChoice(); Container c2 = new Container(); n0 = ComplexRegularExpression(c1); label_11: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_OR: ; break; default: jj_la1[37] = jj_gen; break label_11; } n2 = new NodeSequence(3); n4 = jj_consume_token(BIT_OR); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = ComplexRegularExpression(c2); n2.addNode(n5); if (morethanone) { ch.getChoices().add((RegularExpression_)c2.member); } else { morethanone = true; ch = new RChoice(); ch.setLine(((RegularExpression_)c1.member).getLine()); ch.setColumn(((RegularExpression_)c1.member).getColumn()); ch.getChoices().add((RegularExpression_)c1.member); ch.getChoices().add((RegularExpression_)c2.member); } n1.addNode(n2); } n1.nodes.trimToSize(); if (morethanone) { c1.member = ch; } {if (true) return new ComplexRegularExpressionChoices(n0, n1);} throw new Error("Missing return statement in function"); } // MMa : changed all complex_regular_expression into ComplexRegularExpression to conform to class name convention final public ComplexRegularExpression ComplexRegularExpression(Container c1) throws ParseException { // --- JTB generated node declarations --- NodeList n0 = new NodeList(); ComplexRegularExpressionUnit n1 = null; // --- user BNFProduction java block --- int count = 0; RSequence seq = new RSequence(); Container c2 = new Container(); label_12: while (true) { n1 = ComplexRegularExpressionUnit(c2); count++; if (count == 1) { c1.member = c2.member; // if count does not go beyond 1, we are done. } else if (count == 2) { // more than 1, so create a sequence. seq = new RSequence(); seq.setLine(((RegularExpression_)c1.member).getLine()); seq.setColumn(((RegularExpression_)c1.member).getColumn()); seq.units.add((RegularExpression_)c1.member); seq.units.add((RegularExpression_)c2.member); } else { seq.units.add((RegularExpression_)c2.member); } n0.addNode(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: case LPAREN: case LBRACKET: case LANGLE: case TILDE: ; break; default: jj_la1[38] = jj_gen; break label_12; } } n0.nodes.trimToSize(); if (count > 1) { c1.member = seq; } {if (true) return new ComplexRegularExpression(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all complex_regular_expression_unit into ComplexRegularExpressionUnit to conform to class name convention final public ComplexRegularExpressionUnit ComplexRegularExpressionUnit(Container c) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; StringLiteral n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Identifier n5 = null; NodeToken n6 = null; Token n7 = null; CharacterList n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; ComplexRegularExpressionChoices n12 = null; NodeToken n13 = null; Token n14 = null; NodeOptional n15 = new NodeOptional(); NodeChoice n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeSequence n23 = null; NodeToken n24 = null; Token n25 = null; IntegerLiteral n26 = null; NodeOptional n27 = null; NodeSequence n28 = null; NodeToken n29 = null; Token n30 = null; NodeOptional n31 = null; IntegerLiteral n32 = null; NodeToken n33 = null; Token n34 = null; // --- user BNFProduction java block --- String image; Token t = getToken(1); int r1 = 0, r2 = -1; boolean hasMax = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: n1 = StringLiteral(); image = jtbrt_StringLiteral; c.member = new RStringLiteral(t, image); n0 = new NodeChoice(n1, 0, 4); break; case LANGLE: n2 = new NodeSequence(4); n4 = jj_consume_token(LANGLE); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Identifier(); image = jtbrt_Identifier; n2.addNode(n5); n7 = jj_consume_token(RANGLE); n6 = JTBToolkit.makeNodeToken(n7); n2.addNode(n6); c.member = new RJustName(t, image); n0 = new NodeChoice(n2, 1, 4); break; case LBRACKET: case TILDE: n8 = CharacterList(c); n0 = new NodeChoice(n8, 2, 4); break; case LPAREN: n9 = new NodeSequence(4); n11 = jj_consume_token(LPAREN); n10 = JTBToolkit.makeNodeToken(n11); n9.addNode(n10); n12 = ComplexRegularExpressionChoices(c); n9.addNode(n12); n14 = jj_consume_token(RPAREN); n13 = JTBToolkit.makeNodeToken(n14); n9.addNode(n13); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: case HOOK: case PLUS: case STAR: n27 = new NodeOptional(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: n18 = jj_consume_token(PLUS); n17 = JTBToolkit.makeNodeToken(n18); c.member = new ROneOrMore(t, (RegularExpression_)c.member); n16 = new NodeChoice(n17, 0, 4); break; case STAR: n20 = jj_consume_token(STAR); n19 = JTBToolkit.makeNodeToken(n20); c.member = new RZeroOrMore(t, (RegularExpression_)c.member); n16 = new NodeChoice(n19, 1, 4); break; case HOOK: n22 = jj_consume_token(HOOK); n21 = JTBToolkit.makeNodeToken(n22); RZeroOrOne zorexp = new RZeroOrOne(); zorexp.setLine(t.beginLine); zorexp.setColumn(t.beginColumn); zorexp.regexpr = (RegularExpression_)c.member; c.member = zorexp; n16 = new NodeChoice(n21, 2, 4); break; case LBRACE: n23 = new NodeSequence(5); n25 = jj_consume_token(LBRACE); n24 = JTBToolkit.makeNodeToken(n25); n23.addNode(n24); n26 = IntegerLiteral(); r1 = jtbrt_IntegerLiteral; n23.addNode(n26); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: n31 = new NodeOptional(); n28 = new NodeSequence(3); n30 = jj_consume_token(COMMA); n29 = JTBToolkit.makeNodeToken(n30); n28.addNode(n29); hasMax = true; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: n32 = IntegerLiteral(); r2 = jtbrt_IntegerLiteral; n31.addNode(n32); break; default: jj_la1[39] = jj_gen; ; } n28.addNode(n31); n27.addNode(n28); break; default: jj_la1[40] = jj_gen; ; } n23.addNode(n27); n34 = jj_consume_token(RBRACE); n33 = JTBToolkit.makeNodeToken(n34); n23.addNode(n33); RRepetitionRange rrrexp = new RRepetitionRange(); rrrexp.setLine(t.beginLine); rrrexp.setColumn(t.beginColumn); rrrexp.min = r1; rrrexp.max = r2; rrrexp.hasMax = hasMax; rrrexp.regexpr = (RegularExpression_)c.member; c.member = rrrexp; n16 = new NodeChoice(n23, 3, 4); break; default: jj_la1[41] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n15.addNode(n16); break; default: jj_la1[42] = jj_gen; ; } n9.addNode(n15); n0 = new NodeChoice(n9, 3, 4); break; default: jj_la1[43] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new ComplexRegularExpressionUnit(n0);} throw new Error("Missing return statement in function"); } // MMa : changed all character_list into CharacterList to conform to class name convention final public CharacterList CharacterList(Container c1) throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; CharacterDescriptor n7 = null; NodeListOptional n8 = null; NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; CharacterDescriptor n12 = null; NodeToken n13 = null; Token n14 = null; // --- user BNFProduction java block --- RCharacterList chlist = new RCharacterList(); Token t = getToken(1); chlist.setLine(t.beginLine); chlist.setColumn(t.beginColumn); Container c2 = new Container(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TILDE: n2 = jj_consume_token(TILDE); n1 = JTBToolkit.makeNodeToken(n2); chlist.negated_list = true; n0.addNode(n1); break; default: jj_la1[44] = jj_gen; ; } n4 = jj_consume_token(LBRACKET); n3 = JTBToolkit.makeNodeToken(n4); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: n8 = new NodeListOptional(); n6 = new NodeSequence(3); n7 = CharacterDescriptor(c2); n6.addNode(n7); chlist.descriptors.add(c2.member); label_13: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[45] = jj_gen; break label_13; } n9 = new NodeSequence(3); n11 = jj_consume_token(COMMA); n10 = JTBToolkit.makeNodeToken(n11); n9.addNode(n10); n12 = CharacterDescriptor(c2); n9.addNode(n12); chlist.descriptors.add(c2.member); n8.addNode(n9); } n8.nodes.trimToSize(); n6.addNode(n8); n5.addNode(n6); break; default: jj_la1[46] = jj_gen; ; } n14 = jj_consume_token(RBRACKET); n13 = JTBToolkit.makeNodeToken(n14); c1.member = chlist; {if (true) return new CharacterList(n0, n3, n5, n13);} throw new Error("Missing return statement in function"); } // MMa : changed all character_descriptor into CharacterDescriptor to conform to class name convention final public CharacterDescriptor CharacterDescriptor(Container c) throws ParseException { // --- JTB generated node declarations --- StringLiteral n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; StringLiteral n5 = null; // --- user BNFProduction java block --- char c1, c2 = ' '; // unnecessary initialization to make Java compiler happy! boolean isrange = false; String imageL, imageR; Token t = getToken(1); n0 = StringLiteral(); imageL = jtbrt_StringLiteral; c1 = character_descriptor_assign(getToken(0), imageL); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MINUS: n2 = new NodeSequence(3); n4 = jj_consume_token(MINUS); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = StringLiteral(); imageR = jtbrt_StringLiteral; n2.addNode(n5); isrange = true; c2 = character_descriptor_assign(getToken(0), imageR, imageL); n1.addNode(n2); break; default: jj_la1[47] = jj_gen; ; } if (isrange) { CharacterRange cr = new CharacterRange(); cr.setLine(t.beginLine); cr.setColumn(t.beginColumn); cr.setLeft(c1); cr.setRight(c2); c.member = cr; } else { SingleCharacter sc = new SingleCharacter(); sc.setLine(t.beginLine); sc.setColumn(t.beginColumn); sc.ch = c1; c.member = sc; } {if (true) return new CharacterDescriptor(n0, n1);} throw new Error("Missing return statement in function"); } // MMa : changed all identifier into Identifier to conform to class name convention final public Identifier Identifier() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; // --- user BNFProduction java block --- Token t = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); t = n1; jtbrt_Identifier = t.image; {if (true) return new Identifier(n0);} throw new Error("Missing return statement in function"); } /********************************************** * THE JAVA GRAMMAR SPECIFICATION STARTS HERE * **********************************************/ /* * The Java grammar is modified to use sequences of tokens * for the missing tokens - those that include "<<" and ">>". */ /* * The following production defines Java identifiers - it * includes the reserved words of JavaCC also. */ final public JavaIdentifier JavaIdentifier() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeToken n23 = null; Token n24 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: n2 = jj_consume_token(IDENTIFIER); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 12); break; case _LOOKAHEAD: n4 = jj_consume_token(_LOOKAHEAD); n3 = JTBToolkit.makeNodeToken(n4); n0 = new NodeChoice(n3, 1, 12); break; case _IGNORE_CASE: n6 = jj_consume_token(_IGNORE_CASE); n5 = JTBToolkit.makeNodeToken(n6); n0 = new NodeChoice(n5, 2, 12); break; case _PARSER_BEGIN: n8 = jj_consume_token(_PARSER_BEGIN); n7 = JTBToolkit.makeNodeToken(n8); n0 = new NodeChoice(n7, 3, 12); break; case _PARSER_END: n10 = jj_consume_token(_PARSER_END); n9 = JTBToolkit.makeNodeToken(n10); n0 = new NodeChoice(n9, 4, 12); break; case _JAVACODE: n12 = jj_consume_token(_JAVACODE); n11 = JTBToolkit.makeNodeToken(n12); n0 = new NodeChoice(n11, 5, 12); break; case _TOKEN: n14 = jj_consume_token(_TOKEN); n13 = JTBToolkit.makeNodeToken(n14); n0 = new NodeChoice(n13, 6, 12); break; case _SPECIAL_TOKEN: n16 = jj_consume_token(_SPECIAL_TOKEN); n15 = JTBToolkit.makeNodeToken(n16); n0 = new NodeChoice(n15, 7, 12); break; case _MORE: n18 = jj_consume_token(_MORE); n17 = JTBToolkit.makeNodeToken(n18); n0 = new NodeChoice(n17, 8, 12); break; case _SKIP: n20 = jj_consume_token(_SKIP); n19 = JTBToolkit.makeNodeToken(n20); n0 = new NodeChoice(n19, 9, 12); break; case _TOKEN_MGR_DECLS: n22 = jj_consume_token(_TOKEN_MGR_DECLS); n21 = JTBToolkit.makeNodeToken(n22); n0 = new NodeChoice(n21, 10, 12); break; case _EOF: n24 = jj_consume_token(_EOF); n23 = JTBToolkit.makeNodeToken(n24); n0 = new NodeChoice(n23, 11, 12); break; default: jj_la1[48] = jj_gen; jj_consume_token(-1); throw new ParseException(); } Token retval = getToken(0); retval.kind = IDENTIFIER; jtbrt_JavaIdentifier = retval; {if (true) return new JavaIdentifier(n0);} throw new Error("Missing return statement in function"); } /* * Program structuring syntax follows. */ final public CompilationUnit CompilationUnit() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); PackageDeclaration n1 = null; NodeListOptional n2 = new NodeListOptional(); ImportDeclaration n3 = null; NodeListOptional n4 = new NodeListOptional(); TypeDeclaration n5 = null; // --- user BNFProduction java block --- set_initial_cu_token(getToken(1)); if (jj_2_8(2147483647)) { n1 = PackageDeclaration(); n0.addNode(n1); } else { ; } label_14: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IMPORT: ; break; default: jj_la1[49] = jj_gen; break label_14; } n3 = ImportDeclaration(); n2.addNode(n3); } n2.nodes.trimToSize(); label_15: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case CLASS: case ENUM: case FINAL: case INTERFACE: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case SEMICOLON: case 140: ; break; default: jj_la1[50] = jj_gen; break label_15; } n5 = TypeDeclaration(); n4.addNode(n5); } n4.nodes.trimToSize(); insertionpointerrors(getToken(1)); {if (true) return new CompilationUnit(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public PackageDeclaration PackageDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeListOptional n0 = new NodeListOptional(); Annotation n1 = null; NodeToken n2 = null; Token n3 = null; Name n4 = null; NodeToken n5 = null; Token n6 = null; label_16: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 140: ; break; default: jj_la1[51] = jj_gen; break label_16; } n1 = Annotation(); n0.addNode(n1); } n0.nodes.trimToSize(); n3 = jj_consume_token(PACKAGE); n2 = JTBToolkit.makeNodeToken(n3); n4 = Name(null); n6 = jj_consume_token(SEMICOLON); n5 = JTBToolkit.makeNodeToken(n6); {if (true) return new PackageDeclaration(n0, n2, n4, n5);} throw new Error("Missing return statement in function"); } final public ImportDeclaration ImportDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; Name n5 = null; NodeOptional n6 = new NodeOptional(); NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; n1 = jj_consume_token(IMPORT); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STATIC: n4 = jj_consume_token(STATIC); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); break; default: jj_la1[52] = jj_gen; ; } n5 = Name(null); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOT: n7 = new NodeSequence(2); n9 = jj_consume_token(DOT); n8 = JTBToolkit.makeNodeToken(n9); n7.addNode(n8); n11 = jj_consume_token(STAR); n10 = JTBToolkit.makeNodeToken(n11); n7.addNode(n10); n6.addNode(n7); break; default: jj_la1[53] = jj_gen; ; } n13 = jj_consume_token(SEMICOLON); n12 = JTBToolkit.makeNodeToken(n13); {if (true) return new ImportDeclaration(n0, n2, n5, n6, n12);} throw new Error("Missing return statement in function"); } /* * Modifiers. We match all modifiers in a single rule to reduce the chances of * syntax errors for simple modifier mistakes. It will also enable us to give * better error messages. */ final public Modifiers Modifiers() throws ParseException { // --- JTB generated node declarations --- NodeListOptional n0 = new NodeListOptional(); NodeChoice n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeToken n12 = null; Token n13 = null; NodeToken n14 = null; Token n15 = null; NodeToken n16 = null; Token n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; Annotation n24 = null; // --- user BNFProduction java block --- int modifiers = 0; label_17: while (true) { if (jj_2_9(2)) { ; } else { break label_17; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PUBLIC: n3 = jj_consume_token(PUBLIC); n2 = JTBToolkit.makeNodeToken(n3); modifiers |= ModifierSet.M_PUBLIC; n1 = new NodeChoice(n2, 0, 12); break; case STATIC: n5 = jj_consume_token(STATIC); n4 = JTBToolkit.makeNodeToken(n5); modifiers |= ModifierSet.M_STATIC; n1 = new NodeChoice(n4, 1, 12); break; case PROTECTED: n7 = jj_consume_token(PROTECTED); n6 = JTBToolkit.makeNodeToken(n7); modifiers |= ModifierSet.M_PROTECTED; n1 = new NodeChoice(n6, 2, 12); break; case PRIVATE: n9 = jj_consume_token(PRIVATE); n8 = JTBToolkit.makeNodeToken(n9); modifiers |= ModifierSet.M_PRIVATE; n1 = new NodeChoice(n8, 3, 12); break; case FINAL: n11 = jj_consume_token(FINAL); n10 = JTBToolkit.makeNodeToken(n11); modifiers |= ModifierSet.M_FINAL; n1 = new NodeChoice(n10, 4, 12); break; case ABSTRACT: n13 = jj_consume_token(ABSTRACT); n12 = JTBToolkit.makeNodeToken(n13); modifiers |= ModifierSet.M_ABSTRACT; n1 = new NodeChoice(n12, 5, 12); break; case SYNCHRONIZED: n15 = jj_consume_token(SYNCHRONIZED); n14 = JTBToolkit.makeNodeToken(n15); modifiers |= ModifierSet.M_SYNCHRONIZED; n1 = new NodeChoice(n14, 6, 12); break; case NATIVE: n17 = jj_consume_token(NATIVE); n16 = JTBToolkit.makeNodeToken(n17); modifiers |= ModifierSet.M_NATIVE; n1 = new NodeChoice(n16, 7, 12); break; case TRANSIENT: n19 = jj_consume_token(TRANSIENT); n18 = JTBToolkit.makeNodeToken(n19); modifiers |= ModifierSet.M_TRANSIENT; n1 = new NodeChoice(n18, 8, 12); break; case VOLATILE: n21 = jj_consume_token(VOLATILE); n20 = JTBToolkit.makeNodeToken(n21); modifiers |= ModifierSet.M_VOLATILE; n1 = new NodeChoice(n20, 9, 12); break; case STRICTFP: n23 = jj_consume_token(STRICTFP); n22 = JTBToolkit.makeNodeToken(n23); modifiers |= ModifierSet.M_STRICTFP; n1 = new NodeChoice(n22, 10, 12); break; case 140: n24 = Annotation(); n1 = new NodeChoice(n24, 11, 12); break; default: jj_la1[54] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n0.addNode(n1); } n0.nodes.trimToSize(); jtbrt_Modifiers = modifiers; {if (true) return new Modifiers(n0);} throw new Error("Missing return statement in function"); } /* * Declaration syntax follows. */ final public TypeDeclaration TypeDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeSequence n3 = null; Modifiers n4 = null; NodeChoice n5 = null; ClassOrInterfaceDeclaration n6 = null; EnumDeclaration n7 = null; AnnotationTypeDeclaration n8 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: n2 = jj_consume_token(SEMICOLON); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 2); break; case ABSTRACT: case CLASS: case ENUM: case FINAL: case INTERFACE: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case 140: n3 = new NodeSequence(2); n4 = Modifiers(); n3.addNode(n4); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: case INTERFACE: n6 = ClassOrInterfaceDeclaration(); n5 = new NodeChoice(n6, 0, 3); break; case ENUM: n7 = EnumDeclaration(); n5 = new NodeChoice(n7, 1, 3); break; case 140: n8 = AnnotationTypeDeclaration(); n5 = new NodeChoice(n8, 2, 3); break; default: jj_la1[55] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n3.addNode(n5); n0 = new NodeChoice(n3, 1, 2); break; default: jj_la1[56] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new TypeDeclaration(n0);} throw new Error("Missing return statement in function"); } final public ClassOrInterfaceDeclaration ClassOrInterfaceDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeOptional n7 = new NodeOptional(); TypeParameters n8 = null; NodeOptional n9 = new NodeOptional(); ExtendsList n10 = null; NodeOptional n11 = new NodeOptional(); ImplementsList n12 = null; ClassOrInterfaceBody n13 = null; // --- user BNFProduction java block --- boolean isInterface = false; class_nesting++; Token t; boolean is_parser_class = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: n2 = jj_consume_token(CLASS); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 2); break; case INTERFACE: n4 = jj_consume_token(INTERFACE); n3 = JTBToolkit.makeNodeToken(n4); isInterface = true; n0 = new NodeChoice(n3, 1, 2); break; default: jj_la1[57] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n6 = jj_consume_token(IDENTIFIER); n5 = JTBToolkit.makeNodeToken(n6); t = n6; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n8 = TypeParameters(); n7.addNode(n8); break; default: jj_la1[58] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: n10 = ExtendsList(isInterface); n9.addNode(n10); break; default: jj_la1[59] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IMPLEMENTS: n12 = ImplementsList(isInterface); n11.addNode(n12); break; default: jj_la1[60] = jj_gen; ; } if (t.image.equals(parser_class_name) && class_nesting == 1 && processing_cu) { is_parser_class = true; setinsertionpoint(getToken(1), 1); } n13 = ClassOrInterfaceBody(isInterface, null); if (is_parser_class) { setinsertionpoint(getToken(0), 2); } class_nesting--; {if (true) return new ClassOrInterfaceDeclaration(n0, n5, n7, n9, n11, n13);} throw new Error("Missing return statement in function"); } final public ExtendsList ExtendsList(boolean isInterface) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; // --- user BNFProduction java block --- boolean extendsMoreThanOne = false; n1 = jj_consume_token(EXTENDS); n0 = JTBToolkit.makeNodeToken(n1); n2 = ClassOrInterfaceType(); label_18: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[61] = jj_gen; break label_18; } n4 = new NodeSequence(3); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = ClassOrInterfaceType(); n4.addNode(n7); extendsMoreThanOne = true; n3.addNode(n4); } n3.nodes.trimToSize(); if (extendsMoreThanOne && !isInterface) {if (true) throw new ParseException("A class cannot extend more than one other class");} {if (true) return new ExtendsList(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public ImplementsList ImplementsList(boolean isInterface) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; n1 = jj_consume_token(IMPLEMENTS); n0 = JTBToolkit.makeNodeToken(n1); n2 = ClassOrInterfaceType(); label_19: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[62] = jj_gen; break label_19; } n4 = new NodeSequence(2); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = ClassOrInterfaceType(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); if (isInterface) {if (true) throw new ParseException("An interface cannot implement other interfaces");} {if (true) return new ImplementsList(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public EnumDeclaration EnumDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeOptional n4 = new NodeOptional(); ImplementsList n5 = null; EnumBody n6 = null; n1 = jj_consume_token(ENUM); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(IDENTIFIER); n2 = JTBToolkit.makeNodeToken(n3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IMPLEMENTS: n5 = ImplementsList(false); n4.addNode(n5); break; default: jj_la1[63] = jj_gen; ; } n6 = EnumBody(); {if (true) return new EnumDeclaration(n0, n2, n4, n6);} throw new Error("Missing return statement in function"); } final public EnumBody EnumBody() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; EnumConstant n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; EnumConstant n9 = null; NodeOptional n10 = new NodeOptional(); NodeToken n11 = null; Token n12 = null; NodeOptional n13 = new NodeOptional(); NodeSequence n14 = null; NodeToken n15 = null; Token n16 = null; NodeListOptional n17 = null; ClassOrInterfaceBodyDeclaration n18 = null; NodeToken n19 = null; Token n20 = null; n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case FINAL: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case 140: case IDENTIFIER: n5 = new NodeListOptional(); n3 = new NodeSequence(2); n4 = EnumConstant(); n3.addNode(n4); label_20: while (true) { if (jj_2_10(2)) { ; } else { break label_20; } n6 = new NodeSequence(2); n8 = jj_consume_token(COMMA); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = EnumConstant(); n6.addNode(n9); n5.addNode(n6); } n5.nodes.trimToSize(); n3.addNode(n5); n2.addNode(n3); break; default: jj_la1[64] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: n12 = jj_consume_token(COMMA); n11 = JTBToolkit.makeNodeToken(n12); n10.addNode(n11); break; default: jj_la1[65] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: n17 = new NodeListOptional(); n14 = new NodeSequence(2); n16 = jj_consume_token(SEMICOLON); n15 = JTBToolkit.makeNodeToken(n16); n14.addNode(n15); label_21: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case CLASS: case DOUBLE: case ENUM: case FINAL: case FLOAT: case INT: case INTERFACE: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOID: case VOLATILE: case LBRACE: case SEMICOLON: case LANGLE: case 140: case IDENTIFIER: ; break; default: jj_la1[66] = jj_gen; break label_21; } n18 = ClassOrInterfaceBodyDeclaration(false); n17.addNode(n18); } n17.nodes.trimToSize(); n14.addNode(n17); n13.addNode(n14); break; default: jj_la1[67] = jj_gen; ; } n20 = jj_consume_token(RBRACE); n19 = JTBToolkit.makeNodeToken(n20); {if (true) return new EnumBody(n0, n2, n10, n13, n19);} throw new Error("Missing return statement in function"); } final public EnumConstant EnumConstant() throws ParseException { // --- JTB generated node declarations --- Modifiers n0 = null; NodeToken n1 = null; Token n2 = null; NodeOptional n3 = new NodeOptional(); Arguments n4 = null; NodeOptional n5 = new NodeOptional(); ClassOrInterfaceBody n6 = null; n0 = Modifiers(); n2 = jj_consume_token(IDENTIFIER); n1 = JTBToolkit.makeNodeToken(n2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: n4 = Arguments(null); n3.addNode(n4); break; default: jj_la1[68] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: n6 = ClassOrInterfaceBody(false, null); n5.addNode(n6); break; default: jj_la1[69] = jj_gen; ; } {if (true) return new EnumConstant(n0, n1, n3, n5);} throw new Error("Missing return statement in function"); } final public TypeParameters TypeParameters() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeParameter n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; TypeParameter n7 = null; NodeToken n8 = null; Token n9 = null; n1 = jj_consume_token(LANGLE); n0 = JTBToolkit.makeNodeToken(n1); n2 = TypeParameter(); label_22: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[70] = jj_gen; break label_22; } n4 = new NodeSequence(2); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = TypeParameter(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); n9 = jj_consume_token(RANGLE); n8 = JTBToolkit.makeNodeToken(n9); {if (true) return new TypeParameters(n0, n2, n3, n8);} throw new Error("Missing return statement in function"); } final public TypeParameter TypeParameter() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); TypeBound n3 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: n3 = TypeBound(); n2.addNode(n3); break; default: jj_la1[71] = jj_gen; ; } {if (true) return new TypeParameter(n0, n2);} throw new Error("Missing return statement in function"); } final public TypeBound TypeBound() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; ClassOrInterfaceType n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; ClassOrInterfaceType n7 = null; n1 = jj_consume_token(EXTENDS); n0 = JTBToolkit.makeNodeToken(n1); n2 = ClassOrInterfaceType(); label_23: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: ; break; default: jj_la1[72] = jj_gen; break label_23; } n4 = new NodeSequence(2); n6 = jj_consume_token(BIT_AND); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = ClassOrInterfaceType(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); {if (true) return new TypeBound(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public ClassOrInterfaceBody ClassOrInterfaceBody(boolean isInterface, List tokens) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); ClassOrInterfaceBodyDeclaration n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); first = getToken(1); label_24: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case CLASS: case DOUBLE: case ENUM: case FINAL: case FLOAT: case INT: case INTERFACE: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOID: case VOLATILE: case LBRACE: case SEMICOLON: case LANGLE: case 140: case IDENTIFIER: ; break; default: jj_la1[73] = jj_gen; break label_24; } n3 = ClassOrInterfaceBodyDeclaration(isInterface); n2.addNode(n3); } n2.nodes.trimToSize(); last = getToken(0); n5 = jj_consume_token(RBRACE); n4 = JTBToolkit.makeNodeToken(n5); if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } {if (true) return new ClassOrInterfaceBody(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public ClassOrInterfaceBodyDeclaration ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; Initializer n1 = null; NodeSequence n2 = null; Modifiers n3 = null; NodeChoice n4 = null; ClassOrInterfaceDeclaration n5 = null; EnumDeclaration n6 = null; ConstructorDeclaration n7 = null; FieldDeclaration n8 = null; MethodDeclaration n9 = null; NodeToken n10 = null; Token n11 = null; if (jj_2_13(2)) { n1 = Initializer(); if (isInterface) {if (true) throw new ParseException("An interface cannot have initializers");} n0 = new NodeChoice(n1, 0, 3); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case CLASS: case DOUBLE: case ENUM: case FINAL: case FLOAT: case INT: case INTERFACE: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOID: case VOLATILE: case LANGLE: case 140: case IDENTIFIER: n2 = new NodeSequence(2); n3 = Modifiers(); n2.addNode(n3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: case INTERFACE: n5 = ClassOrInterfaceDeclaration(); n4 = new NodeChoice(n5, 0, 5); break; case ENUM: n6 = EnumDeclaration(); n4 = new NodeChoice(n6, 1, 5); break; default: jj_la1[74] = jj_gen; if (jj_2_11(2147483647)) { n7 = ConstructorDeclaration(); n4 = new NodeChoice(n7, 2, 5); } else if (jj_2_12(2147483647)) { n8 = FieldDeclaration(); n4 = new NodeChoice(n8, 3, 5); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: case VOID: case LANGLE: case IDENTIFIER: n9 = MethodDeclaration(); n4 = new NodeChoice(n9, 4, 5); break; default: jj_la1[75] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } n2.addNode(n4); n0 = new NodeChoice(n2, 1, 3); break; case SEMICOLON: n11 = jj_consume_token(SEMICOLON); n10 = JTBToolkit.makeNodeToken(n11); n0 = new NodeChoice(n10, 2, 3); break; default: jj_la1[76] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new ClassOrInterfaceBodyDeclaration(n0);} throw new Error("Missing return statement in function"); } final public FieldDeclaration FieldDeclaration() throws ParseException { // --- JTB generated node declarations --- Type n0 = null; VariableDeclarator n1 = null; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; VariableDeclarator n6 = null; NodeToken n7 = null; Token n8 = null; n0 = Type(); n1 = VariableDeclarator(); label_25: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[77] = jj_gen; break label_25; } n3 = new NodeSequence(2); n5 = jj_consume_token(COMMA); n4 = JTBToolkit.makeNodeToken(n5); n3.addNode(n4); n6 = VariableDeclarator(); n3.addNode(n6); n2.addNode(n3); } n2.nodes.trimToSize(); n8 = jj_consume_token(SEMICOLON); n7 = JTBToolkit.makeNodeToken(n8); {if (true) return new FieldDeclaration(n0, n1, n2, n7);} throw new Error("Missing return statement in function"); } final public VariableDeclarator VariableDeclarator() throws ParseException { // --- JTB generated node declarations --- VariableDeclaratorId n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; VariableInitializer n5 = null; n0 = VariableDeclaratorId(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: n2 = new NodeSequence(2); n4 = jj_consume_token(ASSIGN); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = VariableInitializer(); n2.addNode(n5); n1.addNode(n2); break; default: jj_la1[78] = jj_gen; ; } {if (true) return new VariableDeclarator(n0, n1);} throw new Error("Missing return statement in function"); } final public VariableDeclaratorId VariableDeclaratorId() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); label_26: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: ; break; default: jj_la1[79] = jj_gen; break label_26; } n3 = new NodeSequence(2); n5 = jj_consume_token(LBRACKET); n4 = JTBToolkit.makeNodeToken(n5); n3.addNode(n4); n7 = jj_consume_token(RBRACKET); n6 = JTBToolkit.makeNodeToken(n7); n3.addNode(n6); n2.addNode(n3); } n2.nodes.trimToSize(); {if (true) return new VariableDeclaratorId(n0, n2);} throw new Error("Missing return statement in function"); } final public VariableInitializer VariableInitializer() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; ArrayInitializer n1 = null; Expression n2 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: n1 = ArrayInitializer(); n0 = new NodeChoice(n1, 0, 2); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n2 = Expression(null); n0 = new NodeChoice(n2, 1, 2); break; default: jj_la1[80] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new VariableInitializer(n0);} throw new Error("Missing return statement in function"); } final public ArrayInitializer ArrayInitializer() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; VariableInitializer n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; VariableInitializer n9 = null; NodeOptional n10 = new NodeOptional(); NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case LBRACE: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n5 = new NodeListOptional(); n3 = new NodeSequence(2); n4 = VariableInitializer(); n3.addNode(n4); label_27: while (true) { if (jj_2_14(2)) { ; } else { break label_27; } n6 = new NodeSequence(2); n8 = jj_consume_token(COMMA); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = VariableInitializer(); n6.addNode(n9); n5.addNode(n6); } n5.nodes.trimToSize(); n3.addNode(n5); n2.addNode(n3); break; default: jj_la1[81] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: n12 = jj_consume_token(COMMA); n11 = JTBToolkit.makeNodeToken(n12); n10.addNode(n11); break; default: jj_la1[82] = jj_gen; ; } n14 = jj_consume_token(RBRACE); n13 = JTBToolkit.makeNodeToken(n14); {if (true) return new ArrayInitializer(n0, n2, n10, n13);} throw new Error("Missing return statement in function"); } final public MethodDeclaration MethodDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); TypeParameters n1 = null; ResultType n2 = null; MethodDeclarator n3 = null; NodeOptional n4 = new NodeOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; NameList n8 = null; NodeChoice n9 = null; Block n10 = null; NodeToken n11 = null; Token n12 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n1 = TypeParameters(); n0.addNode(n1); break; default: jj_la1[83] = jj_gen; ; } n2 = ResultType(null); n3 = MethodDeclarator(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case THROWS: n5 = new NodeSequence(2); n7 = jj_consume_token(THROWS); n6 = JTBToolkit.makeNodeToken(n7); n5.addNode(n6); n8 = NameList(); n5.addNode(n8); n4.addNode(n5); break; default: jj_la1[84] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: n10 = Block(null); n9 = new NodeChoice(n10, 0, 2); break; case SEMICOLON: n12 = jj_consume_token(SEMICOLON); n11 = JTBToolkit.makeNodeToken(n12); n9 = new NodeChoice(n11, 1, 2); break; default: jj_la1[85] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new MethodDeclaration(n0, n2, n3, n4, n9);} throw new Error("Missing return statement in function"); } final public MethodDeclarator MethodDeclarator() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; FormalParameters n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); n2 = FormalParameters(null); label_28: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: ; break; default: jj_la1[86] = jj_gen; break label_28; } n4 = new NodeSequence(2); n6 = jj_consume_token(LBRACKET); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n8 = jj_consume_token(RBRACKET); n7 = JTBToolkit.makeNodeToken(n8); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); {if (true) return new MethodDeclarator(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public FormalParameters FormalParameters(List tokens) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeSequence n3 = null; FormalParameter n4 = null; NodeListOptional n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; FormalParameter n9 = null; NodeToken n10 = null; Token n11 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); n1 = jj_consume_token(LPAREN); n0 = JTBToolkit.makeNodeToken(n1); first = getToken(1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FINAL: case FLOAT: case INT: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case 140: case IDENTIFIER: n5 = new NodeListOptional(); n3 = new NodeSequence(2); n4 = FormalParameter(); n3.addNode(n4); label_29: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[87] = jj_gen; break label_29; } n6 = new NodeSequence(2); n8 = jj_consume_token(COMMA); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = FormalParameter(); n6.addNode(n9); n5.addNode(n6); } n5.nodes.trimToSize(); n3.addNode(n5); n2.addNode(n3); break; default: jj_la1[88] = jj_gen; ; } last = getToken(0); n11 = jj_consume_token(RPAREN); n10 = JTBToolkit.makeNodeToken(n11); if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } {if (true) return new FormalParameters(n0, n2, n10);} throw new Error("Missing return statement in function"); } final public FormalParameter FormalParameter() throws ParseException { // --- JTB generated node declarations --- Modifiers n0 = null; Type n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; VariableDeclaratorId n5 = null; n0 = Modifiers(); n1 = Type(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 135: n4 = jj_consume_token(135); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); break; default: jj_la1[89] = jj_gen; ; } n5 = VariableDeclaratorId(); {if (true) return new FormalParameter(n0, n1, n2, n5);} throw new Error("Missing return statement in function"); } final public ConstructorDeclaration ConstructorDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); TypeParameters n1 = null; NodeToken n2 = null; Token n3 = null; FormalParameters n4 = null; NodeOptional n5 = new NodeOptional(); NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; NameList n9 = null; NodeToken n10 = null; Token n11 = null; NodeOptional n12 = new NodeOptional(); ExplicitConstructorInvocation n13 = null; NodeListOptional n14 = new NodeListOptional(); BlockStatement n15 = null; NodeToken n16 = null; Token n17 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n1 = TypeParameters(); n0.addNode(n1); break; default: jj_la1[90] = jj_gen; ; } n3 = jj_consume_token(IDENTIFIER); n2 = JTBToolkit.makeNodeToken(n3); n4 = FormalParameters(null); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case THROWS: n6 = new NodeSequence(2); n8 = jj_consume_token(THROWS); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = NameList(); n6.addNode(n9); n5.addNode(n6); break; default: jj_la1[91] = jj_gen; ; } n11 = jj_consume_token(LBRACE); n10 = JTBToolkit.makeNodeToken(n11); if (jj_2_15(2147483647)) { n13 = ExplicitConstructorInvocation(); n12.addNode(n13); } else { ; } label_30: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ABSTRACT: case ASSERT: case BOOLEAN: case BREAK: case BYTE: case CHAR: case CLASS: case CONTINUE: case DO: case DOUBLE: case FALSE: case FINAL: case FLOAT: case FOR: case IF: case INT: case INTERFACE: case LONG: case NATIVE: case NEW: case NULL: case PRIVATE: case PROTECTED: case PUBLIC: case RETURN: case SHORT: case STATIC: case STRICTFP: case SUPER: case SWITCH: case SYNCHRONIZED: case THIS: case THROW: case TRANSIENT: case TRUE: case TRY: case VOID: case VOLATILE: case WHILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case LBRACE: case SEMICOLON: case INCR: case DECR: case 140: case IDENTIFIER: ; break; default: jj_la1[92] = jj_gen; break label_30; } n15 = BlockStatement(); n14.addNode(n15); } n14.nodes.trimToSize(); n17 = jj_consume_token(RBRACE); n16 = JTBToolkit.makeNodeToken(n17); {if (true) return new ConstructorDeclaration(n0, n2, n4, n5, n10, n12, n14, n16);} throw new Error("Missing return statement in function"); } final public ExplicitConstructorInvocation ExplicitConstructorInvocation() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Arguments n4 = null; NodeToken n5 = null; Token n6 = null; NodeSequence n7 = null; NodeOptional n8 = new NodeOptional(); NodeSequence n9 = null; PrimaryExpression n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; Arguments n15 = null; NodeToken n16 = null; Token n17 = null; if (jj_2_17(2147483647)) { n1 = new NodeSequence(3); n3 = jj_consume_token(THIS); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = Arguments(null); n1.addNode(n4); n6 = jj_consume_token(SEMICOLON); n5 = JTBToolkit.makeNodeToken(n6); n1.addNode(n5); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case IDENTIFIER: n7 = new NodeSequence(4); if (jj_2_16(2)) { n9 = new NodeSequence(2); n10 = PrimaryExpression(); n9.addNode(n10); n12 = jj_consume_token(DOT); n11 = JTBToolkit.makeNodeToken(n12); n9.addNode(n11); n8.addNode(n9); } else { ; } n7.addNode(n8); n14 = jj_consume_token(SUPER); n13 = JTBToolkit.makeNodeToken(n14); n7.addNode(n13); n15 = Arguments(null); n7.addNode(n15); n17 = jj_consume_token(SEMICOLON); n16 = JTBToolkit.makeNodeToken(n17); n7.addNode(n16); n0 = new NodeChoice(n7, 1, 2); break; default: jj_la1[93] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new ExplicitConstructorInvocation(n0);} throw new Error("Missing return statement in function"); } final public Initializer Initializer() throws ParseException { // --- JTB generated node declarations --- NodeOptional n0 = new NodeOptional(); NodeToken n1 = null; Token n2 = null; Block n3 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STATIC: n2 = jj_consume_token(STATIC); n1 = JTBToolkit.makeNodeToken(n2); n0.addNode(n1); break; default: jj_la1[94] = jj_gen; ; } n3 = Block(null); {if (true) return new Initializer(n0, n3);} throw new Error("Missing return statement in function"); } /* * Type, name and expression syntax follows. */ final public Type Type() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; ReferenceType n1 = null; PrimitiveType n2 = null; if (jj_2_18(2)) { n1 = ReferenceType(); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: n2 = PrimitiveType(); n0 = new NodeChoice(n2, 1, 2); break; default: jj_la1[95] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new Type(n0);} throw new Error("Missing return statement in function"); } final public ReferenceType ReferenceType() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; PrimitiveType n2 = null; NodeList n3 = new NodeList(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeSequence n9 = null; ClassOrInterfaceType n10 = null; NodeListOptional n11 = new NodeListOptional(); NodeSequence n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: n1 = new NodeSequence(2); n2 = PrimitiveType(); n1.addNode(n2); label_31: while (true) { n4 = new NodeSequence(2); n6 = jj_consume_token(LBRACKET); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n8 = jj_consume_token(RBRACKET); n7 = JTBToolkit.makeNodeToken(n8); n4.addNode(n7); n3.addNode(n4); if (jj_2_19(2)) { ; } else { break label_31; } } n3.nodes.trimToSize(); n1.addNode(n3); n0 = new NodeChoice(n1, 0, 2); break; case IDENTIFIER: n9 = new NodeSequence(2); n10 = ClassOrInterfaceType(); n9.addNode(n10); label_32: while (true) { if (jj_2_20(2)) { ; } else { break label_32; } n12 = new NodeSequence(2); n14 = jj_consume_token(LBRACKET); n13 = JTBToolkit.makeNodeToken(n14); n12.addNode(n13); n16 = jj_consume_token(RBRACKET); n15 = JTBToolkit.makeNodeToken(n16); n12.addNode(n15); n11.addNode(n12); } n11.nodes.trimToSize(); n9.addNode(n11); n0 = new NodeChoice(n9, 1, 2); break; default: jj_la1[96] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new ReferenceType(n0);} throw new Error("Missing return statement in function"); } final public ClassOrInterfaceType ClassOrInterfaceType() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); TypeArguments n3 = null; NodeListOptional n4 = new NodeListOptional(); NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeOptional n10 = null; TypeArguments n11 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); if (jj_2_21(2)) { n3 = TypeArguments(); n2.addNode(n3); } else { ; } label_33: while (true) { if (jj_2_22(2)) { ; } else { break label_33; } n10 = new NodeOptional(); n5 = new NodeSequence(3); n7 = jj_consume_token(DOT); n6 = JTBToolkit.makeNodeToken(n7); n5.addNode(n6); n9 = jj_consume_token(IDENTIFIER); n8 = JTBToolkit.makeNodeToken(n9); n5.addNode(n8); if (jj_2_23(2)) { n11 = TypeArguments(); n10.addNode(n11); } else { ; } n5.addNode(n10); n4.addNode(n5); } n4.nodes.trimToSize(); {if (true) return new ClassOrInterfaceType(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public TypeArguments TypeArguments() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeArgument n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; TypeArgument n7 = null; NodeToken n8 = null; Token n9 = null; n1 = jj_consume_token(LANGLE); n0 = JTBToolkit.makeNodeToken(n1); n2 = TypeArgument(); label_34: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[97] = jj_gen; break label_34; } n4 = new NodeSequence(2); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = TypeArgument(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); n9 = jj_consume_token(RANGLE); n8 = JTBToolkit.makeNodeToken(n9); {if (true) return new TypeArguments(n0, n2, n3, n8);} throw new Error("Missing return statement in function"); } final public TypeArgument TypeArgument() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; ReferenceType n1 = null; NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); WildcardBounds n6 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: case IDENTIFIER: n1 = ReferenceType(); n0 = new NodeChoice(n1, 0, 2); break; case HOOK: n2 = new NodeSequence(2); n4 = jj_consume_token(HOOK); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: case SUPER: n6 = WildcardBounds(); n5.addNode(n6); break; default: jj_la1[98] = jj_gen; ; } n2.addNode(n5); n0 = new NodeChoice(n2, 1, 2); break; default: jj_la1[99] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new TypeArgument(n0);} throw new Error("Missing return statement in function"); } final public WildcardBounds WildcardBounds() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; ReferenceType n4 = null; NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; ReferenceType n8 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: n1 = new NodeSequence(2); n3 = jj_consume_token(EXTENDS); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = ReferenceType(); n1.addNode(n4); n0 = new NodeChoice(n1, 0, 2); break; case SUPER: n5 = new NodeSequence(2); n7 = jj_consume_token(SUPER); n6 = JTBToolkit.makeNodeToken(n7); n5.addNode(n6); n8 = ReferenceType(); n5.addNode(n8); n0 = new NodeChoice(n5, 1, 2); break; default: jj_la1[100] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new WildcardBounds(n0);} throw new Error("Missing return statement in function"); } final public PrimitiveType PrimitiveType() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: n2 = jj_consume_token(BOOLEAN); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 8); break; case CHAR: n4 = jj_consume_token(CHAR); n3 = JTBToolkit.makeNodeToken(n4); n0 = new NodeChoice(n3, 1, 8); break; case BYTE: n6 = jj_consume_token(BYTE); n5 = JTBToolkit.makeNodeToken(n6); n0 = new NodeChoice(n5, 2, 8); break; case SHORT: n8 = jj_consume_token(SHORT); n7 = JTBToolkit.makeNodeToken(n8); n0 = new NodeChoice(n7, 3, 8); break; case INT: n10 = jj_consume_token(INT); n9 = JTBToolkit.makeNodeToken(n10); n0 = new NodeChoice(n9, 4, 8); break; case LONG: n12 = jj_consume_token(LONG); n11 = JTBToolkit.makeNodeToken(n12); n0 = new NodeChoice(n11, 5, 8); break; case FLOAT: n14 = jj_consume_token(FLOAT); n13 = JTBToolkit.makeNodeToken(n14); n0 = new NodeChoice(n13, 6, 8); break; case DOUBLE: n16 = jj_consume_token(DOUBLE); n15 = JTBToolkit.makeNodeToken(n16); n0 = new NodeChoice(n15, 7, 8); break; default: jj_la1[101] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new PrimitiveType(n0);} throw new Error("Missing return statement in function"); } final public ResultType ResultType(List tokens) throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; Type n3 = null; // --- user BNFProduction java block --- Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VOID: n2 = jj_consume_token(VOID); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 2); break; case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: case IDENTIFIER: n3 = Type(); n0 = new NodeChoice(n3, 1, 2); break; default: jj_la1[102] = jj_gen; jj_consume_token(-1); throw new ParseException(); } Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } {if (true) return new ResultType(n0);} throw new Error("Missing return statement in function"); } final public Name Name(List tokens) throws ParseException { // --- JTB generated node declarations --- JavaIdentifier n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; JavaIdentifier n5 = null; // --- user BNFProduction java block --- if (tokens == null) tokens = new ArrayList(); Token first = getToken(1); n0 = JavaIdentifier(); label_35: while (true) { if (jj_2_24(2)) { ; } else { break label_35; } n2 = new NodeSequence(2); n4 = jj_consume_token(DOT); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = JavaIdentifier(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } {if (true) return new Name(n0, n1);} throw new Error("Missing return statement in function"); } final public NameList NameList() throws ParseException { // --- JTB generated node declarations --- Name n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Name n5 = null; n0 = Name(null); label_36: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[103] = jj_gen; break label_36; } n2 = new NodeSequence(2); n4 = jj_consume_token(COMMA); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Name(null); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new NameList(n0, n1);} throw new Error("Missing return statement in function"); } /* * Expression syntax follows. */ final public Expression Expression(List tokens) throws ParseException { // --- JTB generated node declarations --- ConditionalExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; AssignmentOperator n3 = null; Expression n4 = null; // --- user BNFProduction java block --- Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); n0 = ConditionalExpression(); if (jj_2_25(2)) { n2 = new NodeSequence(2); n3 = AssignmentOperator(); n2.addNode(n3); n4 = Expression(null); n2.addNode(n4); n1.addNode(n2); } else { ; } Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } {if (true) return new Expression(n0, n1);} throw new Error("Missing return statement in function"); } final public AssignmentOperator AssignmentOperator() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeToken n15 = null; Token n16 = null; NodeToken n17 = null; Token n18 = null; NodeToken n19 = null; Token n20 = null; NodeToken n21 = null; Token n22 = null; NodeToken n23 = null; Token n24 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: n2 = jj_consume_token(ASSIGN); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 12); break; case STARASSIGN: n4 = jj_consume_token(STARASSIGN); n3 = JTBToolkit.makeNodeToken(n4); n0 = new NodeChoice(n3, 1, 12); break; case SLASHASSIGN: n6 = jj_consume_token(SLASHASSIGN); n5 = JTBToolkit.makeNodeToken(n6); n0 = new NodeChoice(n5, 2, 12); break; case REMASSIGN: n8 = jj_consume_token(REMASSIGN); n7 = JTBToolkit.makeNodeToken(n8); n0 = new NodeChoice(n7, 3, 12); break; case PLUSASSIGN: n10 = jj_consume_token(PLUSASSIGN); n9 = JTBToolkit.makeNodeToken(n10); n0 = new NodeChoice(n9, 4, 12); break; case MINUSASSIGN: n12 = jj_consume_token(MINUSASSIGN); n11 = JTBToolkit.makeNodeToken(n12); n0 = new NodeChoice(n11, 5, 12); break; case 136: n14 = jj_consume_token(136); n13 = JTBToolkit.makeNodeToken(n14); n0 = new NodeChoice(n13, 6, 12); break; case 137: n16 = jj_consume_token(137); n15 = JTBToolkit.makeNodeToken(n16); n0 = new NodeChoice(n15, 7, 12); break; case 138: n18 = jj_consume_token(138); n17 = JTBToolkit.makeNodeToken(n18); n0 = new NodeChoice(n17, 8, 12); break; case ANDASSIGN: n20 = jj_consume_token(ANDASSIGN); n19 = JTBToolkit.makeNodeToken(n20); n0 = new NodeChoice(n19, 9, 12); break; case XORASSIGN: n22 = jj_consume_token(XORASSIGN); n21 = JTBToolkit.makeNodeToken(n22); n0 = new NodeChoice(n21, 10, 12); break; case ORASSIGN: n24 = jj_consume_token(ORASSIGN); n23 = JTBToolkit.makeNodeToken(n24); n0 = new NodeChoice(n23, 11, 12); break; default: jj_la1[104] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new AssignmentOperator(n0);} throw new Error("Missing return statement in function"); } final public ConditionalExpression ConditionalExpression() throws ParseException { // --- JTB generated node declarations --- ConditionalOrExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expression n5 = null; NodeToken n6 = null; Token n7 = null; Expression n8 = null; n0 = ConditionalOrExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case HOOK: n2 = new NodeSequence(4); n4 = jj_consume_token(HOOK); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Expression(null); n2.addNode(n5); n7 = jj_consume_token(COLON); n6 = JTBToolkit.makeNodeToken(n7); n2.addNode(n6); n8 = Expression(null); n2.addNode(n8); n1.addNode(n2); break; default: jj_la1[105] = jj_gen; ; } {if (true) return new ConditionalExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public ConditionalOrExpression ConditionalOrExpression() throws ParseException { // --- JTB generated node declarations --- ConditionalAndExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ConditionalAndExpression n5 = null; n0 = ConditionalAndExpression(); label_37: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SC_OR: ; break; default: jj_la1[106] = jj_gen; break label_37; } n2 = new NodeSequence(2); n4 = jj_consume_token(SC_OR); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = ConditionalAndExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new ConditionalOrExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public ConditionalAndExpression ConditionalAndExpression() throws ParseException { // --- JTB generated node declarations --- InclusiveOrExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; InclusiveOrExpression n5 = null; n0 = InclusiveOrExpression(); label_38: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SC_AND: ; break; default: jj_la1[107] = jj_gen; break label_38; } n2 = new NodeSequence(2); n4 = jj_consume_token(SC_AND); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = InclusiveOrExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new ConditionalAndExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public InclusiveOrExpression InclusiveOrExpression() throws ParseException { // --- JTB generated node declarations --- ExclusiveOrExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; ExclusiveOrExpression n5 = null; n0 = ExclusiveOrExpression(); label_39: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_OR: ; break; default: jj_la1[108] = jj_gen; break label_39; } n2 = new NodeSequence(2); n4 = jj_consume_token(BIT_OR); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = ExclusiveOrExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new InclusiveOrExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public ExclusiveOrExpression ExclusiveOrExpression() throws ParseException { // --- JTB generated node declarations --- AndExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; AndExpression n5 = null; n0 = AndExpression(); label_40: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case XOR: ; break; default: jj_la1[109] = jj_gen; break label_40; } n2 = new NodeSequence(2); n4 = jj_consume_token(XOR); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = AndExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new ExclusiveOrExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public AndExpression AndExpression() throws ParseException { // --- JTB generated node declarations --- EqualityExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; EqualityExpression n5 = null; n0 = EqualityExpression(); label_41: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: ; break; default: jj_la1[110] = jj_gen; break label_41; } n2 = new NodeSequence(2); n4 = jj_consume_token(BIT_AND); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = EqualityExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new AndExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public EqualityExpression EqualityExpression() throws ParseException { // --- JTB generated node declarations --- InstanceOfExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; InstanceOfExpression n8 = null; n0 = InstanceOfExpression(); label_42: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ: case NE: ; break; default: jj_la1[111] = jj_gen; break label_42; } n2 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQ: n5 = jj_consume_token(EQ); n4 = JTBToolkit.makeNodeToken(n5); n3 = new NodeChoice(n4, 0, 2); break; case NE: n7 = jj_consume_token(NE); n6 = JTBToolkit.makeNodeToken(n7); n3 = new NodeChoice(n6, 1, 2); break; default: jj_la1[112] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n2.addNode(n3); n8 = InstanceOfExpression(); n2.addNode(n8); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new EqualityExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public InstanceOfExpression InstanceOfExpression() throws ParseException { // --- JTB generated node declarations --- RelationalExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Type n5 = null; n0 = RelationalExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INSTANCEOF: n2 = new NodeSequence(2); n4 = jj_consume_token(INSTANCEOF); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Type(); n2.addNode(n5); n1.addNode(n2); break; default: jj_la1[113] = jj_gen; ; } {if (true) return new InstanceOfExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public RelationalExpression RelationalExpression() throws ParseException { // --- JTB generated node declarations --- ShiftExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; ShiftExpression n12 = null; n0 = ShiftExpression(); label_43: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: case LE: case GE: case RANGLE: ; break; default: jj_la1[114] = jj_gen; break label_43; } n2 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n5 = jj_consume_token(LANGLE); n4 = JTBToolkit.makeNodeToken(n5); n3 = new NodeChoice(n4, 0, 4); break; case RANGLE: n7 = jj_consume_token(RANGLE); n6 = JTBToolkit.makeNodeToken(n7); n3 = new NodeChoice(n6, 1, 4); break; case LE: n9 = jj_consume_token(LE); n8 = JTBToolkit.makeNodeToken(n9); n3 = new NodeChoice(n8, 2, 4); break; case GE: n11 = jj_consume_token(GE); n10 = JTBToolkit.makeNodeToken(n11); n3 = new NodeChoice(n10, 3, 4); break; default: jj_la1[115] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n2.addNode(n3); n12 = ShiftExpression(); n2.addNode(n12); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new RelationalExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public ShiftExpression ShiftExpression() throws ParseException { // --- JTB generated node declarations --- AdditiveExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; RSIGNEDSHIFT n6 = null; RUNSIGNEDSHIFT n7 = null; AdditiveExpression n8 = null; n0 = AdditiveExpression(); label_44: while (true) { if (jj_2_26(1)) { ; } else { break label_44; } n2 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 139: n5 = jj_consume_token(139); n4 = JTBToolkit.makeNodeToken(n5); n3 = new NodeChoice(n4, 0, 3); break; default: jj_la1[116] = jj_gen; if (jj_2_27(1)) { n6 = RSIGNEDSHIFT(); n3 = new NodeChoice(n6, 1, 3); } else if (jj_2_28(1)) { n7 = RUNSIGNEDSHIFT(); n3 = new NodeChoice(n7, 2, 3); } else { jj_consume_token(-1); throw new ParseException(); } } n2.addNode(n3); n8 = AdditiveExpression(); n2.addNode(n8); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new ShiftExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public AdditiveExpression AdditiveExpression() throws ParseException { // --- JTB generated node declarations --- MultiplicativeExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; MultiplicativeExpression n8 = null; n0 = MultiplicativeExpression(); label_45: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: case MINUS: ; break; default: jj_la1[117] = jj_gen; break label_45; } n2 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: n5 = jj_consume_token(PLUS); n4 = JTBToolkit.makeNodeToken(n5); n3 = new NodeChoice(n4, 0, 2); break; case MINUS: n7 = jj_consume_token(MINUS); n6 = JTBToolkit.makeNodeToken(n7); n3 = new NodeChoice(n6, 1, 2); break; default: jj_la1[118] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n2.addNode(n3); n8 = MultiplicativeExpression(); n2.addNode(n8); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new AdditiveExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public MultiplicativeExpression MultiplicativeExpression() throws ParseException { // --- JTB generated node declarations --- UnaryExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeChoice n3 = null; NodeToken n4 = null; Token n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; UnaryExpression n10 = null; n0 = UnaryExpression(); label_46: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STAR: case SLASH: case REM: ; break; default: jj_la1[119] = jj_gen; break label_46; } n2 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STAR: n5 = jj_consume_token(STAR); n4 = JTBToolkit.makeNodeToken(n5); n3 = new NodeChoice(n4, 0, 3); break; case SLASH: n7 = jj_consume_token(SLASH); n6 = JTBToolkit.makeNodeToken(n7); n3 = new NodeChoice(n6, 1, 3); break; case REM: n9 = jj_consume_token(REM); n8 = JTBToolkit.makeNodeToken(n9); n3 = new NodeChoice(n8, 2, 3); break; default: jj_la1[120] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n2.addNode(n3); n10 = UnaryExpression(); n2.addNode(n10); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new MultiplicativeExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public UnaryExpression UnaryExpression() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; PreIncrementExpression n8 = null; PreDecrementExpression n9 = null; UnaryExpressionNotPlusMinus n10 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: case MINUS: n1 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: n4 = jj_consume_token(PLUS); n3 = JTBToolkit.makeNodeToken(n4); n2 = new NodeChoice(n3, 0, 2); break; case MINUS: n6 = jj_consume_token(MINUS); n5 = JTBToolkit.makeNodeToken(n6); n2 = new NodeChoice(n5, 1, 2); break; default: jj_la1[121] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n1.addNode(n2); n7 = UnaryExpression(); n1.addNode(n7); n0 = new NodeChoice(n1, 0, 4); break; case INCR: n8 = PreIncrementExpression(); n0 = new NodeChoice(n8, 1, 4); break; case DECR: n9 = PreDecrementExpression(); n0 = new NodeChoice(n9, 2, 4); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case IDENTIFIER: n10 = UnaryExpressionNotPlusMinus(); n0 = new NodeChoice(n10, 3, 4); break; default: jj_la1[122] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new UnaryExpression(n0);} throw new Error("Missing return statement in function"); } final public PreIncrementExpression PreIncrementExpression() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; PrimaryExpression n2 = null; n1 = jj_consume_token(INCR); n0 = JTBToolkit.makeNodeToken(n1); n2 = PrimaryExpression(); {if (true) return new PreIncrementExpression(n0, n2);} throw new Error("Missing return statement in function"); } final public PreDecrementExpression PreDecrementExpression() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; PrimaryExpression n2 = null; n1 = jj_consume_token(DECR); n0 = JTBToolkit.makeNodeToken(n1); n2 = PrimaryExpression(); {if (true) return new PreDecrementExpression(n0, n2);} throw new Error("Missing return statement in function"); } final public UnaryExpressionNotPlusMinus UnaryExpressionNotPlusMinus() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; CastExpression n8 = null; PostfixExpression n9 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BANG: case TILDE: n1 = new NodeSequence(2); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TILDE: n4 = jj_consume_token(TILDE); n3 = JTBToolkit.makeNodeToken(n4); n2 = new NodeChoice(n3, 0, 2); break; case BANG: n6 = jj_consume_token(BANG); n5 = JTBToolkit.makeNodeToken(n6); n2 = new NodeChoice(n5, 1, 2); break; default: jj_la1[123] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n1.addNode(n2); n7 = UnaryExpression(); n1.addNode(n7); n0 = new NodeChoice(n1, 0, 3); break; default: jj_la1[124] = jj_gen; if (jj_2_29(2147483647)) { n8 = CastExpression(); n0 = new NodeChoice(n8, 1, 3); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case IDENTIFIER: n9 = PostfixExpression(); n0 = new NodeChoice(n9, 2, 3); break; default: jj_la1[125] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } {if (true) return new UnaryExpressionNotPlusMinus(n0);} throw new Error("Missing return statement in function"); } // This production is to determine lookahead only. The LOOKAHEAD specifications // below are not used, but they are there just to indicate that we know about // this. final public CastLookahead CastLookahead() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; PrimitiveType n4 = null; NodeSequence n5 = null; NodeToken n6 = null; Token n7 = null; Type n8 = null; NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; NodeSequence n13 = null; NodeToken n14 = null; Token n15 = null; Type n16 = null; NodeToken n17 = null; Token n18 = null; NodeChoice n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; NodeToken n24 = null; Token n25 = null; NodeToken n26 = null; Token n27 = null; NodeToken n28 = null; Token n29 = null; NodeToken n30 = null; Token n31 = null; NodeToken n32 = null; Token n33 = null; Literal n34 = null; if (jj_2_30(2)) { n1 = new NodeSequence(2); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = PrimitiveType(); n1.addNode(n4); n0 = new NodeChoice(n1, 0, 3); } else if (jj_2_31(2147483647)) { n5 = new NodeSequence(4); n7 = jj_consume_token(LPAREN); n6 = JTBToolkit.makeNodeToken(n7); n5.addNode(n6); n8 = Type(); n5.addNode(n8); n10 = jj_consume_token(LBRACKET); n9 = JTBToolkit.makeNodeToken(n10); n5.addNode(n9); n12 = jj_consume_token(RBRACKET); n11 = JTBToolkit.makeNodeToken(n12); n5.addNode(n11); n0 = new NodeChoice(n5, 1, 3); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: n13 = new NodeSequence(4); n15 = jj_consume_token(LPAREN); n14 = JTBToolkit.makeNodeToken(n15); n13.addNode(n14); n16 = Type(); n13.addNode(n16); n18 = jj_consume_token(RPAREN); n17 = JTBToolkit.makeNodeToken(n18); n13.addNode(n17); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TILDE: n21 = jj_consume_token(TILDE); n20 = JTBToolkit.makeNodeToken(n21); n19 = new NodeChoice(n20, 0, 8); break; case BANG: n23 = jj_consume_token(BANG); n22 = JTBToolkit.makeNodeToken(n23); n19 = new NodeChoice(n22, 1, 8); break; case LPAREN: n25 = jj_consume_token(LPAREN); n24 = JTBToolkit.makeNodeToken(n25); n19 = new NodeChoice(n24, 2, 8); break; case IDENTIFIER: n27 = jj_consume_token(IDENTIFIER); n26 = JTBToolkit.makeNodeToken(n27); n19 = new NodeChoice(n26, 3, 8); break; case THIS: n29 = jj_consume_token(THIS); n28 = JTBToolkit.makeNodeToken(n29); n19 = new NodeChoice(n28, 4, 8); break; case SUPER: n31 = jj_consume_token(SUPER); n30 = JTBToolkit.makeNodeToken(n31); n19 = new NodeChoice(n30, 5, 8); break; case NEW: n33 = jj_consume_token(NEW); n32 = JTBToolkit.makeNodeToken(n33); n19 = new NodeChoice(n32, 6, 8); break; case FALSE: case NULL: case TRUE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: n34 = Literal(); n19 = new NodeChoice(n34, 7, 8); break; default: jj_la1[126] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n13.addNode(n19); n0 = new NodeChoice(n13, 2, 3); break; default: jj_la1[127] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new CastLookahead(n0);} throw new Error("Missing return statement in function"); } final public PostfixExpression PostfixExpression() throws ParseException { // --- JTB generated node declarations --- PrimaryExpression n0 = null; NodeOptional n1 = new NodeOptional(); NodeChoice n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; n0 = PrimaryExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INCR: case DECR: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INCR: n4 = jj_consume_token(INCR); n3 = JTBToolkit.makeNodeToken(n4); n2 = new NodeChoice(n3, 0, 2); break; case DECR: n6 = jj_consume_token(DECR); n5 = JTBToolkit.makeNodeToken(n6); n2 = new NodeChoice(n5, 1, 2); break; default: jj_la1[128] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n1.addNode(n2); break; default: jj_la1[129] = jj_gen; ; } {if (true) return new PostfixExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public CastExpression CastExpression() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Type n4 = null; NodeToken n5 = null; Token n6 = null; UnaryExpression n7 = null; NodeSequence n8 = null; NodeToken n9 = null; Token n10 = null; Type n11 = null; NodeToken n12 = null; Token n13 = null; UnaryExpressionNotPlusMinus n14 = null; if (jj_2_32(2147483647)) { n1 = new NodeSequence(4); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = Type(); n1.addNode(n4); n6 = jj_consume_token(RPAREN); n5 = JTBToolkit.makeNodeToken(n6); n1.addNode(n5); n7 = UnaryExpression(); n1.addNode(n7); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: n8 = new NodeSequence(4); n10 = jj_consume_token(LPAREN); n9 = JTBToolkit.makeNodeToken(n10); n8.addNode(n9); n11 = Type(); n8.addNode(n11); n13 = jj_consume_token(RPAREN); n12 = JTBToolkit.makeNodeToken(n13); n8.addNode(n12); n14 = UnaryExpressionNotPlusMinus(); n8.addNode(n14); n0 = new NodeChoice(n8, 1, 2); break; default: jj_la1[130] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new CastExpression(n0);} throw new Error("Missing return statement in function"); } final public PrimaryExpression PrimaryExpression() throws ParseException { // --- JTB generated node declarations --- PrimaryPrefix n0 = null; NodeListOptional n1 = new NodeListOptional(); PrimarySuffix n2 = null; n0 = PrimaryPrefix(); label_47: while (true) { if (jj_2_33(2)) { ; } else { break label_47; } n2 = PrimarySuffix(); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new PrimaryExpression(n0, n1);} throw new Error("Missing return statement in function"); } final public MemberSelector MemberSelector() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; TypeArguments n2 = null; NodeToken n3 = null; Token n4 = null; n1 = jj_consume_token(DOT); n0 = JTBToolkit.makeNodeToken(n1); n2 = TypeArguments(); n4 = jj_consume_token(IDENTIFIER); n3 = JTBToolkit.makeNodeToken(n4); {if (true) return new MemberSelector(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public PrimaryPrefix PrimaryPrefix() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; Literal n1 = null; NodeToken n2 = null; Token n3 = null; NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; AllocationExpression n17 = null; NodeSequence n18 = null; ResultType n19 = null; NodeToken n20 = null; Token n21 = null; NodeToken n22 = null; Token n23 = null; Name n24 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FALSE: case NULL: case TRUE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: n1 = Literal(); n0 = new NodeChoice(n1, 0, 7); break; case THIS: n3 = jj_consume_token(THIS); n2 = JTBToolkit.makeNodeToken(n3); n0 = new NodeChoice(n2, 1, 7); break; case SUPER: n4 = new NodeSequence(3); n6 = jj_consume_token(SUPER); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n8 = jj_consume_token(DOT); n7 = JTBToolkit.makeNodeToken(n8); n4.addNode(n7); n10 = jj_consume_token(IDENTIFIER); n9 = JTBToolkit.makeNodeToken(n10); n4.addNode(n9); n0 = new NodeChoice(n4, 2, 7); break; case LPAREN: n11 = new NodeSequence(3); n13 = jj_consume_token(LPAREN); n12 = JTBToolkit.makeNodeToken(n13); n11.addNode(n12); n14 = Expression(null); n11.addNode(n14); n16 = jj_consume_token(RPAREN); n15 = JTBToolkit.makeNodeToken(n16); n11.addNode(n15); n0 = new NodeChoice(n11, 3, 7); break; case NEW: n17 = AllocationExpression(); n0 = new NodeChoice(n17, 4, 7); break; default: jj_la1[131] = jj_gen; if (jj_2_34(2147483647)) { n18 = new NodeSequence(3); n19 = ResultType(null); n18.addNode(n19); n21 = jj_consume_token(DOT); n20 = JTBToolkit.makeNodeToken(n21); n18.addNode(n20); n23 = jj_consume_token(CLASS); n22 = JTBToolkit.makeNodeToken(n23); n18.addNode(n22); n0 = new NodeChoice(n18, 5, 7); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case IDENTIFIER: n24 = Name(null); n0 = new NodeChoice(n24, 6, 7); break; default: jj_la1[132] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } {if (true) return new PrimaryPrefix(n0);} throw new Error("Missing return statement in function"); } final public PrimarySuffix PrimarySuffix() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; AllocationExpression n9 = null; MemberSelector n10 = null; NodeSequence n11 = null; NodeToken n12 = null; Token n13 = null; Expression n14 = null; NodeToken n15 = null; Token n16 = null; NodeSequence n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; Arguments n22 = null; if (jj_2_35(2)) { n1 = new NodeSequence(2); n3 = jj_consume_token(DOT); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n5 = jj_consume_token(THIS); n4 = JTBToolkit.makeNodeToken(n5); n1.addNode(n4); n0 = new NodeChoice(n1, 0, 6); } else if (jj_2_36(2)) { n6 = new NodeSequence(2); n8 = jj_consume_token(DOT); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = AllocationExpression(); n6.addNode(n9); n0 = new NodeChoice(n6, 1, 6); } else if (jj_2_37(3)) { n10 = MemberSelector(); n0 = new NodeChoice(n10, 2, 6); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: n11 = new NodeSequence(3); n13 = jj_consume_token(LBRACKET); n12 = JTBToolkit.makeNodeToken(n13); n11.addNode(n12); n14 = Expression(null); n11.addNode(n14); n16 = jj_consume_token(RBRACKET); n15 = JTBToolkit.makeNodeToken(n16); n11.addNode(n15); n0 = new NodeChoice(n11, 3, 6); break; case DOT: n17 = new NodeSequence(2); n19 = jj_consume_token(DOT); n18 = JTBToolkit.makeNodeToken(n19); n17.addNode(n18); n21 = jj_consume_token(IDENTIFIER); n20 = JTBToolkit.makeNodeToken(n21); n17.addNode(n20); n0 = new NodeChoice(n17, 4, 6); break; case LPAREN: n22 = Arguments(null); n0 = new NodeChoice(n22, 5, 6); break; default: jj_la1[133] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new PrimarySuffix(n0);} throw new Error("Missing return statement in function"); } final public Literal Literal() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; BooleanLiteral n9 = null; NullLiteral n10 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: n2 = jj_consume_token(INTEGER_LITERAL); n1 = JTBToolkit.makeNodeToken(n2); n0 = new NodeChoice(n1, 0, 6); break; case FLOATING_POINT_LITERAL: n4 = jj_consume_token(FLOATING_POINT_LITERAL); n3 = JTBToolkit.makeNodeToken(n4); n0 = new NodeChoice(n3, 1, 6); break; case CHARACTER_LITERAL: n6 = jj_consume_token(CHARACTER_LITERAL); n5 = JTBToolkit.makeNodeToken(n6); n0 = new NodeChoice(n5, 2, 6); break; case STRING_LITERAL: n8 = jj_consume_token(STRING_LITERAL); n7 = JTBToolkit.makeNodeToken(n8); n0 = new NodeChoice(n7, 3, 6); break; case FALSE: case TRUE: n9 = BooleanLiteral(); n0 = new NodeChoice(n9, 4, 6); break; case NULL: n10 = NullLiteral(); n0 = new NodeChoice(n10, 5, 6); break; default: jj_la1[134] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new Literal(n0);} throw new Error("Missing return statement in function"); } final public IntegerLiteral IntegerLiteral() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; n1 = jj_consume_token(INTEGER_LITERAL); n0 = JTBToolkit.makeNodeToken(n1); try { jtbrt_IntegerLiteral = Integer.parseInt(token.image); } catch (NumberFormatException e) { {if (true) throw new Error();} } {if (true) return new IntegerLiteral(n0);} throw new Error("Missing return statement in function"); } final public BooleanLiteral BooleanLiteral() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeToken n1 = null; Token n2 = null; NodeToken n3 = null; Token n4 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: n2 = jj_consume_token(TRUE); n1 = JTBToolkit.makeNodeToken(n2); jtbrt_BooleanLiteral = true; n0 = new NodeChoice(n1, 0, 2); break; case FALSE: n4 = jj_consume_token(FALSE); n3 = JTBToolkit.makeNodeToken(n4); jtbrt_BooleanLiteral = false; n0 = new NodeChoice(n3, 1, 2); break; default: jj_la1[135] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new BooleanLiteral(n0);} throw new Error("Missing return statement in function"); } final public StringLiteral StringLiteral() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; // --- user BNFProduction java block --- Token t; n1 = jj_consume_token(STRING_LITERAL); n0 = JTBToolkit.makeNodeToken(n1); t = n1; jtbrt_StringLiteral = remove_escapes_and_quotes(t, t.image); {if (true) return new StringLiteral(n0);} throw new Error("Missing return statement in function"); } final public NullLiteral NullLiteral() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; n1 = jj_consume_token(NULL); n0 = JTBToolkit.makeNodeToken(n1); {if (true) return new NullLiteral(n0);} throw new Error("Missing return statement in function"); } final public Arguments Arguments(List tokens) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); ArgumentList n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); n1 = jj_consume_token(LPAREN); n0 = JTBToolkit.makeNodeToken(n1); first = getToken(1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n3 = ArgumentList(); n2.addNode(n3); break; default: jj_la1[136] = jj_gen; ; } last = getToken(0); n5 = jj_consume_token(RPAREN); n4 = JTBToolkit.makeNodeToken(n5); if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } {if (true) return new Arguments(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public ArgumentList ArgumentList() throws ParseException { // --- JTB generated node declarations --- Expression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; Expression n5 = null; n0 = Expression(null); label_48: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[137] = jj_gen; break label_48; } n2 = new NodeSequence(2); n4 = jj_consume_token(COMMA); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = Expression(null); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new ArgumentList(n0, n1);} throw new Error("Missing return statement in function"); } final public AllocationExpression AllocationExpression() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; PrimitiveType n4 = null; ArrayDimsAndInits n5 = null; NodeSequence n6 = null; NodeToken n7 = null; Token n8 = null; ClassOrInterfaceType n9 = null; NodeOptional n10 = new NodeOptional(); TypeArguments n11 = null; NodeChoice n12 = null; ArrayDimsAndInits n13 = null; NodeSequence n14 = null; Arguments n15 = null; NodeOptional n16 = new NodeOptional(); ClassOrInterfaceBody n17 = null; if (jj_2_38(2)) { n1 = new NodeSequence(3); n3 = jj_consume_token(NEW); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = PrimitiveType(); n1.addNode(n4); n5 = ArrayDimsAndInits(); n1.addNode(n5); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NEW: n6 = new NodeSequence(4); n8 = jj_consume_token(NEW); n7 = JTBToolkit.makeNodeToken(n8); n6.addNode(n7); n9 = ClassOrInterfaceType(); n6.addNode(n9); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LANGLE: n11 = TypeArguments(); n10.addNode(n11); break; default: jj_la1[138] = jj_gen; ; } n6.addNode(n10); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: n13 = ArrayDimsAndInits(); n12 = new NodeChoice(n13, 0, 2); break; case LPAREN: n14 = new NodeSequence(2); n15 = Arguments(null); n14.addNode(n15); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: n17 = ClassOrInterfaceBody(false, null); n16.addNode(n17); break; default: jj_la1[139] = jj_gen; ; } n14.addNode(n16); n12 = new NodeChoice(n14, 1, 2); break; default: jj_la1[140] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n6.addNode(n12); n0 = new NodeChoice(n6, 1, 2); break; default: jj_la1[141] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new AllocationExpression(n0);} throw new Error("Missing return statement in function"); } /* * The third LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */ final public ArrayDimsAndInits ArrayDimsAndInits() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeList n2 = new NodeList(); NodeSequence n3 = null; NodeToken n4 = null; Token n5 = null; Expression n6 = null; NodeToken n7 = null; Token n8 = null; NodeListOptional n9 = new NodeListOptional(); NodeSequence n10 = null; NodeToken n11 = null; Token n12 = null; NodeToken n13 = null; Token n14 = null; NodeSequence n15 = null; NodeList n16 = new NodeList(); NodeSequence n17 = null; NodeToken n18 = null; Token n19 = null; NodeToken n20 = null; Token n21 = null; ArrayInitializer n22 = null; if (jj_2_41(2)) { n1 = new NodeSequence(2); label_49: while (true) { n3 = new NodeSequence(3); n5 = jj_consume_token(LBRACKET); n4 = JTBToolkit.makeNodeToken(n5); n3.addNode(n4); n6 = Expression(null); n3.addNode(n6); n8 = jj_consume_token(RBRACKET); n7 = JTBToolkit.makeNodeToken(n8); n3.addNode(n7); n2.addNode(n3); if (jj_2_39(2)) { ; } else { break label_49; } } n2.nodes.trimToSize(); n1.addNode(n2); label_50: while (true) { if (jj_2_40(2)) { ; } else { break label_50; } n10 = new NodeSequence(2); n12 = jj_consume_token(LBRACKET); n11 = JTBToolkit.makeNodeToken(n12); n10.addNode(n11); n14 = jj_consume_token(RBRACKET); n13 = JTBToolkit.makeNodeToken(n14); n10.addNode(n13); n9.addNode(n10); } n9.nodes.trimToSize(); n1.addNode(n9); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: n15 = new NodeSequence(2); label_51: while (true) { n17 = new NodeSequence(2); n19 = jj_consume_token(LBRACKET); n18 = JTBToolkit.makeNodeToken(n19); n17.addNode(n18); n21 = jj_consume_token(RBRACKET); n20 = JTBToolkit.makeNodeToken(n21); n17.addNode(n20); n16.addNode(n17); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: ; break; default: jj_la1[142] = jj_gen; break label_51; } } n16.nodes.trimToSize(); n15.addNode(n16); n22 = ArrayInitializer(); n15.addNode(n22); n0 = new NodeChoice(n15, 1, 2); break; default: jj_la1[143] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new ArrayDimsAndInits(n0);} throw new Error("Missing return statement in function"); } /* * Statement syntax follows. */ final public Statement Statement() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; LabeledStatement n1 = null; AssertStatement n2 = null; Block n3 = null; EmptyStatement n4 = null; NodeSequence n5 = null; StatementExpression n6 = null; NodeToken n7 = null; Token n8 = null; SwitchStatement n9 = null; IfStatement n10 = null; WhileStatement n11 = null; DoStatement n12 = null; ForStatement n13 = null; BreakStatement n14 = null; ContinueStatement n15 = null; ReturnStatement n16 = null; ThrowStatement n17 = null; SynchronizedStatement n18 = null; TryStatement n19 = null; if (jj_2_42(2)) { n1 = LabeledStatement(); n0 = new NodeChoice(n1, 0, 16); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSERT: n2 = AssertStatement(); n0 = new NodeChoice(n2, 1, 16); break; case LBRACE: n3 = Block(null); n0 = new NodeChoice(n3, 2, 16); break; case SEMICOLON: n4 = EmptyStatement(); n0 = new NodeChoice(n4, 3, 16); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case INCR: case DECR: case IDENTIFIER: n5 = new NodeSequence(2); n6 = StatementExpression(); n5.addNode(n6); n8 = jj_consume_token(SEMICOLON); n7 = JTBToolkit.makeNodeToken(n8); n5.addNode(n7); n0 = new NodeChoice(n5, 4, 16); break; case SWITCH: n9 = SwitchStatement(); n0 = new NodeChoice(n9, 5, 16); break; case IF: n10 = IfStatement(); n0 = new NodeChoice(n10, 6, 16); break; case WHILE: n11 = WhileStatement(); n0 = new NodeChoice(n11, 7, 16); break; case DO: n12 = DoStatement(); n0 = new NodeChoice(n12, 8, 16); break; case FOR: n13 = ForStatement(); n0 = new NodeChoice(n13, 9, 16); break; case BREAK: n14 = BreakStatement(); n0 = new NodeChoice(n14, 10, 16); break; case CONTINUE: n15 = ContinueStatement(); n0 = new NodeChoice(n15, 11, 16); break; case RETURN: n16 = ReturnStatement(); n0 = new NodeChoice(n16, 12, 16); break; case THROW: n17 = ThrowStatement(); n0 = new NodeChoice(n17, 13, 16); break; case SYNCHRONIZED: n18 = SynchronizedStatement(); n0 = new NodeChoice(n18, 14, 16); break; case TRY: n19 = TryStatement(); n0 = new NodeChoice(n19, 15, 16); break; default: jj_la1[144] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new Statement(n0);} throw new Error("Missing return statement in function"); } final public AssertStatement AssertStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Expression n2 = null; NodeOptional n3 = new NodeOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; Expression n7 = null; NodeToken n8 = null; Token n9 = null; n1 = jj_consume_token(ASSERT); n0 = JTBToolkit.makeNodeToken(n1); n2 = Expression(null); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COLON: n4 = new NodeSequence(2); n6 = jj_consume_token(COLON); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = Expression(null); n4.addNode(n7); n3.addNode(n4); break; default: jj_la1[145] = jj_gen; ; } n9 = jj_consume_token(SEMICOLON); n8 = JTBToolkit.makeNodeToken(n9); {if (true) return new AssertStatement(n0, n2, n3, n8);} throw new Error("Missing return statement in function"); } final public LabeledStatement LabeledStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Statement n4 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(COLON); n2 = JTBToolkit.makeNodeToken(n3); n4 = Statement(); {if (true) return new LabeledStatement(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public Block Block(List tokens) throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); BlockStatement n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token first, last; if (tokens == null) tokens = new ArrayList(); n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); first = getToken(1); label_52: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ABSTRACT: case ASSERT: case BOOLEAN: case BREAK: case BYTE: case CHAR: case CLASS: case CONTINUE: case DO: case DOUBLE: case FALSE: case FINAL: case FLOAT: case FOR: case IF: case INT: case INTERFACE: case LONG: case NATIVE: case NEW: case NULL: case PRIVATE: case PROTECTED: case PUBLIC: case RETURN: case SHORT: case STATIC: case STRICTFP: case SUPER: case SWITCH: case SYNCHRONIZED: case THIS: case THROW: case TRANSIENT: case TRUE: case TRY: case VOID: case VOLATILE: case WHILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case LBRACE: case SEMICOLON: case INCR: case DECR: case 140: case IDENTIFIER: ; break; default: jj_la1[146] = jj_gen; break label_52; } n3 = BlockStatement(); n2.addNode(n3); } n2.nodes.trimToSize(); last = getToken(0); n5 = jj_consume_token(RBRACE); n4 = JTBToolkit.makeNodeToken(n5); if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } {if (true) return new Block(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public BlockStatement BlockStatement() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; LocalVariableDeclaration n2 = null; NodeToken n3 = null; Token n4 = null; Statement n5 = null; ClassOrInterfaceDeclaration n6 = null; if (jj_2_43(2147483647)) { n1 = new NodeSequence(2); n2 = LocalVariableDeclaration(); n1.addNode(n2); n4 = jj_consume_token(SEMICOLON); n3 = JTBToolkit.makeNodeToken(n4); n1.addNode(n3); n0 = new NodeChoice(n1, 0, 3); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ASSERT: case BOOLEAN: case BREAK: case BYTE: case CHAR: case CONTINUE: case DO: case DOUBLE: case FALSE: case FLOAT: case FOR: case IF: case INT: case LONG: case NEW: case NULL: case RETURN: case SHORT: case SUPER: case SWITCH: case SYNCHRONIZED: case THIS: case THROW: case TRUE: case TRY: case VOID: case WHILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case LBRACE: case SEMICOLON: case INCR: case DECR: case IDENTIFIER: n5 = Statement(); n0 = new NodeChoice(n5, 1, 3); break; case CLASS: case INTERFACE: n6 = ClassOrInterfaceDeclaration(); n0 = new NodeChoice(n6, 2, 3); break; default: jj_la1[147] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new BlockStatement(n0);} throw new Error("Missing return statement in function"); } final public LocalVariableDeclaration LocalVariableDeclaration() throws ParseException { // --- JTB generated node declarations --- Modifiers n0 = null; Type n1 = null; VariableDeclarator n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; VariableDeclarator n7 = null; n0 = Modifiers(); n1 = Type(); n2 = VariableDeclarator(); label_53: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[148] = jj_gen; break label_53; } n4 = new NodeSequence(2); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = VariableDeclarator(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); {if (true) return new LocalVariableDeclaration(n0, n1, n2, n3);} throw new Error("Missing return statement in function"); } final public EmptyStatement EmptyStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; n1 = jj_consume_token(SEMICOLON); n0 = JTBToolkit.makeNodeToken(n1); {if (true) return new EmptyStatement(n0);} throw new Error("Missing return statement in function"); } final public StatementExpression StatementExpression() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; PreIncrementExpression n1 = null; PreDecrementExpression n2 = null; NodeSequence n3 = null; PrimaryExpression n4 = null; NodeOptional n5 = new NodeOptional(); NodeChoice n6 = null; NodeToken n7 = null; Token n8 = null; NodeToken n9 = null; Token n10 = null; NodeSequence n11 = null; AssignmentOperator n12 = null; Expression n13 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INCR: n1 = PreIncrementExpression(); n0 = new NodeChoice(n1, 0, 3); break; case DECR: n2 = PreDecrementExpression(); n0 = new NodeChoice(n2, 1, 3); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case IDENTIFIER: n3 = new NodeSequence(2); n4 = PrimaryExpression(); n3.addNode(n4); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: case INCR: case DECR: case PLUSASSIGN: case MINUSASSIGN: case STARASSIGN: case SLASHASSIGN: case ANDASSIGN: case ORASSIGN: case XORASSIGN: case REMASSIGN: case 136: case 137: case 138: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INCR: n8 = jj_consume_token(INCR); n7 = JTBToolkit.makeNodeToken(n8); n6 = new NodeChoice(n7, 0, 3); break; case DECR: n10 = jj_consume_token(DECR); n9 = JTBToolkit.makeNodeToken(n10); n6 = new NodeChoice(n9, 1, 3); break; case ASSIGN: case PLUSASSIGN: case MINUSASSIGN: case STARASSIGN: case SLASHASSIGN: case ANDASSIGN: case ORASSIGN: case XORASSIGN: case REMASSIGN: case 136: case 137: case 138: n11 = new NodeSequence(2); n12 = AssignmentOperator(); n11.addNode(n12); n13 = Expression(null); n11.addNode(n13); n6 = new NodeChoice(n11, 2, 3); break; default: jj_la1[149] = jj_gen; jj_consume_token(-1); throw new ParseException(); } n5.addNode(n6); break; default: jj_la1[150] = jj_gen; ; } n3.addNode(n5); n0 = new NodeChoice(n3, 2, 3); break; default: jj_la1[151] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new StatementExpression(n0);} throw new Error("Missing return statement in function"); } final public SwitchStatement SwitchStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; NodeListOptional n9 = new NodeListOptional(); NodeSequence n10 = null; SwitchLabel n11 = null; NodeListOptional n12 = null; BlockStatement n13 = null; NodeToken n14 = null; Token n15 = null; n1 = jj_consume_token(SWITCH); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n4 = Expression(null); n6 = jj_consume_token(RPAREN); n5 = JTBToolkit.makeNodeToken(n6); n8 = jj_consume_token(LBRACE); n7 = JTBToolkit.makeNodeToken(n8); label_54: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CASE: case _DEFAULT: ; break; default: jj_la1[152] = jj_gen; break label_54; } n12 = new NodeListOptional(); n10 = new NodeSequence(2); n11 = SwitchLabel(); n10.addNode(n11); label_55: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ABSTRACT: case ASSERT: case BOOLEAN: case BREAK: case BYTE: case CHAR: case CLASS: case CONTINUE: case DO: case DOUBLE: case FALSE: case FINAL: case FLOAT: case FOR: case IF: case INT: case INTERFACE: case LONG: case NATIVE: case NEW: case NULL: case PRIVATE: case PROTECTED: case PUBLIC: case RETURN: case SHORT: case STATIC: case STRICTFP: case SUPER: case SWITCH: case SYNCHRONIZED: case THIS: case THROW: case TRANSIENT: case TRUE: case TRY: case VOID: case VOLATILE: case WHILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case LBRACE: case SEMICOLON: case INCR: case DECR: case 140: case IDENTIFIER: ; break; default: jj_la1[153] = jj_gen; break label_55; } n13 = BlockStatement(); n12.addNode(n13); } n12.nodes.trimToSize(); n10.addNode(n12); n9.addNode(n10); } n9.nodes.trimToSize(); n15 = jj_consume_token(RBRACE); n14 = JTBToolkit.makeNodeToken(n15); {if (true) return new SwitchStatement(n0, n2, n4, n5, n7, n9, n14);} throw new Error("Missing return statement in function"); } final public SwitchLabel SwitchLabel() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; NodeSequence n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CASE: n1 = new NodeSequence(3); n3 = jj_consume_token(CASE); n2 = JTBToolkit.makeNodeToken(n3); n1.addNode(n2); n4 = Expression(null); n1.addNode(n4); n6 = jj_consume_token(COLON); n5 = JTBToolkit.makeNodeToken(n6); n1.addNode(n5); n0 = new NodeChoice(n1, 0, 2); break; case _DEFAULT: n7 = new NodeSequence(2); n9 = jj_consume_token(_DEFAULT); n8 = JTBToolkit.makeNodeToken(n9); n7.addNode(n8); n11 = jj_consume_token(COLON); n10 = JTBToolkit.makeNodeToken(n11); n7.addNode(n10); n0 = new NodeChoice(n7, 1, 2); break; default: jj_la1[154] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new SwitchLabel(n0);} throw new Error("Missing return statement in function"); } final public IfStatement IfStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Statement n7 = null; NodeOptional n8 = new NodeOptional(); NodeSequence n9 = null; NodeToken n10 = null; Token n11 = null; Statement n12 = null; n1 = jj_consume_token(IF); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n4 = Expression(null); n6 = jj_consume_token(RPAREN); n5 = JTBToolkit.makeNodeToken(n6); n7 = Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ELSE: n9 = new NodeSequence(2); n11 = jj_consume_token(ELSE); n10 = JTBToolkit.makeNodeToken(n11); n9.addNode(n10); n12 = Statement(); n9.addNode(n12); n8.addNode(n9); break; default: jj_la1[155] = jj_gen; ; } {if (true) return new IfStatement(n0, n2, n4, n5, n7, n8);} throw new Error("Missing return statement in function"); } final public WhileStatement WhileStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Statement n7 = null; n1 = jj_consume_token(WHILE); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n4 = Expression(null); n6 = jj_consume_token(RPAREN); n5 = JTBToolkit.makeNodeToken(n6); n7 = Statement(); {if (true) return new WhileStatement(n0, n2, n4, n5, n7);} throw new Error("Missing return statement in function"); } final public DoStatement DoStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Statement n2 = null; NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; Expression n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; n1 = jj_consume_token(DO); n0 = JTBToolkit.makeNodeToken(n1); n2 = Statement(); n4 = jj_consume_token(WHILE); n3 = JTBToolkit.makeNodeToken(n4); n6 = jj_consume_token(LPAREN); n5 = JTBToolkit.makeNodeToken(n6); n7 = Expression(null); n9 = jj_consume_token(RPAREN); n8 = JTBToolkit.makeNodeToken(n9); n11 = jj_consume_token(SEMICOLON); n10 = JTBToolkit.makeNodeToken(n11); {if (true) return new DoStatement(n0, n2, n3, n5, n7, n8, n10);} throw new Error("Missing return statement in function"); } final public ForStatement ForStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeChoice n4 = null; NodeSequence n5 = null; Modifiers n6 = null; Type n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; Expression n12 = null; NodeSequence n13 = null; NodeOptional n14 = new NodeOptional(); ForInit n15 = null; NodeToken n16 = null; Token n17 = null; NodeOptional n18 = new NodeOptional(); Expression n19 = null; NodeToken n20 = null; Token n21 = null; NodeOptional n22 = new NodeOptional(); ForUpdate n23 = null; NodeToken n24 = null; Token n25 = null; Statement n26 = null; n1 = jj_consume_token(FOR); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); if (jj_2_44(2147483647)) { n5 = new NodeSequence(5); n6 = Modifiers(); n5.addNode(n6); n7 = Type(); n5.addNode(n7); n9 = jj_consume_token(IDENTIFIER); n8 = JTBToolkit.makeNodeToken(n9); n5.addNode(n8); n11 = jj_consume_token(COLON); n10 = JTBToolkit.makeNodeToken(n11); n5.addNode(n10); n12 = Expression(null); n5.addNode(n12); n4 = new NodeChoice(n5, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FINAL: case FLOAT: case INT: case LONG: case NATIVE: case NEW: case NULL: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SUPER: case SYNCHRONIZED: case THIS: case TRANSIENT: case TRUE: case VOID: case VOLATILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case SEMICOLON: case INCR: case DECR: case 140: case IDENTIFIER: n13 = new NodeSequence(5); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FINAL: case FLOAT: case INT: case LONG: case NATIVE: case NEW: case NULL: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SUPER: case SYNCHRONIZED: case THIS: case TRANSIENT: case TRUE: case VOID: case VOLATILE: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case INCR: case DECR: case 140: case IDENTIFIER: n15 = ForInit(); n14.addNode(n15); break; default: jj_la1[156] = jj_gen; ; } n13.addNode(n14); n17 = jj_consume_token(SEMICOLON); n16 = JTBToolkit.makeNodeToken(n17); n13.addNode(n16); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n19 = Expression(null); n18.addNode(n19); break; default: jj_la1[157] = jj_gen; ; } n13.addNode(n18); n21 = jj_consume_token(SEMICOLON); n20 = JTBToolkit.makeNodeToken(n21); n13.addNode(n20); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case INCR: case DECR: case IDENTIFIER: n23 = ForUpdate(); n22.addNode(n23); break; default: jj_la1[158] = jj_gen; ; } n13.addNode(n22); n4 = new NodeChoice(n13, 1, 2); break; default: jj_la1[159] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } n25 = jj_consume_token(RPAREN); n24 = JTBToolkit.makeNodeToken(n25); n26 = Statement(); {if (true) return new ForStatement(n0, n2, n4, n24, n26);} throw new Error("Missing return statement in function"); } final public ForInit ForInit() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; LocalVariableDeclaration n1 = null; StatementExpressionList n2 = null; if (jj_2_45(2147483647)) { n1 = LocalVariableDeclaration(); n0 = new NodeChoice(n1, 0, 2); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case INCR: case DECR: case IDENTIFIER: n2 = StatementExpressionList(); n0 = new NodeChoice(n2, 1, 2); break; default: jj_la1[160] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new ForInit(n0);} throw new Error("Missing return statement in function"); } final public StatementExpressionList StatementExpressionList() throws ParseException { // --- JTB generated node declarations --- StatementExpression n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; StatementExpression n5 = null; n0 = StatementExpression(); label_56: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[161] = jj_gen; break label_56; } n2 = new NodeSequence(2); n4 = jj_consume_token(COMMA); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = StatementExpression(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new StatementExpressionList(n0, n1);} throw new Error("Missing return statement in function"); } final public ForUpdate ForUpdate() throws ParseException { // --- JTB generated node declarations --- StatementExpressionList n0 = null; n0 = StatementExpressionList(); {if (true) return new ForUpdate(n0);} throw new Error("Missing return statement in function"); } final public BreakStatement BreakStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; n1 = jj_consume_token(BREAK); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: n4 = jj_consume_token(IDENTIFIER); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); break; default: jj_la1[162] = jj_gen; ; } n6 = jj_consume_token(SEMICOLON); n5 = JTBToolkit.makeNodeToken(n6); {if (true) return new BreakStatement(n0, n2, n5);} throw new Error("Missing return statement in function"); } final public ContinueStatement ContinueStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); NodeToken n3 = null; Token n4 = null; NodeToken n5 = null; Token n6 = null; n1 = jj_consume_token(CONTINUE); n0 = JTBToolkit.makeNodeToken(n1); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: n4 = jj_consume_token(IDENTIFIER); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); break; default: jj_la1[163] = jj_gen; ; } n6 = jj_consume_token(SEMICOLON); n5 = JTBToolkit.makeNodeToken(n6); {if (true) return new ContinueStatement(n0, n2, n5);} throw new Error("Missing return statement in function"); } final public ReturnStatement ReturnStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeOptional n2 = new NodeOptional(); Expression n3 = null; NodeToken n4 = null; Token n5 = null; // --- user BNFProduction java block --- Token t; n1 = jj_consume_token(RETURN); n0 = JTBToolkit.makeNodeToken(n1); t = n1; // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) return"; jumpPatched = true; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n3 = Expression(null); n2.addNode(n3); break; default: jj_la1[164] = jj_gen; ; } n5 = jj_consume_token(SEMICOLON); n4 = JTBToolkit.makeNodeToken(n5); t = n5; // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } {if (true) return new ReturnStatement(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public ThrowStatement ThrowStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Expression n2 = null; NodeToken n3 = null; Token n4 = null; // --- user BNFProduction java block --- Token t; n1 = jj_consume_token(THROW); n0 = JTBToolkit.makeNodeToken(n1); t = n1; // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) throw"; jumpPatched = true; } n2 = Expression(null); n4 = jj_consume_token(SEMICOLON); n3 = JTBToolkit.makeNodeToken(n4); t = n4; // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } {if (true) return new ThrowStatement(n0, n2, n3);} throw new Error("Missing return statement in function"); } final public SynchronizedStatement SynchronizedStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; Expression n4 = null; NodeToken n5 = null; Token n6 = null; Block n7 = null; n1 = jj_consume_token(SYNCHRONIZED); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(LPAREN); n2 = JTBToolkit.makeNodeToken(n3); n4 = Expression(null); n6 = jj_consume_token(RPAREN); n5 = JTBToolkit.makeNodeToken(n6); n7 = Block(null); {if (true) return new SynchronizedStatement(n0, n2, n4, n5, n7);} throw new Error("Missing return statement in function"); } final public TryStatement TryStatement() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Block n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; NodeToken n7 = null; Token n8 = null; FormalParameter n9 = null; NodeToken n10 = null; Token n11 = null; Block n12 = null; NodeOptional n13 = new NodeOptional(); NodeSequence n14 = null; NodeToken n15 = null; Token n16 = null; Block n17 = null; n1 = jj_consume_token(TRY); n0 = JTBToolkit.makeNodeToken(n1); n2 = Block(null); label_57: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CATCH: ; break; default: jj_la1[165] = jj_gen; break label_57; } n4 = new NodeSequence(5); n6 = jj_consume_token(CATCH); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n8 = jj_consume_token(LPAREN); n7 = JTBToolkit.makeNodeToken(n8); n4.addNode(n7); n9 = FormalParameter(); n4.addNode(n9); n11 = jj_consume_token(RPAREN); n10 = JTBToolkit.makeNodeToken(n11); n4.addNode(n10); n12 = Block(null); n4.addNode(n12); n3.addNode(n4); } n3.nodes.trimToSize(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FINALLY: n14 = new NodeSequence(2); n16 = jj_consume_token(FINALLY); n15 = JTBToolkit.makeNodeToken(n16); n14.addNode(n15); n17 = Block(null); n14.addNode(n17); n13.addNode(n14); break; default: jj_la1[166] = jj_gen; ; } {if (true) return new TryStatement(n0, n2, n3, n13);} throw new Error("Missing return statement in function"); } /* We use productions to match >>>, >> and > so that we can keep the * type declaration syntax with generics clean */ final public RUNSIGNEDSHIFT RUNSIGNEDSHIFT() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; if (getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT) { } else { jj_consume_token(-1); throw new ParseException(); } n1 = jj_consume_token(RANGLE); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(RANGLE); n2 = JTBToolkit.makeNodeToken(n3); n5 = jj_consume_token(RANGLE); n4 = JTBToolkit.makeNodeToken(n5); {if (true) return new RUNSIGNEDSHIFT(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public RSIGNEDSHIFT RSIGNEDSHIFT() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; if (getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT) { } else { jj_consume_token(-1); throw new ParseException(); } n1 = jj_consume_token(RANGLE); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(RANGLE); n2 = JTBToolkit.makeNodeToken(n3); {if (true) return new RSIGNEDSHIFT(n0, n2);} throw new Error("Missing return statement in function"); } /* Annotation syntax follows. */ final public Annotation Annotation() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NormalAnnotation n1 = null; SingleMemberAnnotation n2 = null; MarkerAnnotation n3 = null; if (jj_2_46(2147483647)) { n1 = NormalAnnotation(); n0 = new NodeChoice(n1, 0, 3); } else if (jj_2_47(2147483647)) { n2 = SingleMemberAnnotation(); n0 = new NodeChoice(n2, 1, 3); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 140: n3 = MarkerAnnotation(); n0 = new NodeChoice(n3, 2, 3); break; default: jj_la1[167] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return new Annotation(n0);} throw new Error("Missing return statement in function"); } final public NormalAnnotation NormalAnnotation() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; NodeToken n3 = null; Token n4 = null; NodeOptional n5 = new NodeOptional(); MemberValuePairs n6 = null; NodeToken n7 = null; Token n8 = null; n1 = jj_consume_token(140); n0 = JTBToolkit.makeNodeToken(n1); n2 = Name(null); n4 = jj_consume_token(LPAREN); n3 = JTBToolkit.makeNodeToken(n4); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: n6 = MemberValuePairs(); n5.addNode(n6); break; default: jj_la1[168] = jj_gen; ; } n8 = jj_consume_token(RPAREN); n7 = JTBToolkit.makeNodeToken(n8); {if (true) return new NormalAnnotation(n0, n2, n3, n5, n7);} throw new Error("Missing return statement in function"); } final public MarkerAnnotation MarkerAnnotation() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; n1 = jj_consume_token(140); n0 = JTBToolkit.makeNodeToken(n1); n2 = Name(null); {if (true) return new MarkerAnnotation(n0, n2);} throw new Error("Missing return statement in function"); } final public SingleMemberAnnotation SingleMemberAnnotation() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; Name n2 = null; NodeToken n3 = null; Token n4 = null; MemberValue n5 = null; NodeToken n6 = null; Token n7 = null; n1 = jj_consume_token(140); n0 = JTBToolkit.makeNodeToken(n1); n2 = Name(null); n4 = jj_consume_token(LPAREN); n3 = JTBToolkit.makeNodeToken(n4); n5 = MemberValue(); n7 = jj_consume_token(RPAREN); n6 = JTBToolkit.makeNodeToken(n7); {if (true) return new SingleMemberAnnotation(n0, n2, n3, n5, n6);} throw new Error("Missing return statement in function"); } final public MemberValuePairs MemberValuePairs() throws ParseException { // --- JTB generated node declarations --- MemberValuePair n0 = null; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2 = null; NodeToken n3 = null; Token n4 = null; MemberValuePair n5 = null; n0 = MemberValuePair(); label_58: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[169] = jj_gen; break label_58; } n2 = new NodeSequence(2); n4 = jj_consume_token(COMMA); n3 = JTBToolkit.makeNodeToken(n4); n2.addNode(n3); n5 = MemberValuePair(); n2.addNode(n5); n1.addNode(n2); } n1.nodes.trimToSize(); {if (true) return new MemberValuePairs(n0, n1);} throw new Error("Missing return statement in function"); } final public MemberValuePair MemberValuePair() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; MemberValue n4 = null; n1 = jj_consume_token(IDENTIFIER); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(ASSIGN); n2 = JTBToolkit.makeNodeToken(n3); n4 = MemberValue(); {if (true) return new MemberValuePair(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public MemberValue MemberValue() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; Annotation n1 = null; MemberValueArrayInitializer n2 = null; ConditionalExpression n3 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 140: n1 = Annotation(); n0 = new NodeChoice(n1, 0, 3); break; case LBRACE: n2 = MemberValueArrayInitializer(); n0 = new NodeChoice(n2, 1, 3); break; case _LOOKAHEAD: case _IGNORE_CASE: case _PARSER_BEGIN: case _PARSER_END: case _JAVACODE: case _TOKEN: case _SPECIAL_TOKEN: case _MORE: case _SKIP: case _TOKEN_MGR_DECLS: case _EOF: case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FALSE: case FLOAT: case INT: case LONG: case NEW: case NULL: case SHORT: case SUPER: case THIS: case TRUE: case VOID: case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case CHARACTER_LITERAL: case STRING_LITERAL: case LPAREN: case BANG: case TILDE: case INCR: case DECR: case PLUS: case MINUS: case IDENTIFIER: n3 = ConditionalExpression(); n0 = new NodeChoice(n3, 2, 3); break; default: jj_la1[170] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new MemberValue(n0);} throw new Error("Missing return statement in function"); } final public MemberValueArrayInitializer MemberValueArrayInitializer() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; MemberValue n2 = null; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4 = null; NodeToken n5 = null; Token n6 = null; MemberValue n7 = null; NodeOptional n8 = new NodeOptional(); NodeToken n9 = null; Token n10 = null; NodeToken n11 = null; Token n12 = null; n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); n2 = MemberValue(); label_59: while (true) { if (jj_2_48(2)) { ; } else { break label_59; } n4 = new NodeSequence(2); n6 = jj_consume_token(COMMA); n5 = JTBToolkit.makeNodeToken(n6); n4.addNode(n5); n7 = MemberValue(); n4.addNode(n7); n3.addNode(n4); } n3.nodes.trimToSize(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: n10 = jj_consume_token(COMMA); n9 = JTBToolkit.makeNodeToken(n10); n8.addNode(n9); break; default: jj_la1[171] = jj_gen; ; } n12 = jj_consume_token(RBRACE); n11 = JTBToolkit.makeNodeToken(n12); {if (true) return new MemberValueArrayInitializer(n0, n2, n3, n8, n11);} throw new Error("Missing return statement in function"); } /* Annotation Types. */ final public AnnotationTypeDeclaration AnnotationTypeDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeToken n2 = null; Token n3 = null; NodeToken n4 = null; Token n5 = null; AnnotationTypeBody n6 = null; n1 = jj_consume_token(140); n0 = JTBToolkit.makeNodeToken(n1); n3 = jj_consume_token(INTERFACE); n2 = JTBToolkit.makeNodeToken(n3); n5 = jj_consume_token(IDENTIFIER); n4 = JTBToolkit.makeNodeToken(n5); n6 = AnnotationTypeBody(); {if (true) return new AnnotationTypeDeclaration(n0, n2, n4, n6);} throw new Error("Missing return statement in function"); } final public AnnotationTypeBody AnnotationTypeBody() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; NodeListOptional n2 = new NodeListOptional(); AnnotationTypeMemberDeclaration n3 = null; NodeToken n4 = null; Token n5 = null; n1 = jj_consume_token(LBRACE); n0 = JTBToolkit.makeNodeToken(n1); label_60: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case CLASS: case DOUBLE: case ENUM: case FINAL: case FLOAT: case INT: case INTERFACE: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case SEMICOLON: case 140: case IDENTIFIER: ; break; default: jj_la1[172] = jj_gen; break label_60; } n3 = AnnotationTypeMemberDeclaration(); n2.addNode(n3); } n2.nodes.trimToSize(); n5 = jj_consume_token(RBRACE); n4 = JTBToolkit.makeNodeToken(n5); {if (true) return new AnnotationTypeBody(n0, n2, n4);} throw new Error("Missing return statement in function"); } final public AnnotationTypeMemberDeclaration AnnotationTypeMemberDeclaration() throws ParseException { // --- JTB generated node declarations --- NodeChoice n0 = null; NodeSequence n1 = null; Modifiers n2 = null; NodeChoice n3 = null; NodeSequence n4 = null; Type n5 = null; NodeToken n6 = null; Token n7 = null; NodeToken n8 = null; Token n9 = null; NodeToken n10 = null; Token n11 = null; NodeOptional n12 = new NodeOptional(); DefaultValue n13 = null; NodeToken n14 = null; Token n15 = null; ClassOrInterfaceDeclaration n16 = null; EnumDeclaration n17 = null; AnnotationTypeDeclaration n18 = null; FieldDeclaration n19 = null; NodeToken n20 = null; Token n21 = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ABSTRACT: case BOOLEAN: case BYTE: case CHAR: case CLASS: case DOUBLE: case ENUM: case FINAL: case FLOAT: case INT: case INTERFACE: case LONG: case NATIVE: case PRIVATE: case PROTECTED: case PUBLIC: case SHORT: case STATIC: case STRICTFP: case SYNCHRONIZED: case TRANSIENT: case VOLATILE: case 140: case IDENTIFIER: n1 = new NodeSequence(2); n2 = Modifiers(); n1.addNode(n2); if (jj_2_49(2147483647)) { n4 = new NodeSequence(6); n5 = Type(); n4.addNode(n5); n7 = jj_consume_token(IDENTIFIER); n6 = JTBToolkit.makeNodeToken(n7); n4.addNode(n6); n9 = jj_consume_token(LPAREN); n8 = JTBToolkit.makeNodeToken(n9); n4.addNode(n8); n11 = jj_consume_token(RPAREN); n10 = JTBToolkit.makeNodeToken(n11); n4.addNode(n10); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case _DEFAULT: n13 = DefaultValue(); n12.addNode(n13); break; default: jj_la1[173] = jj_gen; ; } n4.addNode(n12); n15 = jj_consume_token(SEMICOLON); n14 = JTBToolkit.makeNodeToken(n15); n4.addNode(n14); n3 = new NodeChoice(n4, 0, 5); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: case INTERFACE: n16 = ClassOrInterfaceDeclaration(); n3 = new NodeChoice(n16, 1, 5); break; case ENUM: n17 = EnumDeclaration(); n3 = new NodeChoice(n17, 2, 5); break; case 140: n18 = AnnotationTypeDeclaration(); n3 = new NodeChoice(n18, 3, 5); break; case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: case IDENTIFIER: n19 = FieldDeclaration(); n3 = new NodeChoice(n19, 4, 5); break; default: jj_la1[174] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } n1.addNode(n3); n0 = new NodeChoice(n1, 0, 2); break; case SEMICOLON: n21 = jj_consume_token(SEMICOLON); n20 = JTBToolkit.makeNodeToken(n21); n0 = new NodeChoice(n20, 1, 2); break; default: jj_la1[175] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return new AnnotationTypeMemberDeclaration(n0);} throw new Error("Missing return statement in function"); } final public DefaultValue DefaultValue() throws ParseException { // --- JTB generated node declarations --- NodeToken n0 = null; Token n1 = null; MemberValue n2 = null; n1 = jj_consume_token(_DEFAULT); n0 = JTBToolkit.makeNodeToken(n1); n2 = MemberValue(); {if (true) return new DefaultValue(n0, n2);} throw new Error("Missing return statement in function"); } private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } private boolean jj_2_8(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_8(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } private boolean jj_2_9(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_9(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } private boolean jj_2_10(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_10(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(9, xla); } } private boolean jj_2_11(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_11(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(10, xla); } } private boolean jj_2_12(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_12(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(11, xla); } } private boolean jj_2_13(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_13(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(12, xla); } } private boolean jj_2_14(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_14(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(13, xla); } } private boolean jj_2_15(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_15(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(14, xla); } } private boolean jj_2_16(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_16(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(15, xla); } } private boolean jj_2_17(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_17(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(16, xla); } } private boolean jj_2_18(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_18(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(17, xla); } } private boolean jj_2_19(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_19(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(18, xla); } } private boolean jj_2_20(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_20(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(19, xla); } } private boolean jj_2_21(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_21(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(20, xla); } } private boolean jj_2_22(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_22(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(21, xla); } } private boolean jj_2_23(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_23(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(22, xla); } } private boolean jj_2_24(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_24(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(23, xla); } } private boolean jj_2_25(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_25(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(24, xla); } } private boolean jj_2_26(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_26(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(25, xla); } } private boolean jj_2_27(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_27(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(26, xla); } } private boolean jj_2_28(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_28(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(27, xla); } } private boolean jj_2_29(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_29(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(28, xla); } } private boolean jj_2_30(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_30(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(29, xla); } } private boolean jj_2_31(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_31(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(30, xla); } } private boolean jj_2_32(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_32(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(31, xla); } } private boolean jj_2_33(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_33(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(32, xla); } } private boolean jj_2_34(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_34(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(33, xla); } } private boolean jj_2_35(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_35(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(34, xla); } } private boolean jj_2_36(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_36(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(35, xla); } } private boolean jj_2_37(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_37(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(36, xla); } } private boolean jj_2_38(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_38(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(37, xla); } } private boolean jj_2_39(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_39(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(38, xla); } } private boolean jj_2_40(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_40(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(39, xla); } } private boolean jj_2_41(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_41(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(40, xla); } } private boolean jj_2_42(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_42(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(41, xla); } } private boolean jj_2_43(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_43(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(42, xla); } } private boolean jj_2_44(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_44(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(43, xla); } } private boolean jj_2_45(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_45(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(44, xla); } } private boolean jj_2_46(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_46(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(45, xla); } } private boolean jj_2_47(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_47(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(46, xla); } } private boolean jj_2_48(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_48(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(47, xla); } } private boolean jj_2_49(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_49(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(48, xla); } } private boolean jj_3R_303() { if (jj_scan_token(BIT_AND)) return true; if (jj_3R_287()) return true; return false; } private boolean jj_3R_111() { Token xsp; if (jj_3R_179()) return true; while (true) { xsp = jj_scanpos; if (jj_3R_179()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_277() { if (jj_scan_token(IF)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_237()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_393()) jj_scanpos = xsp; return false; } private boolean jj_3R_325() { if (jj_3R_114()) return true; return false; } private boolean jj_3R_332() { if (jj_scan_token(THROWS)) return true; if (jj_3R_353()) return true; return false; } private boolean jj_3R_267() { if (jj_3R_287()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_303()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3_49() { if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(LPAREN)) return true; return false; } private boolean jj_3R_330() { if (jj_3R_114()) return true; return false; } private boolean jj_3R_266() { if (jj_scan_token(INTERFACE)) return true; return false; } private boolean jj_3R_320() { Token xsp; xsp = jj_scanpos; if (jj_3R_330()) jj_scanpos = xsp; if (jj_scan_token(IDENTIFIER)) return true; if (jj_3R_331()) return true; xsp = jj_scanpos; if (jj_3R_332()) jj_scanpos = xsp; if (jj_scan_token(LBRACE)) return true; xsp = jj_scanpos; if (jj_3R_333()) jj_scanpos = xsp; while (true) { xsp = jj_scanpos; if (jj_3R_334()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3R_165() { if (jj_3R_89()) return true; return false; } private boolean jj_3R_265() { if (jj_scan_token(CLASS)) return true; return false; } private boolean jj_3R_238() { Token xsp; xsp = jj_scanpos; if (jj_3R_265()) { jj_scanpos = xsp; if (jj_3R_266()) return true; } if (jj_scan_token(IDENTIFIER)) return true; xsp = jj_scanpos; if (jj_3R_325()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_326()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_327()) jj_scanpos = xsp; if (jj_3R_270()) return true; return false; } private boolean jj_3R_164() { if (jj_scan_token(DOT)) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_297() { if (jj_scan_token(XOR)) return true; if (jj_3R_267()) return true; return false; } private boolean jj_3R_239() { if (jj_3R_267()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_297()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_412() { if (jj_scan_token(_DEFAULT)) return true; if (jj_scan_token(COLON)) return true; return false; } private boolean jj_3R_163() { if (jj_scan_token(LBRACKET)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3_37() { if (jj_3R_103()) return true; return false; } private boolean jj_3R_112() { if (jj_scan_token(BIT_OR)) return true; return false; } private boolean jj_3R_377() { if (jj_scan_token(135)) return true; return false; } private boolean jj_3R_68() { if (jj_3R_111()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_112()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_411() { if (jj_scan_token(CASE)) return true; if (jj_3R_94()) return true; if (jj_scan_token(COLON)) return true; return false; } private boolean jj_3R_402() { Token xsp; xsp = jj_scanpos; if (jj_3R_411()) { jj_scanpos = xsp; if (jj_3R_412()) return true; } return false; } private boolean jj_3_36() { if (jj_scan_token(DOT)) return true; if (jj_3R_102()) return true; return false; } private boolean jj_3R_365() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_377()) jj_scanpos = xsp; if (jj_3R_354()) return true; return false; } private boolean jj_3R_288() { if (jj_scan_token(BIT_OR)) return true; if (jj_3R_239()) return true; return false; } private boolean jj_3R_225() { if (jj_3R_239()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_288()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3_35() { if (jj_scan_token(DOT)) return true; if (jj_scan_token(THIS)) return true; return false; } private boolean jj_3R_100() { Token xsp; xsp = jj_scanpos; if (jj_3_35()) { jj_scanpos = xsp; if (jj_3_36()) { jj_scanpos = xsp; if (jj_3_37()) { jj_scanpos = xsp; if (jj_3R_163()) { jj_scanpos = xsp; if (jj_3R_164()) { jj_scanpos = xsp; if (jj_3R_165()) return true; } } } } } return false; } private boolean jj_3R_403() { if (jj_3R_207()) return true; return false; } private boolean jj_3R_268() { if (jj_scan_token(SC_AND)) return true; if (jj_3R_225()) return true; return false; } private boolean jj_3R_209() { if (jj_3R_225()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_268()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_392() { if (jj_3R_402()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_403()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_366() { if (jj_scan_token(COMMA)) return true; if (jj_3R_365()) return true; return false; } private boolean jj_3R_178() { if (jj_3R_106()) return true; return false; } private boolean jj_3R_276() { if (jj_scan_token(SWITCH)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_scan_token(LBRACE)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_392()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3_34() { if (jj_3R_101()) return true; if (jj_scan_token(DOT)) return true; if (jj_scan_token(CLASS)) return true; return false; } private boolean jj_3R_352() { if (jj_3R_365()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_366()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3_7() { if (jj_scan_token(LANGLE)) return true; if (jj_3R_63()) return true; return false; } private boolean jj_3R_81() { if (jj_3R_113()) return true; return false; } private boolean jj_3R_242() { if (jj_scan_token(SC_OR)) return true; if (jj_3R_209()) return true; return false; } private boolean jj_3R_331() { if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_352()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; } private boolean jj_3R_191() { if (jj_3R_209()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_242()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_177() { if (jj_3R_101()) return true; if (jj_scan_token(DOT)) return true; if (jj_scan_token(CLASS)) return true; return false; } private boolean jj_3R_80() { if (jj_scan_token(STRICTFP)) return true; return false; } private boolean jj_3R_272() { if (jj_scan_token(COMMA)) return true; return false; } private boolean jj_3R_176() { if (jj_3R_102()) return true; return false; } private boolean jj_3R_79() { if (jj_scan_token(VOLATILE)) return true; return false; } private boolean jj_3_48() { if (jj_scan_token(COMMA)) return true; if (jj_3R_107()) return true; return false; } private boolean jj_3R_175() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; return false; } private boolean jj_3R_78() { if (jj_scan_token(TRANSIENT)) return true; return false; } private boolean jj_3R_410() { if (jj_3R_93()) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3R_200() { if (jj_scan_token(LBRACE)) return true; if (jj_3R_107()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_48()) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; if (jj_3R_272()) jj_scanpos = xsp; if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3R_409() { if (jj_scan_token(DECR)) return true; return false; } private boolean jj_3R_77() { if (jj_scan_token(NATIVE)) return true; return false; } private boolean jj_3R_228() { if (jj_scan_token(HOOK)) return true; if (jj_3R_94()) return true; if (jj_scan_token(COLON)) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3R_408() { if (jj_scan_token(INCR)) return true; return false; } private boolean jj_3R_110() { if (jj_scan_token(134)) return true; return false; } private boolean jj_3R_174() { if (jj_scan_token(SUPER)) return true; if (jj_scan_token(DOT)) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_150() { if (jj_3R_191()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_228()) jj_scanpos = xsp; return false; } private boolean jj_3R_401() { Token xsp; xsp = jj_scanpos; if (jj_3R_408()) { jj_scanpos = xsp; if (jj_3R_409()) { jj_scanpos = xsp; if (jj_3R_410()) return true; } } return false; } private boolean jj_3R_76() { if (jj_scan_token(SYNCHRONIZED)) return true; return false; } private boolean jj_3R_173() { if (jj_scan_token(THIS)) return true; return false; } private boolean jj_3R_67() { Token xsp; xsp = jj_scanpos; if (jj_3R_110()) jj_scanpos = xsp; if (jj_3R_63()) return true; if (jj_scan_token(COLON)) return true; return false; } private boolean jj_3R_172() { if (jj_3R_201()) return true; return false; } private boolean jj_3R_356() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_295() { if (jj_3R_62()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_401()) jj_scanpos = xsp; return false; } private boolean jj_3R_108() { Token xsp; xsp = jj_scanpos; if (jj_3R_172()) { jj_scanpos = xsp; if (jj_3R_173()) { jj_scanpos = xsp; if (jj_3R_174()) { jj_scanpos = xsp; if (jj_3R_175()) { jj_scanpos = xsp; if (jj_3R_176()) { jj_scanpos = xsp; if (jj_3R_177()) { jj_scanpos = xsp; if (jj_3R_178()) return true; } } } } } } return false; } private boolean jj_3R_75() { if (jj_scan_token(ABSTRACT)) return true; return false; } private boolean jj_3R_294() { if (jj_3R_301()) return true; return false; } private boolean jj_3R_338() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_3R_331()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_356()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3_1() { if (jj_3R_61()) return true; return false; } private boolean jj_3R_293() { if (jj_3R_300()) return true; return false; } private boolean jj_3R_171() { if (jj_3R_150()) return true; return false; } private boolean jj_3_6() { if (jj_scan_token(LANGLE)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_67()) jj_scanpos = xsp; if (jj_3R_68()) return true; if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3R_74() { if (jj_scan_token(FINAL)) return true; return false; } private boolean jj_3R_275() { Token xsp; xsp = jj_scanpos; if (jj_3R_293()) { jj_scanpos = xsp; if (jj_3R_294()) { jj_scanpos = xsp; if (jj_3R_295()) return true; } } return false; } private boolean jj_3R_170() { if (jj_3R_200()) return true; return false; } private boolean jj_3R_149() { if (jj_scan_token(ORASSIGN)) return true; return false; } private boolean jj_3R_169() { if (jj_3R_113()) return true; return false; } private boolean jj_3R_107() { Token xsp; xsp = jj_scanpos; if (jj_3R_169()) { jj_scanpos = xsp; if (jj_3R_170()) { jj_scanpos = xsp; if (jj_3R_171()) return true; } } return false; } private boolean jj_3R_73() { if (jj_scan_token(PRIVATE)) return true; return false; } private boolean jj_3R_148() { if (jj_scan_token(XORASSIGN)) return true; return false; } private boolean jj_3R_147() { if (jj_scan_token(ANDASSIGN)) return true; return false; } private boolean jj_3R_72() { if (jj_scan_token(PROTECTED)) return true; return false; } private boolean jj_3R_341() { if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_146() { if (jj_scan_token(138)) return true; return false; } private boolean jj_3R_340() { if (jj_3R_117()) return true; return false; } private boolean jj_3R_145() { if (jj_scan_token(137)) return true; return false; } private boolean jj_3R_71() { if (jj_scan_token(STATIC)) return true; return false; } private boolean jj_3R_144() { if (jj_scan_token(136)) return true; return false; } private boolean jj_3R_248() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(ASSIGN)) return true; if (jj_3R_107()) return true; return false; } private boolean jj_3R_143() { if (jj_scan_token(MINUSASSIGN)) return true; return false; } private boolean jj_3R_70() { if (jj_scan_token(PUBLIC)) return true; return false; } private boolean jj_3R_274() { if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_339() { if (jj_scan_token(THROWS)) return true; if (jj_3R_353()) return true; return false; } private boolean jj_3R_103() { if (jj_scan_token(DOT)) return true; if (jj_3R_91()) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_142() { if (jj_scan_token(PLUSASSIGN)) return true; return false; } private boolean jj_3_9() { Token xsp; xsp = jj_scanpos; if (jj_3R_70()) { jj_scanpos = xsp; if (jj_3R_71()) { jj_scanpos = xsp; if (jj_3R_72()) { jj_scanpos = xsp; if (jj_3R_73()) { jj_scanpos = xsp; if (jj_3R_74()) { jj_scanpos = xsp; if (jj_3R_75()) { jj_scanpos = xsp; if (jj_3R_76()) { jj_scanpos = xsp; if (jj_3R_77()) { jj_scanpos = xsp; if (jj_3R_78()) { jj_scanpos = xsp; if (jj_3R_79()) { jj_scanpos = xsp; if (jj_3R_80()) { jj_scanpos = xsp; if (jj_3R_81()) return true; } } } } } } } } } } } return false; } private boolean jj_3R_141() { if (jj_scan_token(REMASSIGN)) return true; return false; } private boolean jj_3R_337() { if (jj_3R_114()) return true; return false; } private boolean jj_3R_104() { Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_9()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_322() { Token xsp; xsp = jj_scanpos; if (jj_3R_337()) jj_scanpos = xsp; if (jj_3R_101()) return true; if (jj_3R_338()) return true; xsp = jj_scanpos; if (jj_3R_339()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_340()) { jj_scanpos = xsp; if (jj_3R_341()) return true; } return false; } private boolean jj_3R_140() { if (jj_scan_token(SLASHASSIGN)) return true; return false; } private boolean jj_3R_139() { if (jj_scan_token(STARASSIGN)) return true; return false; } private boolean jj_3R_249() { if (jj_scan_token(COMMA)) return true; if (jj_3R_248()) return true; return false; } private boolean jj_3R_384() { if (jj_scan_token(COMMA)) return true; if (jj_3R_335()) return true; return false; } private boolean jj_3_33() { if (jj_3R_100()) return true; return false; } private boolean jj_3R_138() { if (jj_scan_token(ASSIGN)) return true; return false; } private boolean jj_3R_234() { if (jj_3R_248()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_249()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_93() { Token xsp; xsp = jj_scanpos; if (jj_3R_138()) { jj_scanpos = xsp; if (jj_3R_139()) { jj_scanpos = xsp; if (jj_3R_140()) { jj_scanpos = xsp; if (jj_3R_141()) { jj_scanpos = xsp; if (jj_3R_142()) { jj_scanpos = xsp; if (jj_3R_143()) { jj_scanpos = xsp; if (jj_3R_144()) { jj_scanpos = xsp; if (jj_3R_145()) { jj_scanpos = xsp; if (jj_3R_146()) { jj_scanpos = xsp; if (jj_3R_147()) { jj_scanpos = xsp; if (jj_3R_148()) { jj_scanpos = xsp; if (jj_3R_149()) return true; } } } } } } } } } } } return false; } private boolean jj_3R_62() { if (jj_3R_108()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_33()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_236() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; if (jj_3R_335()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_384()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_290() { if (jj_scan_token(COMMA)) return true; return false; } private boolean jj_3R_224() { if (jj_3R_238()) return true; return false; } private boolean jj_3R_204() { if (jj_scan_token(140)) return true; if (jj_3R_106()) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_107()) return true; if (jj_scan_token(RPAREN)) return true; return false; } private boolean jj_3_43() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_390() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_84()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_371()) return true; return false; } private boolean jj_3R_223() { if (jj_3R_237()) return true; return false; } private boolean jj_3_32() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_99()) return true; return false; } private boolean jj_3_14() { if (jj_scan_token(COMMA)) return true; if (jj_3R_87()) return true; return false; } private boolean jj_3R_222() { if (jj_3R_236()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_289() { if (jj_3R_87()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_14()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_207() { Token xsp; xsp = jj_scanpos; if (jj_3R_222()) { jj_scanpos = xsp; if (jj_3R_223()) { jj_scanpos = xsp; if (jj_3R_224()) return true; } } return false; } private boolean jj_3R_389() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_84()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_342()) return true; return false; } private boolean jj_3R_205() { if (jj_scan_token(140)) return true; if (jj_3R_106()) return true; return false; } private boolean jj_3R_387() { Token xsp; xsp = jj_scanpos; if (jj_3R_389()) { jj_scanpos = xsp; if (jj_3R_390()) return true; } return false; } private boolean jj_3R_186() { if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_289()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_290()) jj_scanpos = xsp; if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3_25() { if (jj_3R_93()) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3R_220() { if (jj_3R_234()) return true; return false; } private boolean jj_3R_94() { if (jj_3R_150()) return true; Token xsp; xsp = jj_scanpos; if (jj_3_25()) jj_scanpos = xsp; return false; } private boolean jj_3R_203() { if (jj_scan_token(140)) return true; if (jj_3R_106()) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_220()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; } private boolean jj_3R_119() { if (jj_3R_94()) return true; return false; } private boolean jj_3R_416() { if (jj_scan_token(DECR)) return true; return false; } private boolean jj_3R_118() { if (jj_3R_186()) return true; return false; } private boolean jj_3R_415() { if (jj_scan_token(INCR)) return true; return false; } private boolean jj_3R_185() { if (jj_3R_207()) return true; return false; } private boolean jj_3R_87() { Token xsp; xsp = jj_scanpos; if (jj_3R_118()) { jj_scanpos = xsp; if (jj_3R_119()) return true; } return false; } private boolean jj_3R_407() { Token xsp; xsp = jj_scanpos; if (jj_3R_415()) { jj_scanpos = xsp; if (jj_3R_416()) return true; } return false; } private boolean jj_3_47() { if (jj_scan_token(140)) return true; if (jj_3R_106()) return true; if (jj_scan_token(LPAREN)) return true; return false; } private boolean jj_3R_388() { if (jj_3R_62()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_407()) jj_scanpos = xsp; return false; } private boolean jj_3R_105() { if (jj_scan_token(140)) return true; if (jj_3R_106()) return true; if (jj_scan_token(LPAREN)) return true; if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(ASSIGN)) return true; return false; } private boolean jj_3_46() { Token xsp; xsp = jj_scanpos; if (jj_3R_105()) { jj_scanpos = xsp; if (jj_scan_token(92)) return true; } return false; } private boolean jj_3R_117() { if (jj_scan_token(LBRACE)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_185()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3R_182() { if (jj_3R_205()) return true; return false; } private boolean jj_3R_181() { if (jj_3R_204()) return true; return false; } private boolean jj_3R_180() { if (jj_3R_203()) return true; return false; } private boolean jj_3R_368() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_367() { if (jj_scan_token(COMMA)) return true; if (jj_3R_106()) return true; return false; } private boolean jj_3R_113() { Token xsp; xsp = jj_scanpos; if (jj_3R_180()) { jj_scanpos = xsp; if (jj_3R_181()) { jj_scanpos = xsp; if (jj_3R_182()) return true; } } return false; } private boolean jj_3R_199() { if (jj_3R_201()) return true; return false; } private boolean jj_3R_354() { if (jj_scan_token(IDENTIFIER)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_368()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_353() { if (jj_3R_106()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_367()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_198() { if (jj_scan_token(NEW)) return true; return false; } private boolean jj_3R_151() { return false; } private boolean jj_3R_69() { if (jj_3R_113()) return true; return false; } private boolean jj_3R_197() { if (jj_scan_token(SUPER)) return true; return false; } private boolean jj_3_8() { Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_69()) { jj_scanpos = xsp; break; } } if (jj_scan_token(PACKAGE)) return true; return false; } private boolean jj_3R_61() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(COLON)) return true; if (jj_3R_237()) return true; return false; } private boolean jj_3R_196() { if (jj_scan_token(THIS)) return true; return false; } private boolean jj_3R_96() { jj_lookingAhead = true; jj_semLA = getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT; jj_lookingAhead = false; if (!jj_semLA || jj_3R_151()) return true; if (jj_scan_token(RANGLE)) return true; if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3R_195() { if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_194() { if (jj_scan_token(LPAREN)) return true; return false; } private boolean jj_3R_355() { if (jj_scan_token(ASSIGN)) return true; if (jj_3R_87()) return true; return false; } private boolean jj_3R_152() { return false; } private boolean jj_3R_193() { if (jj_scan_token(BANG)) return true; return false; } private boolean jj_3R_335() { if (jj_3R_354()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_355()) jj_scanpos = xsp; return false; } private boolean jj_3R_192() { if (jj_scan_token(TILDE)) return true; return false; } private boolean jj_3R_391() { if (jj_scan_token(COLON)) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3_24() { if (jj_scan_token(DOT)) return true; if (jj_3R_92()) return true; return false; } private boolean jj_3R_97() { jj_lookingAhead = true; jj_semLA = getToken(1).kind == GT && ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT; jj_lookingAhead = false; if (!jj_semLA || jj_3R_152()) return true; if (jj_scan_token(RANGLE)) return true; if (jj_scan_token(RANGLE)) return true; if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3_2() { if (jj_scan_token(LANGLE)) return true; if (jj_scan_token(STAR)) return true; return false; } private boolean jj_3R_106() { if (jj_3R_92()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_24()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_273() { if (jj_scan_token(ASSERT)) return true; if (jj_3R_94()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_391()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_154() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_84()) return true; if (jj_scan_token(RPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_192()) { jj_scanpos = xsp; if (jj_3R_193()) { jj_scanpos = xsp; if (jj_3R_194()) { jj_scanpos = xsp; if (jj_3R_195()) { jj_scanpos = xsp; if (jj_3R_196()) { jj_scanpos = xsp; if (jj_3R_197()) { jj_scanpos = xsp; if (jj_3R_198()) { jj_scanpos = xsp; if (jj_3R_199()) return true; } } } } } } } return false; } private boolean jj_3_31() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_84()) return true; if (jj_scan_token(LBRACKET)) return true; return false; } private boolean jj_3R_85() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_336() { if (jj_scan_token(COMMA)) return true; if (jj_3R_335()) return true; return false; } private boolean jj_3R_137() { if (jj_scan_token(_EOF)) return true; return false; } private boolean jj_3R_321() { if (jj_3R_84()) return true; if (jj_3R_335()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_336()) { jj_scanpos = xsp; break; } } if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_400() { if (jj_scan_token(FINALLY)) return true; if (jj_3R_117()) return true; return false; } private boolean jj_3R_136() { if (jj_scan_token(_TOKEN_MGR_DECLS)) return true; return false; } private boolean jj_3R_264() { if (jj_3R_286()) return true; return false; } private boolean jj_3R_153() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_84()) return true; if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_263() { if (jj_3R_285()) return true; return false; } private boolean jj_3R_135() { if (jj_scan_token(_SKIP)) return true; return false; } private boolean jj_3R_262() { if (jj_3R_284()) return true; return false; } private boolean jj_3R_134() { if (jj_scan_token(_MORE)) return true; return false; } private boolean jj_3R_261() { if (jj_3R_283()) return true; return false; } private boolean jj_3_30() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_99()) return true; return false; } private boolean jj_3R_133() { if (jj_scan_token(_SPECIAL_TOKEN)) return true; return false; } private boolean jj_3R_260() { if (jj_3R_282()) return true; return false; } private boolean jj_3R_167() { if (jj_3R_84()) return true; return false; } private boolean jj_3R_98() { Token xsp; xsp = jj_scanpos; if (jj_3_30()) { jj_scanpos = xsp; if (jj_3R_153()) { jj_scanpos = xsp; if (jj_3R_154()) return true; } } return false; } private boolean jj_3_12() { if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_85()) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; if (jj_scan_token(98)) { jj_scanpos = xsp; if (jj_scan_token(100)) { jj_scanpos = xsp; if (jj_scan_token(97)) return true; } } return false; } private boolean jj_3R_259() { if (jj_3R_281()) return true; return false; } private boolean jj_3R_132() { if (jj_scan_token(_TOKEN)) return true; return false; } private boolean jj_3R_83() { if (jj_3R_114()) return true; return false; } private boolean jj_3R_166() { if (jj_scan_token(VOID)) return true; return false; } private boolean jj_3R_399() { if (jj_scan_token(CATCH)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_365()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_117()) return true; return false; } private boolean jj_3R_305() { if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_258() { if (jj_3R_280()) return true; return false; } private boolean jj_3_11() { Token xsp; xsp = jj_scanpos; if (jj_3R_83()) jj_scanpos = xsp; if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(LPAREN)) return true; return false; } private boolean jj_3R_131() { if (jj_scan_token(_JAVACODE)) return true; return false; } private boolean jj_3R_257() { if (jj_3R_279()) return true; return false; } private boolean jj_3R_314() { if (jj_3R_322()) return true; return false; } private boolean jj_3R_101() { Token xsp; xsp = jj_scanpos; if (jj_3R_166()) { jj_scanpos = xsp; if (jj_3R_167()) return true; } return false; } private boolean jj_3R_130() { if (jj_scan_token(_PARSER_END)) return true; return false; } private boolean jj_3R_256() { if (jj_3R_278()) return true; return false; } private boolean jj_3R_286() { if (jj_scan_token(TRY)) return true; if (jj_3R_117()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_399()) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; if (jj_3R_400()) jj_scanpos = xsp; return false; } private boolean jj_3R_313() { if (jj_3R_321()) return true; return false; } private boolean jj_3R_66() { if (jj_3R_62()) return true; if (jj_scan_token(ASSIGN)) return true; return false; } private boolean jj_3R_255() { if (jj_3R_277()) return true; return false; } private boolean jj_3R_129() { if (jj_scan_token(_PARSER_BEGIN)) return true; return false; } private boolean jj_3R_312() { if (jj_3R_320()) return true; return false; } private boolean jj_3R_254() { if (jj_3R_276()) return true; return false; } private boolean jj_3_4() { if (jj_3R_63()) return true; if (jj_scan_token(LPAREN)) return true; return false; } private boolean jj_3R_128() { if (jj_scan_token(_IGNORE_CASE)) return true; return false; } private boolean jj_3R_311() { if (jj_3R_319()) return true; return false; } private boolean jj_3R_310() { if (jj_3R_238()) return true; return false; } private boolean jj_3R_127() { if (jj_scan_token(_LOOKAHEAD)) return true; return false; } private boolean jj_3R_253() { if (jj_3R_275()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_126() { if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_252() { if (jj_3R_274()) return true; return false; } private boolean jj_3R_162() { if (jj_scan_token(DOUBLE)) return true; return false; } private boolean jj_3R_251() { if (jj_3R_117()) return true; return false; } private boolean jj_3R_161() { if (jj_scan_token(FLOAT)) return true; return false; } private boolean jj_3R_92() { Token xsp; xsp = jj_scanpos; if (jj_3R_126()) { jj_scanpos = xsp; if (jj_3R_127()) { jj_scanpos = xsp; if (jj_3R_128()) { jj_scanpos = xsp; if (jj_3R_129()) { jj_scanpos = xsp; if (jj_3R_130()) { jj_scanpos = xsp; if (jj_3R_131()) { jj_scanpos = xsp; if (jj_3R_132()) { jj_scanpos = xsp; if (jj_3R_133()) { jj_scanpos = xsp; if (jj_3R_134()) { jj_scanpos = xsp; if (jj_3R_135()) { jj_scanpos = xsp; if (jj_3R_136()) { jj_scanpos = xsp; if (jj_3R_137()) return true; } } } } } } } } } } } return false; } private boolean jj_3R_304() { if (jj_3R_104()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_310()) { jj_scanpos = xsp; if (jj_3R_311()) { jj_scanpos = xsp; if (jj_3R_312()) { jj_scanpos = xsp; if (jj_3R_313()) { jj_scanpos = xsp; if (jj_3R_314()) return true; } } } } return false; } private boolean jj_3R_250() { if (jj_3R_273()) return true; return false; } private boolean jj_3R_160() { if (jj_scan_token(LONG)) return true; return false; } private boolean jj_3R_65() { if (jj_3R_109()) return true; return false; } private boolean jj_3_42() { if (jj_3R_61()) return true; return false; } private boolean jj_3R_159() { if (jj_scan_token(INT)) return true; return false; } private boolean jj_3_29() { if (jj_3R_98()) return true; return false; } private boolean jj_3R_237() { Token xsp; xsp = jj_scanpos; if (jj_3_42()) { jj_scanpos = xsp; if (jj_3R_250()) { jj_scanpos = xsp; if (jj_3R_251()) { jj_scanpos = xsp; if (jj_3R_252()) { jj_scanpos = xsp; if (jj_3R_253()) { jj_scanpos = xsp; if (jj_3R_254()) { jj_scanpos = xsp; if (jj_3R_255()) { jj_scanpos = xsp; if (jj_3R_256()) { jj_scanpos = xsp; if (jj_3R_257()) { jj_scanpos = xsp; if (jj_3R_258()) { jj_scanpos = xsp; if (jj_3R_259()) { jj_scanpos = xsp; if (jj_3R_260()) { jj_scanpos = xsp; if (jj_3R_261()) { jj_scanpos = xsp; if (jj_3R_262()) { jj_scanpos = xsp; if (jj_3R_263()) { jj_scanpos = xsp; if (jj_3R_264()) return true; } } } } } } } } } } } } } } } return false; } private boolean jj_3_13() { if (jj_3R_86()) return true; return false; } private boolean jj_3R_158() { if (jj_scan_token(SHORT)) return true; return false; } private boolean jj_3R_298() { Token xsp; xsp = jj_scanpos; if (jj_3_13()) { jj_scanpos = xsp; if (jj_3R_304()) { jj_scanpos = xsp; if (jj_3R_305()) return true; } } return false; } private boolean jj_3R_380() { if (jj_3R_388()) return true; return false; } private boolean jj_3_3() { if (jj_3R_62()) return true; if (jj_scan_token(ASSIGN)) return true; return false; } private boolean jj_3R_157() { if (jj_scan_token(BYTE)) return true; return false; } private boolean jj_3R_285() { if (jj_scan_token(SYNCHRONIZED)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_117()) return true; return false; } private boolean jj_3R_379() { if (jj_3R_387()) return true; return false; } private boolean jj_3_5() { Token xsp; xsp = jj_scanpos; if (jj_3R_64()) { jj_scanpos = xsp; if (jj_3R_65()) { jj_scanpos = xsp; if (jj_scan_token(101)) { jj_scanpos = xsp; if (jj_3R_66()) return true; } } } return false; } private boolean jj_3R_64() { if (jj_3R_63()) return true; return false; } private boolean jj_3R_156() { if (jj_scan_token(CHAR)) return true; return false; } private boolean jj_3R_155() { if (jj_scan_token(BOOLEAN)) return true; return false; } private boolean jj_3R_386() { if (jj_scan_token(BANG)) return true; return false; } private boolean jj_3R_99() { Token xsp; xsp = jj_scanpos; if (jj_3R_155()) { jj_scanpos = xsp; if (jj_3R_156()) { jj_scanpos = xsp; if (jj_3R_157()) { jj_scanpos = xsp; if (jj_3R_158()) { jj_scanpos = xsp; if (jj_3R_159()) { jj_scanpos = xsp; if (jj_3R_160()) { jj_scanpos = xsp; if (jj_3R_161()) { jj_scanpos = xsp; if (jj_3R_162()) return true; } } } } } } } return false; } private boolean jj_3R_385() { if (jj_scan_token(TILDE)) return true; return false; } private boolean jj_3R_378() { Token xsp; xsp = jj_scanpos; if (jj_3R_385()) { jj_scanpos = xsp; if (jj_3R_386()) return true; } if (jj_3R_342()) return true; return false; } private boolean jj_3R_371() { Token xsp; xsp = jj_scanpos; if (jj_3R_378()) { jj_scanpos = xsp; if (jj_3R_379()) { jj_scanpos = xsp; if (jj_3R_380()) return true; } } return false; } private boolean jj_3R_269() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_63() { if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_291() { if (jj_3R_298()) return true; return false; } private boolean jj_3R_243() { Token xsp; if (jj_3R_269()) return true; while (true) { xsp = jj_scanpos; if (jj_3R_269()) { jj_scanpos = xsp; break; } } if (jj_3R_186()) return true; return false; } private boolean jj_3R_284() { if (jj_scan_token(THROW)) return true; if (jj_3R_94()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_307() { if (jj_scan_token(SUPER)) return true; if (jj_3R_90()) return true; return false; } private boolean jj_3R_270() { if (jj_scan_token(LBRACE)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_291()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3R_301() { if (jj_scan_token(DECR)) return true; if (jj_3R_62()) return true; return false; } private boolean jj_3R_306() { if (jj_scan_token(EXTENDS)) return true; if (jj_3R_90()) return true; return false; } private boolean jj_3_40() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_299() { Token xsp; xsp = jj_scanpos; if (jj_3R_306()) { jj_scanpos = xsp; if (jj_3R_307()) return true; } return false; } private boolean jj_3R_300() { if (jj_scan_token(INCR)) return true; if (jj_3R_62()) return true; return false; } private boolean jj_3R_398() { if (jj_3R_94()) return true; return false; } private boolean jj_3_39() { if (jj_scan_token(LBRACKET)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_360() { if (jj_3R_371()) return true; return false; } private boolean jj_3_41() { Token xsp; if (jj_3_39()) return true; while (true) { xsp = jj_scanpos; if (jj_3_39()) { jj_scanpos = xsp; break; } } while (true) { xsp = jj_scanpos; if (jj_3_40()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_292() { if (jj_3R_299()) return true; return false; } private boolean jj_3R_235() { if (jj_scan_token(BIT_AND)) return true; if (jj_3R_188()) return true; return false; } private boolean jj_3R_359() { if (jj_3R_301()) return true; return false; } private boolean jj_3R_229() { Token xsp; xsp = jj_scanpos; if (jj_3_41()) { jj_scanpos = xsp; if (jj_3R_243()) return true; } return false; } private boolean jj_3R_358() { if (jj_3R_300()) return true; return false; } private boolean jj_3R_221() { if (jj_scan_token(EXTENDS)) return true; if (jj_3R_188()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_235()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_190() { if (jj_scan_token(HOOK)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_292()) jj_scanpos = xsp; return false; } private boolean jj_3R_283() { if (jj_scan_token(RETURN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_398()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_189() { if (jj_3R_90()) return true; return false; } private boolean jj_3R_370() { if (jj_scan_token(MINUS)) return true; return false; } private boolean jj_3R_271() { if (jj_3R_109()) return true; return false; } private boolean jj_3R_125() { Token xsp; xsp = jj_scanpos; if (jj_3R_189()) { jj_scanpos = xsp; if (jj_3R_190()) return true; } return false; } private boolean jj_3R_369() { if (jj_scan_token(PLUS)) return true; return false; } private boolean jj_3R_357() { Token xsp; xsp = jj_scanpos; if (jj_3R_369()) { jj_scanpos = xsp; if (jj_3R_370()) return true; } if (jj_3R_342()) return true; return false; } private boolean jj_3R_206() { if (jj_3R_221()) return true; return false; } private boolean jj_3R_342() { Token xsp; xsp = jj_scanpos; if (jj_3R_357()) { jj_scanpos = xsp; if (jj_3R_358()) { jj_scanpos = xsp; if (jj_3R_359()) { jj_scanpos = xsp; if (jj_3R_360()) return true; } } } return false; } private boolean jj_3R_397() { if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_183() { if (jj_scan_token(IDENTIFIER)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_206()) jj_scanpos = xsp; return false; } private boolean jj_3R_282() { if (jj_scan_token(CONTINUE)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_397()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_245() { if (jj_scan_token(COMMA)) return true; if (jj_3R_125()) return true; return false; } private boolean jj_3R_244() { if (jj_3R_270()) return true; return false; } private boolean jj_3R_91() { if (jj_scan_token(LANGLE)) return true; if (jj_3R_125()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_245()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3R_232() { if (jj_3R_89()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_244()) jj_scanpos = xsp; return false; } private boolean jj_3R_231() { if (jj_3R_229()) return true; return false; } private boolean jj_3R_184() { if (jj_scan_token(COMMA)) return true; if (jj_3R_183()) return true; return false; } private boolean jj_3R_383() { if (jj_scan_token(REM)) return true; return false; } private boolean jj_3R_396() { if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_382() { if (jj_scan_token(SLASH)) return true; return false; } private boolean jj_3R_114() { if (jj_scan_token(LANGLE)) return true; if (jj_3R_183()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_184()) { jj_scanpos = xsp; break; } } if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3R_230() { if (jj_3R_91()) return true; return false; } private boolean jj_3R_281() { if (jj_scan_token(BREAK)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_396()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_381() { if (jj_scan_token(STAR)) return true; return false; } private boolean jj_3R_247() { if (jj_3R_271()) return true; return false; } private boolean jj_3_23() { if (jj_3R_91()) return true; return false; } private boolean jj_3R_372() { Token xsp; xsp = jj_scanpos; if (jj_3R_381()) { jj_scanpos = xsp; if (jj_3R_382()) { jj_scanpos = xsp; if (jj_3R_383()) return true; } } if (jj_3R_342()) return true; return false; } private boolean jj_3R_168() { if (jj_scan_token(NEW)) return true; if (jj_3R_188()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_230()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_231()) { jj_scanpos = xsp; if (jj_3R_232()) return true; } return false; } private boolean jj_3R_246() { if (jj_scan_token(TILDE)) return true; return false; } private boolean jj_3R_323() { if (jj_3R_342()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_372()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_233() { Token xsp; xsp = jj_scanpos; if (jj_3R_246()) jj_scanpos = xsp; if (jj_scan_token(LBRACKET)) return true; xsp = jj_scanpos; if (jj_3R_247()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_414() { if (jj_3R_419()) return true; return false; } private boolean jj_3R_376() { if (jj_3R_270()) return true; return false; } private boolean jj_3_22() { if (jj_scan_token(DOT)) return true; if (jj_scan_token(IDENTIFIER)) return true; Token xsp; xsp = jj_scanpos; if (jj_3_23()) jj_scanpos = xsp; return false; } private boolean jj_3_38() { if (jj_scan_token(NEW)) return true; if (jj_3R_99()) return true; if (jj_3R_229()) return true; return false; } private boolean jj_3R_375() { if (jj_3R_89()) return true; return false; } private boolean jj_3R_102() { Token xsp; xsp = jj_scanpos; if (jj_3_38()) { jj_scanpos = xsp; if (jj_3R_168()) return true; } return false; } private boolean jj_3_21() { if (jj_3R_91()) return true; return false; } private boolean jj_3R_82() { if (jj_3R_104()) return true; if (jj_scan_token(IDENTIFIER)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_375()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_376()) jj_scanpos = xsp; return false; } private boolean jj_3R_188() { if (jj_scan_token(IDENTIFIER)) return true; Token xsp; xsp = jj_scanpos; if (jj_3_21()) jj_scanpos = xsp; while (true) { xsp = jj_scanpos; if (jj_3_22()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_420() { if (jj_scan_token(COMMA)) return true; if (jj_3R_275()) return true; return false; } private boolean jj_3R_419() { if (jj_3R_275()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_420()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_374() { if (jj_scan_token(MINUS)) return true; return false; } private boolean jj_3R_373() { if (jj_scan_token(PLUS)) return true; return false; } private boolean jj_3_45() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } private boolean jj_3R_364() { if (jj_3R_298()) return true; return false; } private boolean jj_3R_361() { Token xsp; xsp = jj_scanpos; if (jj_3R_373()) { jj_scanpos = xsp; if (jj_3R_374()) return true; } if (jj_3R_323()) return true; return false; } private boolean jj_3R_418() { if (jj_3R_419()) return true; return false; } private boolean jj_3R_315() { if (jj_3R_323()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_361()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_417() { if (jj_3R_236()) return true; return false; } private boolean jj_3R_351() { if (jj_scan_token(SEMICOLON)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_364()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_208() { if (jj_scan_token(COMMA)) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3R_413() { Token xsp; xsp = jj_scanpos; if (jj_3R_417()) { jj_scanpos = xsp; if (jj_3R_418()) return true; } return false; } private boolean jj_3_20() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3R_187() { if (jj_3R_94()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_208()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_350() { if (jj_scan_token(COMMA)) return true; return false; } private boolean jj_3R_124() { if (jj_3R_188()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_20()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3_10() { if (jj_scan_token(COMMA)) return true; if (jj_3R_82()) return true; return false; } private boolean jj_3R_406() { if (jj_3R_414()) return true; return false; } private boolean jj_3_28() { if (jj_3R_97()) return true; return false; } private boolean jj_3_19() { if (jj_scan_token(LBRACKET)) return true; if (jj_scan_token(RBRACKET)) return true; return false; } private boolean jj_3_27() { if (jj_3R_96()) return true; return false; } private boolean jj_3R_349() { if (jj_3R_82()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_10()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_95() { if (jj_scan_token(139)) return true; return false; } private boolean jj_3R_405() { if (jj_3R_94()) return true; return false; } private boolean jj_3R_123() { if (jj_3R_99()) return true; Token xsp; if (jj_3_19()) return true; while (true) { xsp = jj_scanpos; if (jj_3_19()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_329() { if (jj_scan_token(LBRACE)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_349()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_350()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_3R_351()) jj_scanpos = xsp; if (jj_scan_token(RBRACE)) return true; return false; } private boolean jj_3R_90() { Token xsp; xsp = jj_scanpos; if (jj_3R_123()) { jj_scanpos = xsp; if (jj_3R_124()) return true; } return false; } private boolean jj_3_26() { Token xsp; xsp = jj_scanpos; if (jj_3R_95()) { jj_scanpos = xsp; if (jj_3_27()) { jj_scanpos = xsp; if (jj_3_28()) return true; } } if (jj_3R_315()) return true; return false; } private boolean jj_3R_404() { if (jj_3R_413()) return true; return false; } private boolean jj_3R_122() { if (jj_3R_187()) return true; return false; } private boolean jj_3R_308() { if (jj_3R_315()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_26()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_395() { Token xsp; xsp = jj_scanpos; if (jj_3R_404()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; xsp = jj_scanpos; if (jj_3R_405()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; xsp = jj_scanpos; if (jj_3R_406()) jj_scanpos = xsp; return false; } private boolean jj_3R_89() { if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_122()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; } private boolean jj_3_44() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(COLON)) return true; return false; } private boolean jj_3R_394() { if (jj_3R_104()) return true; if (jj_3R_84()) return true; if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(COLON)) return true; if (jj_3R_94()) return true; return false; } private boolean jj_3R_115() { if (jj_3R_99()) return true; return false; } private boolean jj_3R_346() { if (jj_scan_token(GE)) return true; return false; } private boolean jj_3R_328() { if (jj_3R_348()) return true; return false; } private boolean jj_3_18() { if (jj_3R_90()) return true; return false; } private boolean jj_3R_345() { if (jj_scan_token(LE)) return true; return false; } private boolean jj_3R_84() { Token xsp; xsp = jj_scanpos; if (jj_3_18()) { jj_scanpos = xsp; if (jj_3R_115()) return true; } return false; } private boolean jj_3R_280() { if (jj_scan_token(FOR)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_394()) { jj_scanpos = xsp; if (jj_3R_395()) return true; } if (jj_scan_token(RPAREN)) return true; if (jj_3R_237()) return true; return false; } private boolean jj_3R_319() { if (jj_scan_token(ENUM)) return true; if (jj_scan_token(IDENTIFIER)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_328()) jj_scanpos = xsp; if (jj_3R_329()) return true; return false; } private boolean jj_3R_344() { if (jj_scan_token(RANGLE)) return true; return false; } private boolean jj_3R_227() { if (jj_scan_token(NULL)) return true; return false; } private boolean jj_3R_219() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_68()) return true; return false; } private boolean jj_3R_343() { if (jj_scan_token(LANGLE)) return true; return false; } private boolean jj_3R_218() { if (jj_3R_233()) return true; return false; } private boolean jj_3R_324() { Token xsp; xsp = jj_scanpos; if (jj_3R_343()) { jj_scanpos = xsp; if (jj_3R_344()) { jj_scanpos = xsp; if (jj_3R_345()) { jj_scanpos = xsp; if (jj_3R_346()) return true; } } } if (jj_3R_308()) return true; return false; } private boolean jj_3R_116() { if (jj_scan_token(STATIC)) return true; return false; } private boolean jj_3R_302() { if (jj_3R_308()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_324()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_86() { Token xsp; xsp = jj_scanpos; if (jj_3R_116()) jj_scanpos = xsp; if (jj_3R_117()) return true; return false; } private boolean jj_3R_109() { if (jj_scan_token(STRING_LITERAL)) return true; return false; } private boolean jj_3R_217() { if (jj_scan_token(LANGLE)) return true; if (jj_3R_63()) return true; return false; } private boolean jj_3R_363() { if (jj_scan_token(COMMA)) return true; if (jj_3R_188()) return true; return false; } private boolean jj_3R_216() { if (jj_3R_109()) return true; return false; } private boolean jj_3R_202() { Token xsp; xsp = jj_scanpos; if (jj_3R_216()) { jj_scanpos = xsp; if (jj_3R_217()) { jj_scanpos = xsp; if (jj_3R_218()) { jj_scanpos = xsp; if (jj_3R_219()) return true; } } } return false; } private boolean jj_3R_348() { if (jj_scan_token(IMPLEMENTS)) return true; if (jj_3R_188()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_363()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_241() { if (jj_scan_token(FALSE)) return true; return false; } private boolean jj_3R_240() { if (jj_scan_token(TRUE)) return true; return false; } private boolean jj_3R_316() { if (jj_scan_token(INSTANCEOF)) return true; if (jj_3R_84()) return true; return false; } private boolean jj_3_16() { if (jj_3R_62()) return true; if (jj_scan_token(DOT)) return true; return false; } private boolean jj_3R_226() { Token xsp; xsp = jj_scanpos; if (jj_3R_240()) { jj_scanpos = xsp; if (jj_3R_241()) return true; } return false; } private boolean jj_3R_279() { if (jj_scan_token(DO)) return true; if (jj_3R_237()) return true; if (jj_scan_token(WHILE)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_296() { if (jj_3R_302()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_316()) jj_scanpos = xsp; return false; } private boolean jj_3R_121() { Token xsp; xsp = jj_scanpos; if (jj_3_16()) jj_scanpos = xsp; if (jj_scan_token(SUPER)) return true; if (jj_3R_89()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3_17() { if (jj_scan_token(THIS)) return true; if (jj_3R_89()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_120() { if (jj_scan_token(THIS)) return true; if (jj_3R_89()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; } private boolean jj_3R_362() { if (jj_scan_token(COMMA)) return true; if (jj_3R_188()) return true; return false; } private boolean jj_3R_88() { Token xsp; xsp = jj_scanpos; if (jj_3R_120()) { jj_scanpos = xsp; if (jj_3R_121()) return true; } return false; } private boolean jj_3R_318() { if (jj_scan_token(NE)) return true; return false; } private boolean jj_3R_347() { if (jj_scan_token(EXTENDS)) return true; if (jj_3R_188()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_362()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_317() { if (jj_scan_token(EQ)) return true; return false; } private boolean jj_3R_278() { if (jj_scan_token(WHILE)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_94()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_3R_237()) return true; return false; } private boolean jj_3R_309() { Token xsp; xsp = jj_scanpos; if (jj_3R_317()) { jj_scanpos = xsp; if (jj_3R_318()) return true; } if (jj_3R_296()) return true; return false; } private boolean jj_3R_215() { if (jj_3R_227()) return true; return false; } private boolean jj_3R_287() { if (jj_3R_296()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_309()) { jj_scanpos = xsp; break; } } return false; } private boolean jj_3R_214() { if (jj_3R_226()) return true; return false; } private boolean jj_3R_213() { if (jj_scan_token(STRING_LITERAL)) return true; return false; } private boolean jj_3_15() { if (jj_3R_88()) return true; return false; } private boolean jj_3R_212() { if (jj_scan_token(CHARACTER_LITERAL)) return true; return false; } private boolean jj_3R_334() { if (jj_3R_207()) return true; return false; } private boolean jj_3R_211() { if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; return false; } private boolean jj_3R_393() { if (jj_scan_token(ELSE)) return true; if (jj_3R_237()) return true; return false; } private boolean jj_3R_210() { if (jj_scan_token(INTEGER_LITERAL)) return true; return false; } private boolean jj_3R_333() { if (jj_3R_88()) return true; return false; } private boolean jj_3R_327() { if (jj_3R_348()) return true; return false; } private boolean jj_3R_201() { Token xsp; xsp = jj_scanpos; if (jj_3R_210()) { jj_scanpos = xsp; if (jj_3R_211()) { jj_scanpos = xsp; if (jj_3R_212()) { jj_scanpos = xsp; if (jj_3R_213()) { jj_scanpos = xsp; if (jj_3R_214()) { jj_scanpos = xsp; if (jj_3R_215()) return true; } } } } } return false; } private boolean jj_3R_326() { if (jj_3R_347()) return true; return false; } private boolean jj_3R_179() { if (jj_3R_202()) return true; return false; } /** Generated Token Manager. */ public JTBParserTokenManager token_source; JavaCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; /** Whether we are looking ahead. */ private boolean jj_lookingAhead = false; private boolean jj_semLA; private int jj_gen; final private int[] jj_la1 = new int[176]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; static private int[] jj_la1_3; static private int[] jj_la1_4; static { jj_la1_init_0(); jj_la1_init_1(); jj_la1_init_2(); jj_la1_init_3(); jj_la1_init_4(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x0,0xb0000ffe,0x0,0xa00007e0,0x6,0x6,0x0,0xa00007e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffe,0x0,0x8000000,0x0,0x0,0x0,0x8000000,0x0,0x8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0xa8000000,0x0,0x0,0x0,0x0,0x0,0x0,0xa8000000,0x0,0xa0000000,0xa8000000,0x0,0x0,0x0,0xa0000ffe,0xa0000ffe,0x0,0x0,0x0,0x0,0x0,0x0,0xa8000000,0x0,0x0,0x0,0xf8000ffe,0xa0000ffe,0x0,0xa0000000,0xa0000000,0x0,0x0,0xa0000000,0x0,0xa0000000,0xa0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa0000ffe,0x0,0x0,0xa0000ffe,0x0,0x0,0x0,0x0,0x0,0x0,0xffe,0x0,0x0,0x0,0xa0000ffe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000ffe,0x0,0xf8000ffe,0xf0000ffe,0x0,0x0,0x0,0xa0000ffe,0x0,0xf8000ffe,0x0,0x0,0xa8000ffe,0xa0000ffe,0xa0000ffe,0xa8000ffe,0xa0000ffe,0x0,0x0,0x0,0xa0000ffe,0x0,0x0,0x0,0x0,0x0,0xa0000ffe,0x0,0xa8000000,0x0,0xa0000000,0xa8000000,}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {0x0,0xd409104,0x0,0xe1408104,0x0,0x0,0x1000,0xe1408104,0x0,0x0,0x0,0x0,0xe0000000,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100000,0xe2802408,0x0,0x0,0x0,0xe2002000,0x800408,0xe2802408,0x800008,0x0,0x800,0x80000,0x0,0x0,0x80000,0xe2002000,0x0,0xe3c0a50c,0x0,0x0,0x0,0x0,0x800,0x0,0xe3c0a50c,0x800408,0x1408104,0xe3c0a50c,0x0,0x0,0x0,0xd409104,0xd409104,0x0,0x0,0x0,0x0,0x0,0x0,0xe340a104,0x0,0x0,0x0,0xefc5b1ac,0xd409104,0x0,0x1408104,0x1408104,0x0,0x800,0x1408104,0x800,0x1408104,0x1408104,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xd409104,0x0,0x0,0xd409104,0xc001000,0x0,0x0,0x0,0x0,0xc001000,0x0,0x0,0x8001000,0x1000,0xd409104,0x0,0x0,0x0,0x0,0x4000000,0x0,0x0,0xd4591a4,0x0,0xefc5b1ac,0xdc591ac,0x0,0x0,0x0,0xd409104,0x41,0xefc5b1ac,0x41,0x200,0xef40b104,0xd409104,0xd409104,0xef40b104,0xd409104,0x0,0x0,0x0,0xd409104,0x2,0x4000,0x0,0x0,0x0,0xd409104,0x0,0xe3c0a50c,0x40,0x1c0850c,0xe3c0a50c,}; } private static void jj_la1_init_2() { jj_la1_2 = new int[] {0x0,0x2e1138b2,0x0,0x2002,0x4,0x4,0x4010800,0x2002,0x0,0x200,0x0,0x200,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x20000000,0x0,0x0,0x0,0x10000,0x0,0x4000000,0x0,0x0,0xa0001000,0x8000000,0x0,0x0,0x0,0x0,0x4000000,0x0,0x0,0x8c000000,0x10000,0x0,0x20000000,0x20000000,0x8c000000,0x0,0x0,0x4000000,0x0,0x0,0x0,0x444c,0x0,0x4,0x0,0x444c,0x0,0x444c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x444c,0x0,0x2000644e,0x0,0x8000000,0x20000000,0x0,0x0,0x0,0x2000644e,0x0,0x2002,0x644e,0x0,0x0,0x80000000,0x2e112892,0x2e112892,0x0,0x0,0x200,0x20000000,0x80000000,0x0,0x444e,0x0,0x0,0x200,0x2e11fdff,0xe112892,0x4,0x2,0x2,0x0,0x10,0x2,0x10,0x2,0x2002,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe112892,0x0,0x0,0xe112892,0xe110890,0x8000000,0x0,0x0,0x8000000,0xe110890,0x0,0x88000000,0x6110800,0x800,0xe112892,0x0,0x0,0x20000000,0x88000000,0x0,0x80000000,0x80000000,0x2e11b9f3,0x0,0x2e11fdff,0x2e11b9f3,0x0,0x0,0x0,0xe112892,0x0,0x2e11fdff,0x0,0x0,0xe116cde,0xe112892,0xe112892,0xe116cde,0xe112892,0x0,0x0,0x0,0xe112892,0x0,0x0,0x0,0x0,0x0,0x2e112892,0x0,0x444e,0x0,0x2,0x444e,}; } private static void jj_la1_init_3() { jj_la1_3 = new int[] {0x0,0x30002,0x0,0x20,0x0,0x0,0x0,0x20,0x4,0x0,0x4,0x0,0x0,0x0,0x4,0x20,0x20,0x0,0x800000,0x0,0x0,0x200,0x800000,0x0,0x0,0x8,0x20,0x140100,0x140100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x800000,0xa0,0x0,0x4,0x140100,0x140100,0xa0,0x80,0x4,0x0,0x80000,0x0,0x0,0x2,0x0,0x0,0x8,0x0,0x0,0x2,0x0,0x20,0x0,0x0,0x4,0x4,0x0,0x0,0x4,0x22,0x2,0x0,0x0,0x4,0x0,0x400000,0x22,0x0,0x20,0x22,0x4,0x10,0x0,0xf00c0,0xf00c0,0x4,0x20,0x0,0x2,0x0,0x4,0x0,0x0,0x20,0x0,0x30002,0x0,0x0,0x0,0x0,0x4,0x0,0x100,0x0,0x0,0x0,0x4,0xfc000010,0x100,0x4000,0x8000,0x800000,0x1000000,0x400000,0x2400,0x2400,0x0,0x1820,0x1820,0x0,0xc0000,0xc0000,0x2300000,0x2300000,0xc0000,0xf00c0,0xc0,0xc0,0x0,0xc0,0x0,0x30000,0x30000,0x0,0x0,0x0,0x8,0x0,0x0,0xf00c0,0x4,0x20,0x0,0x0,0x0,0x0,0x0,0x30002,0x200,0x30002,0x30002,0x4,0xfc030010,0xfc030010,0x30000,0x0,0x30002,0x0,0x0,0x30000,0xf00c0,0x30000,0x30002,0x30000,0x4,0x0,0x0,0xf00c0,0x0,0x0,0x0,0x0,0x4,0xf00c0,0x4,0x2,0x0,0x0,0x2,}; } private static void jj_la1_init_4() { jj_la1_4 = new int[] {0x1000,0x2000,0x1000,0x2000,0x2000,0x2000,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x2040,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x1000,0x1000,0x0,0x0,0x1000,0x1000,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000,0x0,0x3000,0x0,0x0,0x0,0x0,0x0,0x0,0x3000,0x0,0x2000,0x3000,0x0,0x0,0x0,0x2000,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x3000,0x80,0x0,0x0,0x3000,0x2000,0x0,0x0,0x2000,0x0,0x0,0x2000,0x0,0x0,0x2000,0x0,0x703,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x800,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x0,0x2000,0x2000,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x3000,0x2000,0x0,0x703,0x703,0x2000,0x0,0x3000,0x0,0x0,0x3000,0x2000,0x2000,0x3000,0x2000,0x0,0x2000,0x2000,0x2000,0x0,0x0,0x1000,0x2000,0x0,0x3000,0x0,0x3000,0x0,0x3000,0x3000,}; } final private JJCalls[] jj_2_rtns = new JJCalls[49]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with InputStream. */ public JTBParser(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public JTBParser(java.io.InputStream stream, String encoding) { try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new JTBParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public JTBParser(java.io.Reader stream) { jj_input_stream = new JavaCharStream(stream, 1, 1); token_source = new JTBParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor with generated Token Manager. */ public JTBParser(JTBParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(JTBParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 176; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; if (++jj_gc > 100) { jj_gc = 0; for (int i = 0; i < jj_2_rtns.length; i++) { JJCalls c = jj_2_rtns[i]; while (c != null) { if (c.gen < jj_gen) c.first = null; c = c.next; } } } return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_scanpos.next; } if (jj_rescan) { int i = 0; Token tok = token; while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } if (tok != null) jj_add_error_token(kind, i); } if (jj_scanpos.kind != kind) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; return false; } /** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } /** Get the specific Token. */ final public Token getToken(int index) { Token t = jj_lookingAhead ? jj_scanpos : token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; private int jj_endpos; private void jj_add_error_token(int kind, int pos) { if (pos >= 100) return; if (pos == jj_endpos + 1) { jj_lasttokens[jj_endpos++] = kind; } else if (jj_endpos != 0) { jj_expentry = new int[jj_endpos]; for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { continue jj_entries_loop; } } jj_expentries.add(jj_expentry); break jj_entries_loop; } } if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[144]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 176; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< jj_gen) { jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; switch (i) { case 0: jj_3_1(); break; case 1: jj_3_2(); break; case 2: jj_3_3(); break; case 3: jj_3_4(); break; case 4: jj_3_5(); break; case 5: jj_3_6(); break; case 6: jj_3_7(); break; case 7: jj_3_8(); break; case 8: jj_3_9(); break; case 9: jj_3_10(); break; case 10: jj_3_11(); break; case 11: jj_3_12(); break; case 12: jj_3_13(); break; case 13: jj_3_14(); break; case 14: jj_3_15(); break; case 15: jj_3_16(); break; case 16: jj_3_17(); break; case 17: jj_3_18(); break; case 18: jj_3_19(); break; case 19: jj_3_20(); break; case 20: jj_3_21(); break; case 21: jj_3_22(); break; case 22: jj_3_23(); break; case 23: jj_3_24(); break; case 24: jj_3_25(); break; case 25: jj_3_26(); break; case 26: jj_3_27(); break; case 27: jj_3_28(); break; case 28: jj_3_29(); break; case 29: jj_3_30(); break; case 30: jj_3_31(); break; case 31: jj_3_32(); break; case 32: jj_3_33(); break; case 33: jj_3_34(); break; case 34: jj_3_35(); break; case 35: jj_3_36(); break; case 36: jj_3_37(); break; case 37: jj_3_38(); break; case 38: jj_3_39(); break; case 39: jj_3_40(); break; case 40: jj_3_41(); break; case 41: jj_3_42(); break; case 42: jj_3_43(); break; case 43: jj_3_44(); break; case 44: jj_3_45(); break; case 45: jj_3_46(); break; case 46: jj_3_47(); break; case 47: jj_3_48(); break; case 48: jj_3_49(); break; } } p = p.next; } while (p != null); } catch(LookaheadSuccess ls) { } } jj_rescan = false; } private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } } class JTBToolkit { static NodeToken makeNodeToken(final Token tok) { final NodeToken node = new NodeToken(tok.image.intern(), tok.kind, tok.beginLine, tok.beginColumn, tok.endLine, tok.endColumn); if (tok.specialToken == null) return node; final java.util.ArrayList temp = new java.util.ArrayList(); Token t = tok; while (t.specialToken != null) { t = t.specialToken; temp.add(new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn)); } for (int i = temp.size() - 1; i >= 0; --i) node.addSpecial(temp.get(i)); node.trimSpecials(); return node; } } jtb-1.4.4/EDU/purdue/jtb/parser/JavaCCGlobals.java0000644000175000017500000004771311360636752021376 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; /** * This package contains data created as a result of parsing and semanticizing * a JavaCC input file. This data is what is used by the back-ends of JavaCC as * well as any other back-end of JavaCC related tools such as JJTree. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class JavaCCGlobals { /** * String that identifies the JavaCC generated files. */ protected static final String toolName = "JavaCC"; /** * The name of the grammar file being processed. */ static public String fileName; /** * The name of the original file (before processing by JJTree). * Currently this is the same as fileName. */ static public String origFileName; /** * Set to true if this file has been processed by JJTree. */ static public boolean jjtreeGenerated; /** * The list of tools that have participated in generating the * input grammar file. */ static public List toolNames; /** * This prints the banner line when the various tools are invoked. This * takes as argument the tool's full name and its version. */ static public void bannerLine(final String fullName, final String ver) { System.out.print("Java Compiler Compiler Version " + Version.version + " (" + fullName); if (!ver.equals("")) { System.out.print(" Version " + ver); } System.out.println(")"); } /** * The name of the parser class (what appears in PARSER_BEGIN and PARSER_END). */ static public String cu_name; /** * This is a list of tokens that appear after "PARSER_BEGIN(name)" all the * way until (but not including) the opening brace "{" of the class "name". */ static public List cu_to_insertion_point_1 = new ArrayList(); /** * This is the list of all tokens that appear after the tokens in * "cu_to_insertion_point_1" and until (but not including) the closing brace "}" * of the class "name". */ static public List cu_to_insertion_point_2 = new ArrayList(); /** * This is the list of all tokens that appear after the tokens in * "cu_to_insertion_point_2" and until "PARSER_END(name)". */ static public List cu_from_insertion_point_2 = new ArrayList(); /** * A list of all grammar productions - normal and JAVACODE - in the order * they appear in the input file. Each entry here will be a subclass of * "NormalProduction". */ static public List bnfproductions = new ArrayList(); /** * A symbol table of all grammar productions - normal and JAVACODE. The * symbol table is indexed by the name of the left hand side non-terminal. * Its contents are of type "NormalProduction". */ static public Map production_table = new HashMap(); /** * A mapping of lexical state strings to their integer internal representation. * Integers are stored as java.lang.Integer's. */ static public Hashtable lexstate_S2I = new Hashtable(); /** * A mapping of the internal integer representations of lexical states to * their strings. Integers are stored as java.lang.Integer's. */ static public Hashtable lexstate_I2S = new Hashtable(); /** * The declarations to be inserted into the TokenManager class. */ static public List token_mgr_decls; /** * The list of all TokenProductions from the input file. This list includes * implicit TokenProductions that are created for uses of regular expressions * within BNF productions. */ static public List rexprlist = new ArrayList(); /** * The total number of distinct tokens. This is therefore one more than the * largest assigned token ordinal. */ static public int tokenCount; /** * This is a symbol table that contains all named tokens (those that are * defined with a label). The index to the table is the image of the label * and the contents of the table are of type "RegularExpression_". */ static public Map named_tokens_table = new HashMap(); /** * Contains the same entries as "named_tokens_table", but this is an ordered * list which is ordered by the order of appearance in the input file. */ static public List ordered_named_tokens = new ArrayList(); /** * A mapping of ordinal values (represented as objects of type "Integer") to * the corresponding labels (of type "String"). An entry exists for an ordinal * value only if there is a labeled token corresponding to this entry. * If there are multiple labels representing the same ordinal value, then * only one label is stored. */ static public Map names_of_tokens = new HashMap(); /** * A mapping of ordinal values (represented as objects of type "Integer") to * the corresponding RegularExpression_'s. */ static public Map rexps_of_tokens = new HashMap(); /** * This is a three-level symbol table that contains all simple tokens (those * that are defined using a single string (with or without a label). The index * to the first level table is a lexical state which maps to a second level * hashtable. The index to the second level hashtable is the string of the * simple token converted to upper case, and this maps to a third level hashtable. * This third level hashtable contains the actual string of the simple token * and maps it to its RegularExpression_. */ static public Hashtable>> simple_tokens_table = new Hashtable>>(); /** * maskindex, jj2index, maskVals are variables that are shared between * ParseEngine and ParseGen. */ static protected int maskindex = 0; static protected int jj2index = 0; public static boolean lookaheadNeeded; static protected List maskVals = new ArrayList(); static Action actForEof; static String nextStateForEof; // Some general purpose utilities follow. /** * Returns the identifying string for the file name, given a toolname * used to generate it. */ public static String getIdString(final String tn, final String fn) { final List tns = new ArrayList(); tns.add(tn); return getIdString(tns, fn); } /** * Returns the identifying string for the file name, given a set of tool * names that are used to generate it. */ public static String getIdString(final List tns, final String fn) { int i; String toolNamePrefix = "Generated By:"; for (i = 0; i < tns.size() - 1; i++) toolNamePrefix += tns.get(i) + "&"; toolNamePrefix += tns.get(i) + ":"; if (toolNamePrefix.length() > 200) { System.out.println("Tool names too long."); throw new Error(); } return toolNamePrefix + " Do not edit this line. " + addUnicodeEscapes(fn); } /** * Returns true if tool name passed is one of the tool names returned * by getToolNames(fileName). */ public static boolean isGeneratedBy(final String tn, final String fn) { final List v = getToolNames(fn); for (int i = 0; i < v.size(); i++) if (tn.equals(v.get(i))) return true; return false; } private static List makeToolNameList(final String str) { final List retVal = new ArrayList(); int limit1 = str.indexOf('\n'); if (limit1 == -1) limit1 = 1000; int limit2 = str.indexOf('\r'); if (limit2 == -1) limit2 = 1000; final int limit = (limit1 < limit2) ? limit1 : limit2; String tmp; if (limit == 1000) { tmp = str; } else { tmp = str.substring(0, limit); } if (tmp.indexOf(':') == -1) return retVal; tmp = tmp.substring(tmp.indexOf(':') + 1); if (tmp.indexOf(':') == -1) return retVal; tmp = tmp.substring(0, tmp.indexOf(':')); int i = 0, j = 0; while (j < tmp.length() && (i = tmp.indexOf('&', j)) != -1) { retVal.add(tmp.substring(j, i)); j = i + 1; } if (j < tmp.length()) retVal.add(tmp.substring(j)); return retVal; } /** * Returns a List of names of the tools that have been used to generate * the given file. */ public static List getToolNames(final String fn) { final char[] buf = new char[256]; java.io.FileReader stream = null; int read, total = 0; try { stream = new java.io.FileReader(fn); for (;;) if ((read = stream.read(buf, total, buf.length - total)) != -1) { if ((total += read) == buf.length) break; } else break; return makeToolNameList(new String(buf, 0, total)); } catch (final java.io.FileNotFoundException e1) { } catch (final java.io.IOException e2) { if (total > 0) return makeToolNameList(new String(buf, 0, total)); } finally { if (stream != null) try { stream.close(); } catch (final Exception e3) { } } return new ArrayList(); } public static void createOutputDir(final File outputDir) { if (!outputDir.exists()) { JavaCCErrors.warning("Output directory \"" + outputDir + "\" does not exist. Creating the directory."); if (!outputDir.mkdirs()) { JavaCCErrors.semantic_error("Cannot create the output directory : " + outputDir); return; } } if (!outputDir.isDirectory()) { JavaCCErrors.semantic_error("\"" + outputDir + " is not a valid output directory."); return; } if (!outputDir.canWrite()) { JavaCCErrors.semantic_error("Cannot write to the output output directory : \"" + outputDir + "\""); return; } } static public String staticOpt() { if (Options.getStatic()) { return "static "; } else { return ""; } } static public String add_escapes(final String str) { String retval = ""; char ch; for (int i = 0; i < str.length(); i++) { ch = str.charAt(i); if (ch == '\b') { retval += "\\b"; } else if (ch == '\t') { retval += "\\t"; } else if (ch == '\n') { retval += "\\n"; } else if (ch == '\f') { retval += "\\f"; } else if (ch == '\r') { retval += "\\r"; } else if (ch == '\"') { retval += "\\\""; } else if (ch == '\'') { retval += "\\\'"; } else if (ch == '\\') { retval += "\\\\"; } else if (ch < 0x20 || ch > 0x7e) { final String s = "0000" + Integer.toString(ch, 16); retval += "\\u" + s.substring(s.length() - 4, s.length()); } else { retval += ch; } } return retval; } static public String addUnicodeEscapes(final String str) { // ModMMa : performance improvements (String concatenation) // String retval = ""; // char ch; // for (int i = 0; i < str.length(); i++) { // ch = str.charAt(i); // if (ch < 0x20 || ch > 0x7e || ch == '\\') { // String s = "0000" + Integer.toString(ch, 16); // retval += "\\u" + s.substring(s.length() - 4, s.length()); // } else { // retval += ch; // } // } // return retval; final int strlen = str.length(); final StringBuilder retval = new StringBuilder(2 * strlen); char ch; for (int i = 0; i < strlen; i++) { ch = str.charAt(i); if (ch < 0x20 || ch > 0x7e || ch == '\\') { final String s = "0000" + Integer.toString(ch, 16); retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } return retval.toString(); } static protected int cline, ccol; static protected void printTokenSetup(final Token t) { Token tt = t; while (tt.specialToken != null) tt = tt.specialToken; cline = tt.beginLine; ccol = tt.beginColumn; } static protected void printTokenOnly(final Token t, final java.io.PrintWriter ostr) { for (; cline < t.beginLine; cline++) { ostr.println(""); ccol = 1; } for (; ccol < t.beginColumn; ccol++) { ostr.print(" "); } if (t.kind == JavaCCParserConstants.STRING_LITERAL || t.kind == JavaCCParserConstants.CHARACTER_LITERAL) ostr.print(addUnicodeEscapes(t.image)); else ostr.print(t.image); cline = t.endLine; ccol = t.endColumn + 1; final char last = t.image.charAt(t.image.length() - 1); if (last == '\n' || last == '\r') { cline++; ccol = 1; } } static protected void printToken(final Token t, final java.io.PrintWriter ostr) { Token tt = t.specialToken; if (tt != null) { while (tt.specialToken != null) tt = tt.specialToken; while (tt != null) { printTokenOnly(tt, ostr); tt = tt.next; } } printTokenOnly(t, ostr); } static protected void printTokenList(final List list, final java.io.PrintWriter ostr) { Token t = null; for (final Iterator it = list.iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } if (t != null) printTrailingComments(t, ostr); } static protected void printLeadingComments(final Token t, final java.io.PrintWriter ostr) { if (t.specialToken == null) return; Token tt = t.specialToken; while (tt.specialToken != null) tt = tt.specialToken; while (tt != null) { printTokenOnly(tt, ostr); tt = tt.next; } if (ccol != 1 && cline != t.beginLine) { ostr.println(""); cline++; ccol = 1; } } static protected void printTrailingComments(final Token t, final java.io.PrintWriter ostr) { if (t.next == null) return; // printLeadingComments(t.next); printLeadingComments(t.next, ostr); } static protected String printTokenOnly(final Token t) { String retval = ""; for (; cline < t.beginLine; cline++) { retval += "\n"; ccol = 1; } for (; ccol < t.beginColumn; ccol++) { retval += " "; } if (t.kind == JavaCCParserConstants.STRING_LITERAL || t.kind == JavaCCParserConstants.CHARACTER_LITERAL) retval += addUnicodeEscapes(t.image); else retval += t.image; cline = t.endLine; ccol = t.endColumn + 1; final char last = t.image.charAt(t.image.length() - 1); if (last == '\n' || last == '\r') { cline++; ccol = 1; } return retval; } static protected String printToken(final Token t) { String retval = ""; Token tt = t.specialToken; if (tt != null) { while (tt.specialToken != null) tt = tt.specialToken; while (tt != null) { retval += printTokenOnly(tt); tt = tt.next; } } retval += printTokenOnly(t); return retval; } static protected String printLeadingComments(final Token t) { String retval = ""; if (t.specialToken == null) return retval; Token tt = t.specialToken; while (tt.specialToken != null) tt = tt.specialToken; while (tt != null) { retval += printTokenOnly(tt); tt = tt.next; } if (ccol != 1 && cline != t.beginLine) { retval += "\n"; cline++; ccol = 1; } return retval; } static protected String printTrailingComments(final Token t) { if (t.next == null) return ""; return printLeadingComments(t.next); } public static void reInit() { fileName = null; origFileName = null; jjtreeGenerated = false; toolNames = null; cu_name = null; cu_to_insertion_point_1 = new ArrayList(); cu_to_insertion_point_2 = new ArrayList(); cu_from_insertion_point_2 = new ArrayList(); bnfproductions = new ArrayList(); production_table = new HashMap(); lexstate_S2I = new Hashtable(); lexstate_I2S = new Hashtable(); token_mgr_decls = null; rexprlist = new ArrayList(); tokenCount = 0; named_tokens_table = new HashMap(); ordered_named_tokens = new ArrayList(); names_of_tokens = new HashMap(); rexps_of_tokens = new HashMap(); simple_tokens_table = new Hashtable>>(); maskindex = 0; jj2index = 0; maskVals = new ArrayList(); cline = 0; ccol = 0; actForEof = null; nextStateForEof = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/ParseException.java0000644000175000017500000001433611416555666021735 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ /* JavaCCOptions:KEEP_LINE_COL=null */ package EDU.purdue.jtb.parser; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends Exception { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); } /** Constructor with message. */ public ParseException(String message) { super(message); } /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * It uses "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser) the correct error message * gets displayed. */ private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += " " + tokenImage[tok.kind]; retval += " \""; retval += add_escapes(tok.image); retval += " \""; tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected.toString(); return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ static String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } } /* JavaCC - OriginalChecksum=d2482fa1c2c3763e5b3de6c1a972038b (do not edit this line) */ jtb-1.4.4/EDU/purdue/jtb/parser/Lookahead.java0000644000175000017500000001127611360636752020665 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Describes lookahead rule for a particular expansion or expansion * sequence (See Sequence.java). In case this describes the lookahead * rule for a single expansion unit, then a sequence is created with * this node as the first element, and the expansion unit as the second * and last element. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Lookahead extends Expansion_ { /** * Contains the list of tokens that make up the semantic lookahead * if any. If this node represents a different kind of lookahead (other * than semantic lookahead), then this list contains nothing. If * this list contains something, then it is the boolean expression * that forms the semantic lookahead. In this case, the following * fields "amount" and "la_expansion" are ignored. */ private final List action_tokens = new ArrayList(); /** * The lookahead amount. Its default value essentially gives us * infinite lookahead. */ private int amount = Integer.MAX_VALUE; /** * The expansion used to determine whether or not to choose the * corresponding parse option. This expansion is parsed upto * "amount" tokens of lookahead or until a complete match for it * is found. Usually, this is the same as the expansion to be * parsed. */ private Expansion_ la_expansion; /** * Is set to true if this is an explicit lookahead specification. */ private boolean isExplicit; // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker public Lookahead() { expType = EXP_TYPE.LOOKAHEAD; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped).append( isExplicit ? " explicit" : " implicit"); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); sb.append(eol).append(la_expansion.dump(indent + 1, alreadyDumped)); return sb; } /** * @return the action_tokens */ public final List getActionTokens() { return action_tokens; } /** * @param amount the amount to set */ public final void setAmount(final int am) { amount = am; } /** * @return the amount */ public final int getAmount() { return amount; } /** * @param la_expansion the la_expansion to set */ public final void setLaExpansion(final Expansion_ laexp) { la_expansion = laexp; } /** * @return the la_expansion */ public final Expansion_ getLaExpansion() { return la_expansion; } /** * @param isExplicit the isExplicit to set */ public final void setExplicit(final boolean ise) { isExplicit = ise; } /** * @return the isExplicit */ public final boolean isExplicit() { return isExplicit; } } jtb-1.4.4/EDU/purdue/jtb/parser/ExpansionTreeWalker.java0000644000175000017500000002616111360636752022727 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Iterator; import EDU.purdue.jtb.parser.Expansion_.EXP_TYPE; /** * A set of routines that walk down the Expansion_ tree in various ways. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public final class ExpansionTreeWalker { private ExpansionTreeWalker() { } /** * Visits the nodes of the tree rooted at "node" in pre-order. * i.e., it executes opObj.action first and then visits the * children. */ static void preOrderWalk(final Expansion_ node, final TreeWalkerOp opObj) { opObj.action(node); if (opObj.goDeeper(node)) { if (node.expType == EXP_TYPE.CHOICE) { for (final Iterator it = ((Choice) node).getChoices().iterator(); it.hasNext();) { preOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.SEQUENCE) { for (final Iterator it = ((Sequence) node).units.iterator(); it.hasNext();) { preOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.ONE_OR_MORE) { preOrderWalk(((OneOrMore) node).expansion, opObj); } else if (node.expType == EXP_TYPE.ZERO_OR_MORE) { preOrderWalk(((ZeroOrMore) node).expansion, opObj); } else if (node.expType == EXP_TYPE.ZERO_OR_ONE) { preOrderWalk(((ZeroOrOne) node).expansion, opObj); } else if (node.expType == EXP_TYPE.LOOKAHEAD) { final Expansion_ nested_e = ((Lookahead) node).getLaExpansion(); if (!(nested_e.expType == EXP_TYPE.SEQUENCE && (((Sequence) nested_e).units.get(0)) == node)) { preOrderWalk(nested_e, opObj); } } else if (node.expType == EXP_TYPE.TRY_BLOCK) { preOrderWalk(((TryBlock) node).exp, opObj); } else if (node.expType == EXP_TYPE.R_CHOICE) { for (final Iterator it = ((RChoice) node).getChoices().iterator(); it.hasNext();) { preOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.R_SEQUENCE) { for (final Iterator it = ((RSequence) node).units.iterator(); it.hasNext();) { preOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.R_ONE_OR_MORE) { preOrderWalk(((ROneOrMore) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_ZERO_OR_MORE) { preOrderWalk(((RZeroOrMore) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_ZERO_OR_ONE) { preOrderWalk(((RZeroOrOne) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_REPETITION_RANGE) { preOrderWalk(((RRepetitionRange) node).regexpr, opObj); } } // ModMMa : modified to get rid of 'instanceof' for performance reasons // opObj.action(node); // if (opObj.goDeeper(node)) { // if (node instanceof Choice) { // for (final Iterator it = ((Choice) node).getChoices().iterator(); it.hasNext();) { // preOrderWalk(it.next(), opObj); // } // } // else if (node instanceof Sequence) { // for (final Iterator it = ((Sequence) node).units.iterator(); it.hasNext();) { // preOrderWalk(it.next(), opObj); // } // } // else if (node instanceof OneOrMore) { // preOrderWalk(((OneOrMore) node).expansion, opObj); // } // else if (node instanceof ZeroOrMore) { // preOrderWalk(((ZeroOrMore) node).expansion, opObj); // } // else if (node instanceof ZeroOrOne) { // preOrderWalk(((ZeroOrOne) node).expansion, opObj); // } // else if (node instanceof Lookahead) { // final Expansion_ nested_e = ((Lookahead) node).getLaExpansion(); // if (!(nested_e instanceof Sequence && (((Sequence) nested_e).units.get(0)) == node)) { // preOrderWalk(nested_e, opObj); // } // } // else if (node instanceof TryBlock) { // preOrderWalk(((TryBlock) node).exp, opObj); // } // else if (node instanceof RChoice) { // for (final Iterator it = ((RChoice) node).getChoices().iterator(); it.hasNext();) { // preOrderWalk(it.next(), opObj); // } // } // else if (node instanceof RSequence) { // for (final Iterator it = ((RSequence) node).units.iterator(); it.hasNext();) { // preOrderWalk(it.next(), opObj); // } // } // else if (node instanceof ROneOrMore) { // preOrderWalk(((ROneOrMore) node).regexpr, opObj); // } // else if (node instanceof RZeroOrMore) { // preOrderWalk(((RZeroOrMore) node).regexpr, opObj); // } // else if (node instanceof RZeroOrOne) { // preOrderWalk(((RZeroOrOne) node).regexpr, opObj); // } // else if (node instanceof RRepetitionRange) { // preOrderWalk(((RRepetitionRange) node).regexpr, opObj); // } // } } /** * Visits the nodes of the tree rooted at "node" in post-order. * i.e., it visits the children first and then executes * opObj.action. */ static void postOrderWalk(final Expansion_ node, final TreeWalkerOp opObj) { if (opObj.goDeeper(node)) { if (node.expType == EXP_TYPE.CHOICE) { for (final Iterator it = ((Choice) node).getChoices().iterator(); it.hasNext();) { postOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.SEQUENCE) { for (final Iterator it = ((Sequence) node).units.iterator(); it.hasNext();) { postOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.ONE_OR_MORE) { postOrderWalk(((OneOrMore) node).expansion, opObj); } else if (node.expType == EXP_TYPE.ZERO_OR_MORE) { postOrderWalk(((ZeroOrMore) node).expansion, opObj); } else if (node.expType == EXP_TYPE.ZERO_OR_ONE) { postOrderWalk(((ZeroOrOne) node).expansion, opObj); } else if (node.expType == EXP_TYPE.LOOKAHEAD) { final Expansion_ nested_e = ((Lookahead) node).getLaExpansion(); if (!(nested_e.expType == EXP_TYPE.SEQUENCE && (((Sequence) nested_e).units.get(0)) == node)) { postOrderWalk(nested_e, opObj); } } else if (node.expType == EXP_TYPE.TRY_BLOCK) { postOrderWalk(((TryBlock) node).exp, opObj); } else if (node.expType == EXP_TYPE.R_CHOICE) { for (final Iterator it = ((RChoice) node).getChoices().iterator(); it.hasNext();) { postOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.R_SEQUENCE) { for (final Iterator it = ((RSequence) node).units.iterator(); it.hasNext();) { postOrderWalk(it.next(), opObj); } } else if (node.expType == EXP_TYPE.R_ONE_OR_MORE) { postOrderWalk(((ROneOrMore) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_ZERO_OR_MORE) { postOrderWalk(((RZeroOrMore) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_ZERO_OR_ONE) { postOrderWalk(((RZeroOrOne) node).regexpr, opObj); } else if (node.expType == EXP_TYPE.R_REPETITION_RANGE) { postOrderWalk(((RRepetitionRange) node).regexpr, opObj); } } opObj.action(node); // ModMMa : modified to get rid of 'instanceof' for performance reasons // if (opObj.goDeeper(node)) { // if (node instanceof Choice) { // for (final Iterator it = ((Choice) node).getChoices().iterator(); it.hasNext();) { // postOrderWalk(it.next(), opObj); // } // } // else if (node instanceof Sequence) { // for (final Iterator it = ((Sequence) node).units.iterator(); it.hasNext();) { // postOrderWalk(it.next(), opObj); // } // } // else if (node instanceof OneOrMore) { // postOrderWalk(((OneOrMore) node).expansion, opObj); // } // else if (node instanceof ZeroOrMore) { // postOrderWalk(((ZeroOrMore) node).expansion, opObj); // } // else if (node instanceof ZeroOrOne) { // postOrderWalk(((ZeroOrOne) node).expansion, opObj); // } // else if (node instanceof Lookahead) { // final Expansion_ nested_e = ((Lookahead) node).getLaExpansion(); // if (!(nested_e instanceof Sequence && (((Sequence) nested_e).units.get(0)) == node)) { // postOrderWalk(nested_e, opObj); // } // } // else if (node instanceof TryBlock) { // postOrderWalk(((TryBlock) node).exp, opObj); // } // else if (node instanceof RChoice) { // for (final Iterator it = ((RChoice) node).getChoices().iterator(); it.hasNext();) { // postOrderWalk(it.next(), opObj); // } // } // else if (node instanceof RSequence) { // for (final Iterator it = ((RSequence) node).units.iterator(); it.hasNext();) { // postOrderWalk(it.next(), opObj); // } // } // else if (node instanceof ROneOrMore) { // postOrderWalk(((ROneOrMore) node).regexpr, opObj); // } // else if (node instanceof RZeroOrMore) { // postOrderWalk(((RZeroOrMore) node).regexpr, opObj); // } // else if (node instanceof RZeroOrOne) { // postOrderWalk(((RZeroOrOne) node).regexpr, opObj); // } // else if (node instanceof RRepetitionRange) { // postOrderWalk(((RRepetitionRange) node).regexpr, opObj); // } // } // opObj.action(node); } } jtb-1.4.4/EDU/purdue/jtb/parser/RSequence.java0000644000175000017500000000625311360636752020667 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes regular expressions which are sequences of * other regular expressions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RSequence extends RegularExpression_ { /** * The list of units in this regular expression sequence. Each * list component will narrow to RegularExpression_. */ public List units = new ArrayList(); @Override public Nfa GenerateNfa(final boolean ignoreCase) { if (units.size() == 1) return (units.get(0)).GenerateNfa(ignoreCase); final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; Nfa temp1; Nfa temp2 = null; RegularExpression_ curRE; curRE = units.get(0); temp1 = curRE.GenerateNfa(ignoreCase); startState.AddMove(temp1.start); for (int i = 1; i < units.size(); i++) { curRE = units.get(i); temp2 = curRE.GenerateNfa(ignoreCase); temp1.end.AddMove(temp2.start); temp1 = temp2; } temp2.end.AddMove(finalState); return retVal; } // ModMMa : added public public RSequence() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.R_SEQUENCE; } // ModMMa : added public public RSequence(final List seq) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); ordinal = Integer.MAX_VALUE; units = seq; } } jtb-1.4.4/EDU/purdue/jtb/parser/Nfa.java0000644000175000017500000000404111360636752017472 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * A Non-deterministic Finite Automaton. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Nfa { NfaState start; NfaState end; public Nfa() { start = new NfaState(); end = new NfaState(); } public Nfa(final NfaState startGiven, final NfaState finalGiven) { start = startGiven; end = finalGiven; } } jtb-1.4.4/EDU/purdue/jtb/parser/JTBParserConstants.java0000644000175000017500000002346611416555666022501 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. JTBParserConstants.java */ package EDU.purdue.jtb.parser; /** * Token literal values and constants. * Generated by org.javacc.parser.OtherFilesGen#start() */ public interface JTBParserConstants { /** End of File. */ int EOF = 0; /** RegularExpression Id. */ int _LOOKAHEAD = 1; /** RegularExpression Id. */ int _IGNORE_CASE = 2; /** RegularExpression Id. */ int _PARSER_BEGIN = 3; /** RegularExpression Id. */ int _PARSER_END = 4; /** RegularExpression Id. */ int _JAVACODE = 5; /** RegularExpression Id. */ int _TOKEN = 6; /** RegularExpression Id. */ int _SPECIAL_TOKEN = 7; /** RegularExpression Id. */ int _MORE = 8; /** RegularExpression Id. */ int _SKIP = 9; /** RegularExpression Id. */ int _TOKEN_MGR_DECLS = 10; /** RegularExpression Id. */ int _EOF = 11; /** RegularExpression Id. */ int SINGLE_LINE_COMMENT = 23; /** RegularExpression Id. */ int FORMAL_COMMENT = 24; /** RegularExpression Id. */ int MULTI_LINE_COMMENT = 25; /** RegularExpression Id. */ int ABSTRACT = 27; /** RegularExpression Id. */ int ASSERT = 28; /** RegularExpression Id. */ int BOOLEAN = 29; /** RegularExpression Id. */ int BREAK = 30; /** RegularExpression Id. */ int BYTE = 31; /** RegularExpression Id. */ int CASE = 32; /** RegularExpression Id. */ int CATCH = 33; /** RegularExpression Id. */ int CHAR = 34; /** RegularExpression Id. */ int CLASS = 35; /** RegularExpression Id. */ int CONST = 36; /** RegularExpression Id. */ int CONTINUE = 37; /** RegularExpression Id. */ int _DEFAULT = 38; /** RegularExpression Id. */ int DO = 39; /** RegularExpression Id. */ int DOUBLE = 40; /** RegularExpression Id. */ int ELSE = 41; /** RegularExpression Id. */ int ENUM = 42; /** RegularExpression Id. */ int EXTENDS = 43; /** RegularExpression Id. */ int FALSE = 44; /** RegularExpression Id. */ int FINAL = 45; /** RegularExpression Id. */ int FINALLY = 46; /** RegularExpression Id. */ int FLOAT = 47; /** RegularExpression Id. */ int FOR = 48; /** RegularExpression Id. */ int GOTO = 49; /** RegularExpression Id. */ int IF = 50; /** RegularExpression Id. */ int IMPLEMENTS = 51; /** RegularExpression Id. */ int IMPORT = 52; /** RegularExpression Id. */ int INSTANCEOF = 53; /** RegularExpression Id. */ int INT = 54; /** RegularExpression Id. */ int INTERFACE = 55; /** RegularExpression Id. */ int LONG = 56; /** RegularExpression Id. */ int NATIVE = 57; /** RegularExpression Id. */ int NEW = 58; /** RegularExpression Id. */ int NULL = 59; /** RegularExpression Id. */ int PACKAGE = 60; /** RegularExpression Id. */ int PRIVATE = 61; /** RegularExpression Id. */ int PROTECTED = 62; /** RegularExpression Id. */ int PUBLIC = 63; /** RegularExpression Id. */ int RETURN = 64; /** RegularExpression Id. */ int SHORT = 65; /** RegularExpression Id. */ int STATIC = 66; /** RegularExpression Id. */ int STRICTFP = 67; /** RegularExpression Id. */ int SUPER = 68; /** RegularExpression Id. */ int SWITCH = 69; /** RegularExpression Id. */ int SYNCHRONIZED = 70; /** RegularExpression Id. */ int THIS = 71; /** RegularExpression Id. */ int THROW = 72; /** RegularExpression Id. */ int THROWS = 73; /** RegularExpression Id. */ int TRANSIENT = 74; /** RegularExpression Id. */ int TRUE = 75; /** RegularExpression Id. */ int TRY = 76; /** RegularExpression Id. */ int VOID = 77; /** RegularExpression Id. */ int VOLATILE = 78; /** RegularExpression Id. */ int WHILE = 79; /** RegularExpression Id. */ int INTEGER_LITERAL = 80; /** RegularExpression Id. */ int DECIMAL_LITERAL = 81; /** RegularExpression Id. */ int HEX_LITERAL = 82; /** RegularExpression Id. */ int OCTAL_LITERAL = 83; /** RegularExpression Id. */ int FLOATING_POINT_LITERAL = 84; /** RegularExpression Id. */ int DECIMAL_FLOATING_POINT_LITERAL = 85; /** RegularExpression Id. */ int DECIMAL_EXPONENT = 86; /** RegularExpression Id. */ int HEXADECIMAL_FLOATING_POINT_LITERAL = 87; /** RegularExpression Id. */ int HEXADECIMAL_EXPONENT = 88; /** RegularExpression Id. */ int CHARACTER_LITERAL = 89; /** RegularExpression Id. */ int STRING_LITERAL = 90; /** RegularExpression Id. */ int LPAREN = 91; /** RegularExpression Id. */ int RPAREN = 92; /** RegularExpression Id. */ int LBRACE = 93; /** RegularExpression Id. */ int RBRACE = 94; /** RegularExpression Id. */ int LBRACKET = 95; /** RegularExpression Id. */ int RBRACKET = 96; /** RegularExpression Id. */ int SEMICOLON = 97; /** RegularExpression Id. */ int COMMA = 98; /** RegularExpression Id. */ int DOT = 99; /** RegularExpression Id. */ int ASSIGN = 100; /** RegularExpression Id. */ int LT = 101; /** RegularExpression Id. */ int BANG = 102; /** RegularExpression Id. */ int TILDE = 103; /** RegularExpression Id. */ int HOOK = 104; /** RegularExpression Id. */ int COLON = 105; /** RegularExpression Id. */ int EQ = 106; /** RegularExpression Id. */ int LE = 107; /** RegularExpression Id. */ int GE = 108; /** RegularExpression Id. */ int NE = 109; /** RegularExpression Id. */ int SC_OR = 110; /** RegularExpression Id. */ int SC_AND = 111; /** RegularExpression Id. */ int INCR = 112; /** RegularExpression Id. */ int DECR = 113; /** RegularExpression Id. */ int PLUS = 114; /** RegularExpression Id. */ int MINUS = 115; /** RegularExpression Id. */ int STAR = 116; /** RegularExpression Id. */ int SLASH = 117; /** RegularExpression Id. */ int BIT_AND = 118; /** RegularExpression Id. */ int BIT_OR = 119; /** RegularExpression Id. */ int XOR = 120; /** RegularExpression Id. */ int REM = 121; /** RegularExpression Id. */ int PLUSASSIGN = 122; /** RegularExpression Id. */ int MINUSASSIGN = 123; /** RegularExpression Id. */ int STARASSIGN = 124; /** RegularExpression Id. */ int SLASHASSIGN = 125; /** RegularExpression Id. */ int ANDASSIGN = 126; /** RegularExpression Id. */ int ORASSIGN = 127; /** RegularExpression Id. */ int XORASSIGN = 128; /** RegularExpression Id. */ int REMASSIGN = 129; /** RegularExpression Id. */ int RUNSIGNEDSHIFT = 130; /** RegularExpression Id. */ int RSIGNEDSHIFT = 131; /** RegularExpression Id. */ int GT = 132; /** RegularExpression Id. */ int LANGLE = 101; /** RegularExpression Id. */ int RANGLE = 132; /** RegularExpression Id. */ int IDENTIFIER = 141; /** RegularExpression Id. */ int LETTER = 142; /** RegularExpression Id. */ int PART_LETTER = 143; /** Lexical state. */ int DEFAULT = 0; /** Lexical state. */ int AFTER_EGEN = 1; /** Lexical state. */ int IN_SINGLE_LINE_COMMENT = 2; /** Lexical state. */ int IN_FORMAL_COMMENT = 3; /** Lexical state. */ int IN_MULTI_LINE_COMMENT = 4; /** Literal token values. */ String[] tokenImage = { "", "\"LOOKAHEAD\"", "\"IGNORE_CASE\"", "\"PARSER_BEGIN\"", "\"PARSER_END\"", "\"JAVACODE\"", "\"TOKEN\"", "\"SPECIAL_TOKEN\"", "\"MORE\"", "\"SKIP\"", "\"TOKEN_MGR_DECLS\"", "\"EOF\"", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "\"\\f\"", "\"/*@egen*/\"", "", "\"//\"", "", "\"/*\"", "\"/*@bgen(jjtree\"", "", "\"*/\"", "\"*/\"", "", "\"abstract\"", "\"assert\"", "\"boolean\"", "\"break\"", "\"byte\"", "\"case\"", "\"catch\"", "\"char\"", "\"class\"", "\"const\"", "\"continue\"", "\"default\"", "\"do\"", "\"double\"", "\"else\"", "\"enum\"", "\"extends\"", "\"false\"", "\"final\"", "\"finally\"", "\"float\"", "\"for\"", "\"goto\"", "\"if\"", "\"implements\"", "\"import\"", "\"instanceof\"", "\"int\"", "\"interface\"", "\"long\"", "\"native\"", "\"new\"", "\"null\"", "\"package\"", "\"private\"", "\"protected\"", "\"public\"", "\"return\"", "\"short\"", "\"static\"", "\"strictfp\"", "\"super\"", "\"switch\"", "\"synchronized\"", "\"this\"", "\"throw\"", "\"throws\"", "\"transient\"", "\"true\"", "\"try\"", "\"void\"", "\"volatile\"", "\"while\"", "", "", "", "", "", "", "", "", "", "", "", "\"(\"", "\")\"", "\"{\"", "\"}\"", "\"[\"", "\"]\"", "\";\"", "\",\"", "\".\"", "\"=\"", "\"<\"", "\"!\"", "\"~\"", "\"?\"", "\":\"", "\"==\"", "\"<=\"", "\">=\"", "\"!=\"", "\"||\"", "\"&&\"", "\"++\"", "\"--\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"&\"", "\"|\"", "\"^\"", "\"%\"", "\"+=\"", "\"-=\"", "\"*=\"", "\"/=\"", "\"&=\"", "\"|=\"", "\"^=\"", "\"%=\"", "\">>>\"", "\">>\"", "\">\"", "\"options\"", "\"#\"", "\"...\"", "\"<<=\"", "\">>=\"", "\">>>=\"", "\"<<\"", "\"@\"", "", "", "", }; } jtb-1.4.4/EDU/purdue/jtb/parser/JavaCCErrors.java0000644000175000017500000001104011360636752021247 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Output error messages and keep track of totals. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public final class JavaCCErrors { private static int parse_error_count = 0, semantic_error_count = 0, warning_count = 0; private JavaCCErrors() {} private static void printLocationInfo(final Object node) { if (node instanceof NormalProduction) { final NormalProduction n = (NormalProduction)node; System.err.print("Line " + n.getLine() + ", Column " + n.getColumn() + ": "); } else if (node instanceof TokenProduction) { final TokenProduction n = (TokenProduction)node; System.err.print("Line " + n.getLine() + ", Column " + n.getColumn() + ": "); } else if (node instanceof Expansion_) { final Expansion_ n = (Expansion_)node; System.err.print("Line " + n.getLine() + ", Column " + n.getColumn() + ": "); } else if (node instanceof CharacterRange) { final CharacterRange n = (CharacterRange)node; System.err.print("Line " + n.getLine() + ", Column " + n.getColumn() + ": "); } else if (node instanceof SingleCharacter) { final SingleCharacter n = (SingleCharacter)node; System.err.print("Line " + n.getLine() + ", Column " + n.getColumn() + ": "); } else if (node instanceof Token) { final Token t = (Token)node; System.err.print("Line " + t.beginLine + ", Column " + t.beginColumn + ": "); } } public static void parse_error(final Object node, final String mess) { System.err.print("Error: "); printLocationInfo(node); System.err.println(mess); parse_error_count++; } public static void parse_error(final String mess) { System.err.print("Error: "); System.err.println(mess); parse_error_count++; } public static int get_parse_error_count() { return parse_error_count; } public static void semantic_error(final Object node, final String mess) { System.err.print("Error: "); printLocationInfo(node); System.err.println(mess); semantic_error_count++; } public static void semantic_error(final String mess) { System.err.print("Error: "); System.err.println(mess); semantic_error_count++; } public static final int get_semantic_error_count() { return semantic_error_count; } public static void warning(final Object node, final String mess) { System.err.print("Warning: "); printLocationInfo(node); System.err.println(mess); warning_count++; } public static void warning(final String mess) { System.err.print("Warning: "); System.err.println(mess); warning_count++; } public static final int get_warning_count() { return warning_count; } public static final int get_error_count() { return parse_error_count + semantic_error_count; } public static void reInit() { parse_error_count = 0; semantic_error_count = 0; warning_count = 0; } } jtb-1.4.4/EDU/purdue/jtb/parser/OutputFile.java0000644000175000017500000002643111360636752021075 0ustar cavedoncavedon/* Copyright (c) 2007, Paul Cager. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * This class handles the creation and maintenance of the boiler-plate classes, * such as Token.java, JavaCharStream.java etc. * * It is responsible for: * *
    *
  • Writing the JavaCC header lines to the file.
  • *
  • Writing the checksum line.
  • *
  • Using the checksum to determine if an existing file has been changed by * the user (and so should be left alone).
  • *
  • Checking any existing file's version (if the file can not be * overwritten).
  • *
  • Checking any existing file's creation options (if the file can not be * overwritten).
  • *
  • *
* * @author Paul Cager * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class OutputFile { private static final String MD5_LINE_PART_1 = "/* JavaCC - OriginalChecksum="; private static final String MD5_LINE_PART_1q = "/\\* JavaCC - OriginalChecksum="; private static final String MD5_LINE_PART_2 = " (do not edit this line) */"; private static final String MD5_LINE_PART_2q = " \\(do not edit this line\\) \\*/"; TrapClosePrintWriter pw; DigestOutputStream dos; String toolName = JavaCCGlobals.toolName; final File file; final String compatibleVersion; final String[] options; /** * Create a new OutputFile. * * @param file * the file to write to. * @param compatibleVersion * the minimum compatible JavaCC version. * @param options * if the file already exists, and cannot be overwritten, this is * a list of options (such s STATIC=false) to check for changes. * @throws IOException */ public OutputFile(final File fl, final String compVers, final String[] opt) throws IOException { file = fl; compatibleVersion = compVers; options = opt; if (fl.exists()) { // Generate the checksum of the file, and compare with any value // stored // in the file. final BufferedReader br = new BufferedReader(new FileReader(fl)); MessageDigest digest; try { digest = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw (IOException) (new IOException("No MD5 implementation").initCause(e)); } final DigestOutputStream digestStream = new DigestOutputStream(new NullOutputStream(), digest); final PrintWriter lpw = new PrintWriter(digestStream); String line; String existingMD5 = null; while ((line = br.readLine()) != null) { if (line.startsWith(MD5_LINE_PART_1)) { existingMD5 = line.replaceAll(MD5_LINE_PART_1q, "").replaceAll(MD5_LINE_PART_2q, ""); } else { lpw.println(line); } } lpw.close(); final String calculatedDigest = toHexString(digestStream.getMessageDigest().digest()); if (existingMD5 == null || !existingMD5.equals(calculatedDigest)) { // No checksum in file, or checksum differs. needToWrite = false; if (compVers != null) { checkVersion(fl, compVers); } if (opt != null) { checkOptions(fl, opt); } } else { // The file has not been altered since JavaCC created it. // Rebuild it. System.out.println("File \"" + fl.getName() + "\" is being rebuilt."); needToWrite = true; } } else { // File does not exist System.out.println("File \"" + fl.getName() + "\" does not exist. Will create one."); needToWrite = true; } } public OutputFile(final File fl) throws IOException { this(fl, null, null); } public boolean needToWrite = true; /** * Output a warning if the file was created with an incompatible version of JavaCC. * * @param fileName * @param versionId */ private void checkVersion(final File fl, final String versionId) { final String firstLine = "/* " + JavaCCGlobals.getIdString(toolName, fl.getName()) + " Version "; try { final BufferedReader reader = new BufferedReader(new FileReader(fl)); String line; while ((line = reader.readLine()) != null) { if (line.startsWith(firstLine)) { final String version = firstLine.replaceFirst(".* Version ", "").replaceAll(" \\*/", ""); if (version != versionId) { JavaCCErrors.warning(fl.getName() + ": File is obsolete. Please rename or delete this file so" + " that a new one can be generated for you."); } return; } } // If no version line is found, do not output the warning. } catch (final FileNotFoundException e1) { // This should never happen JavaCCErrors.semantic_error("Could not open file " + fl.getName() + " for writing."); throw new Error(); } catch (final IOException e2) { } } /** * Read the options line from the file and compare to the options currently in use. Output a warning if they * are different. * * @param fileName * @param options */ private void checkOptions(final File fl, final String[] opt) { try { final BufferedReader reader = new BufferedReader(new FileReader(fl)); String line; while ((line = reader.readLine()) != null) { if (line.startsWith("/* JavaCCOptions:")) { final String currentOptions = Options.getOptionsString(opt); if (line.indexOf(currentOptions) == -1) { JavaCCErrors .warning(fl.getName() + ": Generated using incompatible options. Please rename or delete this file so" + " that a new one can be generated for you."); } return; } } } catch (final FileNotFoundException e1) { // This should never happen JavaCCErrors.semantic_error("Could not open file " + fl.getName() + " for writing."); throw new Error(); } catch (final IOException e2) { } // Not found so cannot check } /** * Return a PrintWriter object that may be used to write to this file. Any necessary header information is * written by this method. * * @return * @throws IOException */ public PrintWriter getPrintWriter() throws IOException { if (pw == null) { MessageDigest digest; try { digest = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw (IOException) (new IOException("No MD5 implementation").initCause(e)); } dos = new DigestOutputStream(new BufferedOutputStream(new FileOutputStream(file)), digest); pw = new TrapClosePrintWriter(dos); // Write the headers.... final String version = compatibleVersion == null ? Version.version : compatibleVersion; // pw.println("/* " // + JavaCCGlobals.getIdString(toolName, file.getName()) // + " Version " + version + " */"); // if (options != null) { // pw.println("/* JavaCCOptions:" + Options.getOptionsString(options) + " */"); // } pw.println("/* ".concat(JavaCCGlobals.getIdString(toolName, file.getName())) .concat(" Version ").concat(version).concat(" */")); if (options != null) { pw.println("/* JavaCCOptions:".concat(Options.getOptionsString(options)).concat(" */")); } } return pw; } /** * Close the OutputFile, writing any necessary trailer information * (such as a checksum). * @throws IOException */ public void close() { // Write the trailer (checksum). // Possibly rename the .java.tmp to .java?? if (pw != null) { // Mod MMa : performance improvements (no concatenation) // pw.println(MD5_LINE_PART_1 + getMD5sum() + MD5_LINE_PART_2); pw.print(MD5_LINE_PART_1); pw.print(getMD5sum()); pw.println(MD5_LINE_PART_2); pw.closePrintWriter(); // file.renameTo(dest) } } private String getMD5sum() { pw.flush(); final byte[] digest = dos.getMessageDigest().digest(); return toHexString(digest); } private final static char[] HEX_DIGITS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; private static final String toHexString(final byte[] bytes) { final StringBuffer sb = new StringBuffer(32); for (int i = 0; i < bytes.length; i++) { final byte b = bytes[i]; sb.append(HEX_DIGITS[(b & 0xF0) >> 4]).append(HEX_DIGITS[b & 0x0F]); } return sb.toString(); } static class NullOutputStream extends OutputStream { @Override public void write(@SuppressWarnings("unused") final byte[] arg0, @SuppressWarnings("unused") final int arg1, @SuppressWarnings("unused") final int arg2) { } @Override public void write(@SuppressWarnings("unused") final byte[] arg0) { } @Override public void write(@SuppressWarnings("unused") final int arg0) { } } private class TrapClosePrintWriter extends PrintWriter { public TrapClosePrintWriter(final OutputStream os) { super(os); } public void closePrintWriter() { super.close(); } @Override public void close() { OutputFile.this.close(); } } /** * @return the toolName */ public final String getToolName() { return toolName; } /** * @param toolName the toolName to set */ public final void setToolName(final String tn) { toolName = tn; } } jtb-1.4.4/EDU/purdue/jtb/parser/JTBParserTokenManager.java0000644000175000017500000025754411416555666023106 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. JTBParserTokenManager.java */ package EDU.purdue.jtb.parser; import java.util.List; import java.util.ArrayList; import EDU.purdue.jtb.syntaxtree.*; /** Token Manager. */ public class JTBParserTokenManager implements JTBParserConstants { int size = 20; int beginLine[] = new int[size]; int beginCol[] = new int[size]; int depth = 0; final void saveBeginLineCol(final int l, final int c) { if (depth == size) { size += 10; final int tmpbeginLine[] = new int[size]; final int tmpbeginCol[] = new int[size]; System.arraycopy(beginLine, 0, tmpbeginLine, 0, depth); System.arraycopy(beginCol, 0, tmpbeginCol, 0, depth); beginLine = tmpbeginLine; beginCol = tmpbeginCol; } beginLine[depth] = l; beginCol[depth] = c; depth++; } final void restoreBeginLineCol() { depth--; input_stream.adjustBeginLineColumn(beginLine[depth], beginCol[depth]); } /** Debug output. */ public java.io.PrintStream debugStream = System.out; /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1, long active2) { switch (pos) { case 0: if ((active0 & 0x6a0000L) != 0L || (active1 & 0x2020000000000000L) != 0L) return 2; if ((active0 & 0xfffffffff8000ffeL) != 0L || (active1 & 0xffffL) != 0L || (active2 & 0x20L) != 0L) { jjmatchedKind = 141; return 32; } if ((active1 & 0x800000000L) != 0L || (active2 & 0x80L) != 0L) return 8; return -1; case 1: if ((active0 & 0x620000L) != 0L) return 0; if ((active0 & 0xfffbfe7ff8000ffeL) != 0L || (active1 & 0xffffL) != 0L || (active2 & 0x20L) != 0L) { if (jjmatchedPos != 1) { jjmatchedKind = 141; jjmatchedPos = 1; } return 32; } if ((active0 & 0x4018000000000L) != 0L) return 32; return -1; case 2: if ((active0 & 0xfb3aff7ff80007feL) != 0L || (active1 & 0xefffL) != 0L || (active2 & 0x20L) != 0L) { if (jjmatchedPos != 2) { jjmatchedKind = 141; jjmatchedPos = 2; } return 32; } if ((active0 & 0x4c1000000000800L) != 0L || (active1 & 0x1000L) != 0L) return 32; return -1; case 3: if ((active0 & 0xf2b8f97a780004feL) != 0L || (active1 & 0xc77fL) != 0L || (active2 & 0x20L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 3; return 32; } if ((active0 & 0x902060580000300L) != 0L || (active1 & 0x2880L) != 0L) return 32; return -1; case 4: if ((active0 & 0xf2b80960380000beL) != 0L || (active1 & 0x446dL) != 0L || (active2 & 0x20L) != 0L) { if (jjmatchedPos != 4) { jjmatchedKind = 141; jjmatchedPos = 4; } return 32; } if ((active0 & 0xf01a40000440L) != 0L || (active1 & 0x8312L) != 0L) return 32; return -1; case 5: if ((active0 & 0x70a84860280004beL) != 0L || (active1 & 0x4448L) != 0L || (active2 & 0x20L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 5; return 32; } if ((active0 & 0x8210010010000000L) != 0L || (active1 & 0x225L) != 0L) return 32; return -1; case 6: if ((active0 & 0x40a80020080004beL) != 0L || (active1 & 0x4448L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 6; return 32; } if ((active0 & 0x3000484020000000L) != 0L || (active2 & 0x20L) != 0L) return 32; return -1; case 7: if ((active0 & 0x40a800000000049eL) != 0L || (active1 & 0x440L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 7; return 32; } if ((active0 & 0x2008000020L) != 0L || (active1 & 0x4008L) != 0L) return 32; return -1; case 8: if ((active0 & 0x2800000000049cL) != 0L || (active1 & 0x40L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 8; return 32; } if ((active0 & 0x4080000000000002L) != 0L || (active1 & 0x400L) != 0L) return 32; return -1; case 9: if ((active0 & 0x48cL) != 0L || (active1 & 0x40L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 9; return 32; } if ((active0 & 0x28000000000010L) != 0L) return 32; return -1; case 10: if ((active0 & 0x488L) != 0L || (active1 & 0x40L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 10; return 32; } if ((active0 & 0x4L) != 0L) return 32; return -1; case 11: if ((active0 & 0x480L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 11; return 32; } if ((active0 & 0x8L) != 0L || (active1 & 0x40L) != 0L) return 32; return -1; case 12: if ((active0 & 0x400L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 12; return 32; } if ((active0 & 0x80L) != 0L) return 32; return -1; case 13: if ((active0 & 0x400L) != 0L) { jjmatchedKind = 141; jjmatchedPos = 13; return 32; } return -1; default : return -1; } } private final int jjStartNfa_0(int pos, long active0, long active1, long active2) { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1, active2), pos + 1); } private int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 33: jjmatchedKind = 102; return jjMoveStringLiteralDfa1_0(0x0L, 0x200000000000L, 0x0L); case 35: return jjStopAtPos(0, 134); case 37: jjmatchedKind = 121; return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x2L); case 38: jjmatchedKind = 118; return jjMoveStringLiteralDfa1_0(0x0L, 0x4000800000000000L, 0x0L); case 40: return jjStopAtPos(0, 91); case 41: return jjStopAtPos(0, 92); case 42: jjmatchedKind = 116; return jjMoveStringLiteralDfa1_0(0x0L, 0x1000000000000000L, 0x0L); case 43: jjmatchedKind = 114; return jjMoveStringLiteralDfa1_0(0x0L, 0x401000000000000L, 0x0L); case 44: return jjStopAtPos(0, 98); case 45: jjmatchedKind = 115; return jjMoveStringLiteralDfa1_0(0x0L, 0x802000000000000L, 0x0L); case 46: jjmatchedKind = 99; return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x80L); case 47: jjmatchedKind = 117; return jjMoveStringLiteralDfa1_0(0x6a0000L, 0x2000000000000000L, 0x0L); case 58: return jjStopAtPos(0, 105); case 59: return jjStopAtPos(0, 97); case 60: jjmatchedKind = 101; return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000L, 0x900L); case 61: jjmatchedKind = 100; return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000000L, 0x0L); case 62: jjmatchedKind = 132; return jjMoveStringLiteralDfa1_0(0x0L, 0x100000000000L, 0x60cL); case 63: return jjStopAtPos(0, 104); case 64: return jjStopAtPos(0, 140); case 69: return jjMoveStringLiteralDfa1_0(0x800L, 0x0L, 0x0L); case 73: return jjMoveStringLiteralDfa1_0(0x4L, 0x0L, 0x0L); case 74: return jjMoveStringLiteralDfa1_0(0x20L, 0x0L, 0x0L); case 76: return jjMoveStringLiteralDfa1_0(0x2L, 0x0L, 0x0L); case 77: return jjMoveStringLiteralDfa1_0(0x100L, 0x0L, 0x0L); case 80: return jjMoveStringLiteralDfa1_0(0x18L, 0x0L, 0x0L); case 83: return jjMoveStringLiteralDfa1_0(0x280L, 0x0L, 0x0L); case 84: return jjMoveStringLiteralDfa1_0(0x440L, 0x0L, 0x0L); case 91: return jjStopAtPos(0, 95); case 93: return jjStopAtPos(0, 96); case 94: jjmatchedKind = 120; return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x1L); case 97: return jjMoveStringLiteralDfa1_0(0x18000000L, 0x0L, 0x0L); case 98: return jjMoveStringLiteralDfa1_0(0xe0000000L, 0x0L, 0x0L); case 99: return jjMoveStringLiteralDfa1_0(0x3f00000000L, 0x0L, 0x0L); case 100: return jjMoveStringLiteralDfa1_0(0x1c000000000L, 0x0L, 0x0L); case 101: return jjMoveStringLiteralDfa1_0(0xe0000000000L, 0x0L, 0x0L); case 102: return jjMoveStringLiteralDfa1_0(0x1f00000000000L, 0x0L, 0x0L); case 103: return jjMoveStringLiteralDfa1_0(0x2000000000000L, 0x0L, 0x0L); case 105: return jjMoveStringLiteralDfa1_0(0xfc000000000000L, 0x0L, 0x0L); case 108: return jjMoveStringLiteralDfa1_0(0x100000000000000L, 0x0L, 0x0L); case 110: return jjMoveStringLiteralDfa1_0(0xe00000000000000L, 0x0L, 0x0L); case 111: return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x20L); case 112: return jjMoveStringLiteralDfa1_0(0xf000000000000000L, 0x0L, 0x0L); case 114: return jjMoveStringLiteralDfa1_0(0x0L, 0x1L, 0x0L); case 115: return jjMoveStringLiteralDfa1_0(0x0L, 0x7eL, 0x0L); case 116: return jjMoveStringLiteralDfa1_0(0x0L, 0x1f80L, 0x0L); case 118: return jjMoveStringLiteralDfa1_0(0x0L, 0x6000L, 0x0L); case 119: return jjMoveStringLiteralDfa1_0(0x0L, 0x8000L, 0x0L); case 123: return jjStopAtPos(0, 93); case 124: jjmatchedKind = 119; return jjMoveStringLiteralDfa1_0(0x0L, 0x8000400000000000L, 0x0L); case 125: return jjStopAtPos(0, 94); case 126: return jjStopAtPos(0, 103); default : return jjMoveNfa_0(3, 0); } } private int jjMoveStringLiteralDfa1_0(long active0, long active1, long active2) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0, active1, active2); return 1; } switch(curChar) { case 38: if ((active1 & 0x800000000000L) != 0L) return jjStopAtPos(1, 111); break; case 42: if ((active0 & 0x200000L) != 0L) { jjmatchedKind = 21; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0x420000L, active1, 0L, active2, 0L); case 43: if ((active1 & 0x1000000000000L) != 0L) return jjStopAtPos(1, 112); break; case 45: if ((active1 & 0x2000000000000L) != 0L) return jjStopAtPos(1, 113); break; case 46: return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x80L); case 47: if ((active0 & 0x80000L) != 0L) return jjStopAtPos(1, 19); break; case 60: if ((active2 & 0x800L) != 0L) { jjmatchedKind = 139; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x100L); case 61: if ((active1 & 0x40000000000L) != 0L) return jjStopAtPos(1, 106); else if ((active1 & 0x80000000000L) != 0L) return jjStopAtPos(1, 107); else if ((active1 & 0x100000000000L) != 0L) return jjStopAtPos(1, 108); else if ((active1 & 0x200000000000L) != 0L) return jjStopAtPos(1, 109); else if ((active1 & 0x400000000000000L) != 0L) return jjStopAtPos(1, 122); else if ((active1 & 0x800000000000000L) != 0L) return jjStopAtPos(1, 123); else if ((active1 & 0x1000000000000000L) != 0L) return jjStopAtPos(1, 124); else if ((active1 & 0x2000000000000000L) != 0L) return jjStopAtPos(1, 125); else if ((active1 & 0x4000000000000000L) != 0L) return jjStopAtPos(1, 126); else if ((active1 & 0x8000000000000000L) != 0L) return jjStopAtPos(1, 127); else if ((active2 & 0x1L) != 0L) return jjStopAtPos(1, 128); else if ((active2 & 0x2L) != 0L) return jjStopAtPos(1, 129); break; case 62: if ((active2 & 0x8L) != 0L) { jjmatchedKind = 131; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x604L); case 65: return jjMoveStringLiteralDfa2_0(active0, 0x38L, active1, 0L, active2, 0L); case 71: return jjMoveStringLiteralDfa2_0(active0, 0x4L, active1, 0L, active2, 0L); case 75: return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L, active2, 0L); case 79: return jjMoveStringLiteralDfa2_0(active0, 0xd42L, active1, 0L, active2, 0L); case 80: return jjMoveStringLiteralDfa2_0(active0, 0x80L, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa2_0(active0, 0x1200100300000000L, active1, 0L, active2, 0L); case 98: return jjMoveStringLiteralDfa2_0(active0, 0x8000000L, active1, 0L, active2, 0L); case 101: return jjMoveStringLiteralDfa2_0(active0, 0x400004000000000L, active1, 0x1L, active2, 0L); case 102: if ((active0 & 0x4000000000000L) != 0L) return jjStartNfaWithStates_0(1, 50, 32); break; case 104: return jjMoveStringLiteralDfa2_0(active0, 0x400000000L, active1, 0x8382L, active2, 0L); case 105: return jjMoveStringLiteralDfa2_0(active0, 0x600000000000L, active1, 0L, active2, 0L); case 108: return jjMoveStringLiteralDfa2_0(active0, 0x820800000000L, active1, 0L, active2, 0L); case 109: return jjMoveStringLiteralDfa2_0(active0, 0x18000000000000L, active1, 0L, active2, 0L); case 110: return jjMoveStringLiteralDfa2_0(active0, 0xe0040000000000L, active1, 0L, active2, 0L); case 111: if ((active0 & 0x8000000000L) != 0L) { jjmatchedKind = 39; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0x103013020000000L, active1, 0x6000L, active2, 0L); case 112: return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x20L); case 114: return jjMoveStringLiteralDfa2_0(active0, 0x6000000040000000L, active1, 0x1c00L, active2, 0L); case 115: return jjMoveStringLiteralDfa2_0(active0, 0x10000000L, active1, 0L, active2, 0L); case 116: return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0xcL, active2, 0L); case 117: return jjMoveStringLiteralDfa2_0(active0, 0x8800000000000000L, active1, 0x10L, active2, 0L); case 119: return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x20L, active2, 0L); case 120: return jjMoveStringLiteralDfa2_0(active0, 0x80000000000L, active1, 0L, active2, 0L); case 121: return jjMoveStringLiteralDfa2_0(active0, 0x80000000L, active1, 0x40L, active2, 0L); case 124: if ((active1 & 0x400000000000L) != 0L) return jjStopAtPos(1, 110); break; default : break; } return jjStartNfa_0(0, active0, active1, active2); } private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(0, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(1, active0, active1, active2); return 2; } switch(curChar) { case 46: if ((active2 & 0x80L) != 0L) return jjStopAtPos(2, 135); break; case 61: if ((active2 & 0x100L) != 0L) return jjStopAtPos(2, 136); else if ((active2 & 0x200L) != 0L) return jjStopAtPos(2, 137); break; case 62: if ((active2 & 0x4L) != 0L) { jjmatchedKind = 130; jjmatchedPos = 2; } return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0L, active2, 0x400L); case 64: return jjMoveStringLiteralDfa3_0(active0, 0x420000L, active1, 0L, active2, 0L); case 69: return jjMoveStringLiteralDfa3_0(active0, 0x80L, active1, 0L, active2, 0L); case 70: if ((active0 & 0x800L) != 0L) return jjStartNfaWithStates_0(2, 11, 32); break; case 73: return jjMoveStringLiteralDfa3_0(active0, 0x200L, active1, 0L, active2, 0L); case 75: return jjMoveStringLiteralDfa3_0(active0, 0x440L, active1, 0L, active2, 0L); case 78: return jjMoveStringLiteralDfa3_0(active0, 0x4L, active1, 0L, active2, 0L); case 79: return jjMoveStringLiteralDfa3_0(active0, 0x2L, active1, 0L, active2, 0L); case 82: return jjMoveStringLiteralDfa3_0(active0, 0x118L, active1, 0L, active2, 0L); case 86: return jjMoveStringLiteralDfa3_0(active0, 0x20L, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa3_0(active0, 0xc00000000L, active1, 0x404L, active2, 0L); case 98: return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000000L, active1, 0L, active2, 0L); case 99: return jjMoveStringLiteralDfa3_0(active0, 0x1000000000000000L, active1, 0L, active2, 0L); case 101: return jjMoveStringLiteralDfa3_0(active0, 0x40000000L, active1, 0L, active2, 0L); case 102: return jjMoveStringLiteralDfa3_0(active0, 0x4000000000L, active1, 0L, active2, 0L); case 105: return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0xa0a0L, active2, 0L); case 108: return jjMoveStringLiteralDfa3_0(active0, 0x800100000000000L, active1, 0x4000L, active2, 0L); case 110: return jjMoveStringLiteralDfa3_0(active0, 0x100603000000000L, active1, 0x40L, active2, 0L); case 111: return jjMoveStringLiteralDfa3_0(active0, 0x4000800020000000L, active1, 0x2L, active2, 0L); case 112: return jjMoveStringLiteralDfa3_0(active0, 0x18000000000000L, active1, 0x10L, active2, 0L); case 114: if ((active0 & 0x1000000000000L) != 0L) return jjStartNfaWithStates_0(2, 48, 32); return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x308L, active2, 0L); case 115: return jjMoveStringLiteralDfa3_0(active0, 0x20020118000000L, active1, 0L, active2, 0L); case 116: if ((active0 & 0x40000000000000L) != 0L) { jjmatchedKind = 54; jjmatchedPos = 2; } return jjMoveStringLiteralDfa3_0(active0, 0x282080280000000L, active1, 0x1L, active2, 0x20L); case 117: return jjMoveStringLiteralDfa3_0(active0, 0x50000000000L, active1, 0x800L, active2, 0L); case 119: if ((active0 & 0x400000000000000L) != 0L) return jjStartNfaWithStates_0(2, 58, 32); break; case 121: if ((active1 & 0x1000L) != 0L) return jjStartNfaWithStates_0(2, 76, 32); break; default : break; } return jjStartNfa_0(1, active0, active1, active2); } private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(1, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(2, active0, active1, active2); return 3; } switch(curChar) { case 61: if ((active2 & 0x400L) != 0L) return jjStopAtPos(3, 138); break; case 65: return jjMoveStringLiteralDfa4_0(active0, 0x20L, active1, 0L, active2, 0L); case 67: return jjMoveStringLiteralDfa4_0(active0, 0x80L, active1, 0L, active2, 0L); case 69: if ((active0 & 0x100L) != 0L) return jjStartNfaWithStates_0(3, 8, 32); return jjMoveStringLiteralDfa4_0(active0, 0x440L, active1, 0L, active2, 0L); case 75: return jjMoveStringLiteralDfa4_0(active0, 0x2L, active1, 0L, active2, 0L); case 79: return jjMoveStringLiteralDfa4_0(active0, 0x4L, active1, 0L, active2, 0L); case 80: if ((active0 & 0x200L) != 0L) return jjStartNfaWithStates_0(3, 9, 32); break; case 83: return jjMoveStringLiteralDfa4_0(active0, 0x18L, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa4_0(active0, 0xe04040000000L, active1, 0x4000L, active2, 0L); case 98: return jjMoveStringLiteralDfa4_0(active0, 0x10000400000L, active1, 0L, active2, 0L); case 99: return jjMoveStringLiteralDfa4_0(active0, 0x200000000L, active1, 0x40L, active2, 0L); case 100: if ((active1 & 0x2000L) != 0L) return jjStartNfaWithStates_0(3, 77, 32); break; case 101: if ((active0 & 0x80000000L) != 0L) return jjStartNfaWithStates_0(3, 31, 32); else if ((active0 & 0x100000000L) != 0L) return jjStartNfaWithStates_0(3, 32, 32); else if ((active0 & 0x20000000000L) != 0L) return jjStartNfaWithStates_0(3, 41, 32); else if ((active1 & 0x800L) != 0L) return jjStartNfaWithStates_0(3, 75, 32); return jjMoveStringLiteralDfa4_0(active0, 0x80080010020000L, active1, 0x10L, active2, 0L); case 103: if ((active0 & 0x100000000000000L) != 0L) return jjStartNfaWithStates_0(3, 56, 32); break; case 105: return jjMoveStringLiteralDfa4_0(active0, 0x200000000000000L, active1, 0x8L, active2, 0x20L); case 107: return jjMoveStringLiteralDfa4_0(active0, 0x1000000000000000L, active1, 0L, active2, 0L); case 108: if ((active0 & 0x800000000000000L) != 0L) return jjStartNfaWithStates_0(3, 59, 32); return jjMoveStringLiteralDfa4_0(active0, 0x8008000020000000L, active1, 0x8000L, active2, 0L); case 109: if ((active0 & 0x40000000000L) != 0L) return jjStartNfaWithStates_0(3, 42, 32); break; case 110: return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x400L, active2, 0L); case 111: if ((active0 & 0x2000000000000L) != 0L) return jjStartNfaWithStates_0(3, 49, 32); return jjMoveStringLiteralDfa4_0(active0, 0x10000000000000L, active1, 0x300L, active2, 0L); case 114: if ((active0 & 0x400000000L) != 0L) return jjStartNfaWithStates_0(3, 34, 32); return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x2L, active2, 0L); case 115: if ((active1 & 0x80L) != 0L) return jjStartNfaWithStates_0(3, 71, 32); return jjMoveStringLiteralDfa4_0(active0, 0x101800000000L, active1, 0L, active2, 0L); case 116: return jjMoveStringLiteralDfa4_0(active0, 0x4020002008000000L, active1, 0x24L, active2, 0L); case 117: return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x1L, active2, 0L); case 118: return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000000L, active1, 0L, active2, 0L); default : break; } return jjStartNfa_0(2, active0, active1, active2); } private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(2, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(3, active0, active1, active2); return 4; } switch(curChar) { case 65: return jjMoveStringLiteralDfa5_0(active0, 0x2L, active1, 0L, active2, 0L); case 67: return jjMoveStringLiteralDfa5_0(active0, 0x20L, active1, 0L, active2, 0L); case 69: return jjMoveStringLiteralDfa5_0(active0, 0x18L, active1, 0L, active2, 0L); case 73: return jjMoveStringLiteralDfa5_0(active0, 0x80L, active1, 0L, active2, 0L); case 78: if ((active0 & 0x40L) != 0L) { jjmatchedKind = 6; jjmatchedPos = 4; } return jjMoveStringLiteralDfa5_0(active0, 0x400L, active1, 0L, active2, 0L); case 82: return jjMoveStringLiteralDfa5_0(active0, 0x4L, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa5_0(active0, 0x3020000000000000L, active1, 0L, active2, 0L); case 99: return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x28L, active2, 0L); case 101: if ((active0 & 0x100000000000L) != 0L) return jjStartNfaWithStates_0(4, 44, 32); else if ((active1 & 0x8000L) != 0L) return jjStartNfaWithStates_0(4, 79, 32); return jjMoveStringLiteralDfa5_0(active0, 0x4008000020000000L, active1, 0L, active2, 0L); case 103: return jjMoveStringLiteralDfa5_0(active0, 0x420000L, active1, 0L, active2, 0L); case 104: if ((active0 & 0x200000000L) != 0L) return jjStartNfaWithStates_0(4, 33, 32); return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x40L, active2, 0L); case 105: return jjMoveStringLiteralDfa5_0(active0, 0x8000002000000000L, active1, 0x4L, active2, 0L); case 107: if ((active0 & 0x40000000L) != 0L) return jjStartNfaWithStates_0(4, 30, 32); break; case 108: if ((active0 & 0x200000000000L) != 0L) { jjmatchedKind = 45; jjmatchedPos = 4; } return jjMoveStringLiteralDfa5_0(active0, 0x410000000000L, active1, 0L, active2, 0L); case 110: return jjMoveStringLiteralDfa5_0(active0, 0x80000000000L, active1, 0L, active2, 0L); case 111: return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0L, active2, 0x20L); case 114: if ((active1 & 0x10L) != 0L) return jjStartNfaWithStates_0(4, 68, 32); return jjMoveStringLiteralDfa5_0(active0, 0x90000018000000L, active1, 0x1L, active2, 0L); case 115: if ((active0 & 0x800000000L) != 0L) return jjStartNfaWithStates_0(4, 35, 32); return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x400L, active2, 0L); case 116: if ((active0 & 0x1000000000L) != 0L) return jjStartNfaWithStates_0(4, 36, 32); else if ((active0 & 0x800000000000L) != 0L) return jjStartNfaWithStates_0(4, 47, 32); else if ((active1 & 0x2L) != 0L) return jjStartNfaWithStates_0(4, 65, 32); return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x4000L, active2, 0L); case 117: return jjMoveStringLiteralDfa5_0(active0, 0x4000000000L, active1, 0L, active2, 0L); case 118: return jjMoveStringLiteralDfa5_0(active0, 0x200000000000000L, active1, 0L, active2, 0L); case 119: if ((active1 & 0x100L) != 0L) { jjmatchedKind = 72; jjmatchedPos = 4; } return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x200L, active2, 0L); default : break; } return jjStartNfa_0(3, active0, active1, active2); } private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(3, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(4, active0, active1, active2); return 5; } switch(curChar) { case 65: return jjMoveStringLiteralDfa6_0(active0, 0x80L, active1, 0L, active2, 0L); case 69: return jjMoveStringLiteralDfa6_0(active0, 0x4L, active1, 0L, active2, 0L); case 72: return jjMoveStringLiteralDfa6_0(active0, 0x2L, active1, 0L, active2, 0L); case 79: return jjMoveStringLiteralDfa6_0(active0, 0x20L, active1, 0L, active2, 0L); case 82: return jjMoveStringLiteralDfa6_0(active0, 0x18L, active1, 0L, active2, 0L); case 95: return jjMoveStringLiteralDfa6_0(active0, 0x400L, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa6_0(active0, 0x28000000L, active1, 0L, active2, 0L); case 99: if ((active0 & 0x8000000000000000L) != 0L) return jjStartNfaWithStates_0(5, 63, 32); else if ((active1 & 0x4L) != 0L) return jjStartNfaWithStates_0(5, 66, 32); return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000000L, active1, 0L, active2, 0L); case 100: return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L, active1, 0L, active2, 0L); case 101: if ((active0 & 0x10000000000L) != 0L) return jjStartNfaWithStates_0(5, 40, 32); else if ((active0 & 0x200000000000000L) != 0L) return jjStartNfaWithStates_0(5, 57, 32); return jjMoveStringLiteralDfa6_0(active0, 0x420000L, active1, 0L, active2, 0L); case 102: return jjMoveStringLiteralDfa6_0(active0, 0x80000000000000L, active1, 0L, active2, 0L); case 103: return jjMoveStringLiteralDfa6_0(active0, 0x1000000000000000L, active1, 0L, active2, 0L); case 104: if ((active1 & 0x20L) != 0L) return jjStartNfaWithStates_0(5, 69, 32); break; case 105: return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x4400L, active2, 0L); case 108: return jjMoveStringLiteralDfa6_0(active0, 0x404000000000L, active1, 0L, active2, 0L); case 109: return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L, active1, 0L, active2, 0L); case 110: if ((active1 & 0x1L) != 0L) return jjStartNfaWithStates_0(5, 64, 32); return jjMoveStringLiteralDfa6_0(active0, 0x20002000000000L, active1, 0L, active2, 0x20L); case 114: return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x40L, active2, 0L); case 115: if ((active1 & 0x200L) != 0L) return jjStartNfaWithStates_0(5, 73, 32); break; case 116: if ((active0 & 0x10000000L) != 0L) return jjStartNfaWithStates_0(5, 28, 32); else if ((active0 & 0x10000000000000L) != 0L) return jjStartNfaWithStates_0(5, 52, 32); return jjMoveStringLiteralDfa6_0(active0, 0x2000000000000000L, active1, 0x8L, active2, 0L); default : break; } return jjStartNfa_0(4, active0, active1, active2); } private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(4, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(5, active0, active1, active2); return 6; } switch(curChar) { case 68: return jjMoveStringLiteralDfa7_0(active0, 0x20L, active1, 0L, active2, 0L); case 69: return jjMoveStringLiteralDfa7_0(active0, 0x2L, active1, 0L, active2, 0L); case 76: return jjMoveStringLiteralDfa7_0(active0, 0x80L, active1, 0L, active2, 0L); case 77: return jjMoveStringLiteralDfa7_0(active0, 0x400L, active1, 0L, active2, 0L); case 95: return jjMoveStringLiteralDfa7_0(active0, 0x1cL, active1, 0L, active2, 0L); case 97: return jjMoveStringLiteralDfa7_0(active0, 0x80000000000000L, active1, 0L, active2, 0L); case 99: return jjMoveStringLiteralDfa7_0(active0, 0x20000008000000L, active1, 0L, active2, 0L); case 101: if ((active0 & 0x1000000000000000L) != 0L) return jjStartNfaWithStates_0(6, 60, 32); else if ((active0 & 0x2000000000000000L) != 0L) return jjStartNfaWithStates_0(6, 61, 32); return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L, active1, 0x400L, active2, 0L); case 102: return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x8L, active2, 0L); case 108: return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x4000L, active2, 0L); case 110: if ((active0 & 0x20000000L) != 0L) return jjStartNfaWithStates_0(6, 29, 32); return jjMoveStringLiteralDfa7_0(active0, 0x420000L, active1, 0L, active2, 0L); case 111: return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x40L, active2, 0L); case 115: if ((active0 & 0x80000000000L) != 0L) return jjStartNfaWithStates_0(6, 43, 32); else if ((active2 & 0x20L) != 0L) return jjStartNfaWithStates_0(6, 133, 32); break; case 116: if ((active0 & 0x4000000000L) != 0L) return jjStartNfaWithStates_0(6, 38, 32); return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000000L, active1, 0L, active2, 0L); case 117: return jjMoveStringLiteralDfa7_0(active0, 0x2000000000L, active1, 0L, active2, 0L); case 121: if ((active0 & 0x400000000000L) != 0L) return jjStartNfaWithStates_0(6, 46, 32); break; default : break; } return jjStartNfa_0(5, active0, active1, active2); } private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long active1, long old2, long active2) { if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) return jjStartNfa_0(5, old0, old1, old2); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0, active1, 0L); return 7; } switch(curChar) { case 40: return jjMoveStringLiteralDfa8_0(active0, 0x400000L, active1, 0L); case 42: return jjMoveStringLiteralDfa8_0(active0, 0x20000L, active1, 0L); case 65: return jjMoveStringLiteralDfa8_0(active0, 0x2L, active1, 0L); case 66: return jjMoveStringLiteralDfa8_0(active0, 0x8L, active1, 0L); case 67: return jjMoveStringLiteralDfa8_0(active0, 0x4L, active1, 0L); case 69: if ((active0 & 0x20L) != 0L) return jjStartNfaWithStates_0(7, 5, 32); return jjMoveStringLiteralDfa8_0(active0, 0x10L, active1, 0L); case 71: return jjMoveStringLiteralDfa8_0(active0, 0x400L, active1, 0L); case 95: return jjMoveStringLiteralDfa8_0(active0, 0x80L, active1, 0L); case 99: return jjMoveStringLiteralDfa8_0(active0, 0x80000000000000L, active1, 0L); case 101: if ((active0 & 0x2000000000L) != 0L) return jjStartNfaWithStates_0(7, 37, 32); else if ((active1 & 0x4000L) != 0L) return jjStartNfaWithStates_0(7, 78, 32); return jjMoveStringLiteralDfa8_0(active0, 0x4020000000000000L, active1, 0L); case 110: return jjMoveStringLiteralDfa8_0(active0, 0x8000000000000L, active1, 0x440L); case 112: if ((active1 & 0x8L) != 0L) return jjStartNfaWithStates_0(7, 67, 32); break; case 116: if ((active0 & 0x8000000L) != 0L) return jjStartNfaWithStates_0(7, 27, 32); break; default : break; } return jjStartNfa_0(6, active0, active1, 0L); } private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long active1) { if (((active0 &= old0) | (active1 &= old1)) == 0L) return jjStartNfa_0(6, old0, old1, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(7, active0, active1, 0L); return 8; } switch(curChar) { case 47: if ((active0 & 0x20000L) != 0L) return jjStopAtPos(8, 17); break; case 65: return jjMoveStringLiteralDfa9_0(active0, 0x4L, active1, 0L); case 68: if ((active0 & 0x2L) != 0L) return jjStartNfaWithStates_0(8, 1, 32); break; case 69: return jjMoveStringLiteralDfa9_0(active0, 0x8L, active1, 0L); case 78: return jjMoveStringLiteralDfa9_0(active0, 0x10L, active1, 0L); case 82: return jjMoveStringLiteralDfa9_0(active0, 0x400L, active1, 0L); case 84: return jjMoveStringLiteralDfa9_0(active0, 0x80L, active1, 0L); case 100: if ((active0 & 0x4000000000000000L) != 0L) return jjStartNfaWithStates_0(8, 62, 32); break; case 101: if ((active0 & 0x80000000000000L) != 0L) return jjStartNfaWithStates_0(8, 55, 32); break; case 105: return jjMoveStringLiteralDfa9_0(active0, 0L, active1, 0x40L); case 106: return jjMoveStringLiteralDfa9_0(active0, 0x400000L, active1, 0L); case 111: return jjMoveStringLiteralDfa9_0(active0, 0x20000000000000L, active1, 0L); case 116: if ((active1 & 0x400L) != 0L) return jjStartNfaWithStates_0(8, 74, 32); return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L, active1, 0L); default : break; } return jjStartNfa_0(7, active0, active1, 0L); } private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long active1) { if (((active0 &= old0) | (active1 &= old1)) == 0L) return jjStartNfa_0(7, old0, old1, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(8, active0, active1, 0L); return 9; } switch(curChar) { case 68: if ((active0 & 0x10L) != 0L) return jjStartNfaWithStates_0(9, 4, 32); break; case 71: return jjMoveStringLiteralDfa10_0(active0, 0x8L, active1, 0L); case 79: return jjMoveStringLiteralDfa10_0(active0, 0x80L, active1, 0L); case 83: return jjMoveStringLiteralDfa10_0(active0, 0x4L, active1, 0L); case 95: return jjMoveStringLiteralDfa10_0(active0, 0x400L, active1, 0L); case 102: if ((active0 & 0x20000000000000L) != 0L) return jjStartNfaWithStates_0(9, 53, 32); break; case 106: return jjMoveStringLiteralDfa10_0(active0, 0x400000L, active1, 0L); case 115: if ((active0 & 0x8000000000000L) != 0L) return jjStartNfaWithStates_0(9, 51, 32); break; case 122: return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x40L); default : break; } return jjStartNfa_0(8, active0, active1, 0L); } private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1, long active1) { if (((active0 &= old0) | (active1 &= old1)) == 0L) return jjStartNfa_0(8, old0, old1, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(9, active0, active1, 0L); return 10; } switch(curChar) { case 68: return jjMoveStringLiteralDfa11_0(active0, 0x400L, active1, 0L); case 69: if ((active0 & 0x4L) != 0L) return jjStartNfaWithStates_0(10, 2, 32); break; case 73: return jjMoveStringLiteralDfa11_0(active0, 0x8L, active1, 0L); case 75: return jjMoveStringLiteralDfa11_0(active0, 0x80L, active1, 0L); case 101: return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x40L); case 116: return jjMoveStringLiteralDfa11_0(active0, 0x400000L, active1, 0L); default : break; } return jjStartNfa_0(9, active0, active1, 0L); } private int jjMoveStringLiteralDfa11_0(long old0, long active0, long old1, long active1) { if (((active0 &= old0) | (active1 &= old1)) == 0L) return jjStartNfa_0(9, old0, old1, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(10, active0, active1, 0L); return 11; } switch(curChar) { case 69: return jjMoveStringLiteralDfa12_0(active0, 0x480L, active1, 0L); case 78: if ((active0 & 0x8L) != 0L) return jjStartNfaWithStates_0(11, 3, 32); break; case 100: if ((active1 & 0x40L) != 0L) return jjStartNfaWithStates_0(11, 70, 32); break; case 114: return jjMoveStringLiteralDfa12_0(active0, 0x400000L, active1, 0L); default : break; } return jjStartNfa_0(10, active0, active1, 0L); } private int jjMoveStringLiteralDfa12_0(long old0, long active0, long old1, long active1) { if (((active0 &= old0) | (active1 &= old1)) == 0L) return jjStartNfa_0(10, old0, old1, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(11, active0, 0L, 0L); return 12; } switch(curChar) { case 67: return jjMoveStringLiteralDfa13_0(active0, 0x400L); case 78: if ((active0 & 0x80L) != 0L) return jjStartNfaWithStates_0(12, 7, 32); break; case 101: return jjMoveStringLiteralDfa13_0(active0, 0x400000L); default : break; } return jjStartNfa_0(11, active0, 0L, 0L); } private int jjMoveStringLiteralDfa13_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(11, old0, 0L, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(12, active0, 0L, 0L); return 13; } switch(curChar) { case 76: return jjMoveStringLiteralDfa14_0(active0, 0x400L); case 101: if ((active0 & 0x400000L) != 0L) return jjStopAtPos(13, 22); break; default : break; } return jjStartNfa_0(12, active0, 0L, 0L); } private int jjMoveStringLiteralDfa14_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(12, old0, 0L, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(13, active0, 0L, 0L); return 14; } switch(curChar) { case 83: if ((active0 & 0x400L) != 0L) return jjStartNfaWithStates_0(14, 10, 32); break; default : break; } return jjStartNfa_0(13, active0, 0L, 0L); } private int jjStartNfaWithStates_0(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_0(state, pos + 1); } static final long[] jjbitVec0 = { 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec3 = { 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL }; static final long[] jjbitVec4 = { 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL }; static final long[] jjbitVec5 = { 0xffffcffffffffL, 0xffffffffffff0000L, 0xf9ff3fffffffffffL, 0x401f00030003L }; static final long[] jjbitVec6 = { 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xffffffcff7fffL }; static final long[] jjbitVec7 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff003L, 0x33fffffffff199fL }; static final long[] jjbitVec8 = { 0xfffe000000000000L, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L }; static final long[] jjbitVec9 = { 0x7fffffe00000000L, 0xfffe0000000007ffL, 0xffffffffffffffffL, 0x1c000060002fffffL }; static final long[] jjbitVec10 = { 0x1ffffffd0000L, 0x0L, 0x3fffffffffL, 0x0L }; static final long[] jjbitVec11 = { 0x23ffffffffffffe0L, 0x3ff010000L, 0x3c5fdfffff99fe0L, 0xf0003b0000000L }; static final long[] jjbitVec12 = { 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100010000L }; static final long[] jjbitVec13 = { 0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L }; static final long[] jjbitVec14 = { 0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L }; static final long[] jjbitVec15 = { 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL }; static final long[] jjbitVec16 = { 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL }; static final long[] jjbitVec17 = { 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L }; static final long[] jjbitVec18 = { 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x7fffffffff003fL }; static final long[] jjbitVec19 = { 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL }; static final long[] jjbitVec20 = { 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL }; static final long[] jjbitVec21 = { 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL }; static final long[] jjbitVec22 = { 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x7ffffffffffL }; static final long[] jjbitVec23 = { 0x0L, 0x0L, 0xfffffffffffffL, 0x8000000L }; static final long[] jjbitVec24 = { 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L }; static final long[] jjbitVec25 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL }; static final long[] jjbitVec26 = { 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL }; static final long[] jjbitVec27 = { 0x8000000000000000L, 0x8000000000000001L, 0xffff00000000L, 0x0L }; static final long[] jjbitVec28 = { 0x3fbbd503e2ffc84L, 0xffffffff00000000L, 0xfL, 0x0L }; static final long[] jjbitVec29 = { 0x73e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffe601fffffL, 0x7fffffffffffffffL }; static final long[] jjbitVec30 = { 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0x0L }; static final long[] jjbitVec31 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L }; static final long[] jjbitVec32 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L }; static final long[] jjbitVec33 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L }; static final long[] jjbitVec34 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L }; static final long[] jjbitVec35 = { 0x3fffffffffffL, 0x0L, 0x0L, 0x0L }; static final long[] jjbitVec36 = { 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L }; static final long[] jjbitVec37 = { 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0xfff0000000000ffL }; static final long[] jjbitVec38 = { 0x18000000000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL }; static final long[] jjbitVec39 = { 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL }; static final long[] jjbitVec40 = { 0x0L, 0x0L, 0x420043cffffffffL, 0xff7fffffff7fffffL }; static final long[] jjbitVec41 = { 0xffffffffffffffffL, 0x400000700007fffL, 0xfffffffbffffd740L, 0xffffffcff7fffL }; static final long[] jjbitVec42 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff07bL, 0x33fffffffff199fL }; static final long[] jjbitVec43 = { 0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L }; static final long[] jjbitVec44 = { 0x7fffffe00000000L, 0xffff03ff003fffffL, 0xffffffffffffffffL, 0x1fff3dff9fefffffL }; static final long[] jjbitVec45 = { 0xffff1fffffff8000L, 0x7ffL, 0x1ffffffffffffL, 0x0L }; static final long[] jjbitVec46 = { 0xf3ffffffffffffeeL, 0xffcfff1f3fffL, 0xd3c5fdfffff99feeL, 0xfffcfb080399fL }; static final long[] jjbitVec47 = { 0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100013bbfL }; static final long[] jjbitVec48 = { 0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L }; static final long[] jjbitVec49 = { 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL }; static final long[] jjbitVec50 = { 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL }; static final long[] jjbitVec51 = { 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL }; static final long[] jjbitVec52 = { 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L }; static final long[] jjbitVec53 = { 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x7fffffffff003fL }; static final long[] jjbitVec54 = { 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL }; static final long[] jjbitVec55 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0x3ff080fffffL }; static final long[] jjbitVec56 = { 0xffffffff03ff7800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L }; static final long[] jjbitVec57 = { 0x80007c000000f000L, 0x8000fc0000000001L, 0xffff00000000L, 0x21fff0000L }; static final long[] jjbitVec58 = { 0x73efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x7fffffffffffffffL }; static final long[] jjbitVec59 = { 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L }; static final long[] jjbitVec60 = { 0x18000f00000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL }; static final long[] jjbitVec61 = { 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL }; private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 65; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 3: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(0, 6); else if (curChar == 36) { if (kind > 141) kind = 141; jjCheckNAdd(32); } else if (curChar == 34) jjCheckNAddStates(7, 9); else if (curChar == 39) jjAddStates(10, 11); else if (curChar == 46) jjCheckNAdd(8); else if (curChar == 47) jjstateSet[jjnewStateCnt++] = 2; if ((0x3fe000000000000L & l) != 0L) { if (kind > 80) kind = 80; jjCheckNAddTwoStates(5, 6); } else if (curChar == 48) { if (kind > 80) kind = 80; jjCheckNAddStates(12, 16); } break; case 0: if (curChar == 42) jjstateSet[jjnewStateCnt++] = 1; break; case 1: if ((0xffff7fffffffffffL & l) != 0L && kind > 20) kind = 20; break; case 2: if (curChar == 42) jjstateSet[jjnewStateCnt++] = 0; break; case 4: if ((0x3fe000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(5, 6); break; case 5: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(5, 6); break; case 7: if (curChar == 46) jjCheckNAdd(8); break; case 8: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddStates(17, 19); break; case 10: if ((0x280000000000L & l) != 0L) jjCheckNAdd(11); break; case 11: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddTwoStates(11, 12); break; case 13: if (curChar == 39) jjAddStates(10, 11); break; case 14: if ((0xffffff7fffffdbffL & l) != 0L) jjCheckNAdd(15); break; case 15: if (curChar == 39 && kind > 89) kind = 89; break; case 17: if ((0x8400000000L & l) != 0L) jjCheckNAdd(15); break; case 18: if ((0xff000000000000L & l) != 0L) jjCheckNAddTwoStates(19, 15); break; case 19: if ((0xff000000000000L & l) != 0L) jjCheckNAdd(15); break; case 20: if ((0xf000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 21; break; case 21: if ((0xff000000000000L & l) != 0L) jjCheckNAdd(19); break; case 22: if (curChar == 34) jjCheckNAddStates(7, 9); break; case 23: if ((0xfffffffbffffdbffL & l) != 0L) jjCheckNAddStates(7, 9); break; case 25: if ((0x8400000000L & l) != 0L) jjCheckNAddStates(7, 9); break; case 26: if (curChar == 34 && kind > 90) kind = 90; break; case 27: if ((0xff000000000000L & l) != 0L) jjCheckNAddStates(20, 23); break; case 28: if ((0xff000000000000L & l) != 0L) jjCheckNAddStates(7, 9); break; case 29: if ((0xf000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 30; break; case 30: if ((0xff000000000000L & l) != 0L) jjCheckNAdd(28); break; case 31: if (curChar != 36) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; case 32: if ((0x3ff00100fffc1ffL & l) == 0L) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; case 33: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(0, 6); break; case 34: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(24, 26); break; case 36: if ((0x280000000000L & l) != 0L) jjCheckNAdd(37); break; case 37: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(37, 12); break; case 38: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(38, 39); break; case 40: if ((0x280000000000L & l) != 0L) jjCheckNAdd(41); break; case 41: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddTwoStates(41, 12); break; case 42: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(42, 43); break; case 43: if (curChar != 46) break; if (kind > 84) kind = 84; jjCheckNAddStates(27, 29); break; case 44: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddStates(27, 29); break; case 46: if ((0x280000000000L & l) != 0L) jjCheckNAdd(47); break; case 47: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddTwoStates(47, 12); break; case 48: if (curChar != 48) break; if (kind > 80) kind = 80; jjCheckNAddStates(12, 16); break; case 50: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(50, 6); break; case 51: if ((0xff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(51, 6); break; case 53: if ((0x3ff000000000000L & l) != 0L) jjAddStates(30, 31); break; case 54: if (curChar == 46) jjCheckNAdd(55); break; case 55: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(55, 56); break; case 57: if ((0x280000000000L & l) != 0L) jjCheckNAdd(58); break; case 58: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddTwoStates(58, 12); break; case 60: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(32, 34); break; case 61: if (curChar == 46) jjCheckNAdd(62); break; case 63: if ((0x280000000000L & l) != 0L) jjCheckNAdd(64); break; case 64: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 84) kind = 84; jjCheckNAddTwoStates(64, 12); break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 3: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; case 1: if (kind > 20) kind = 20; break; case 6: if ((0x100000001000L & l) != 0L && kind > 80) kind = 80; break; case 9: if ((0x2000000020L & l) != 0L) jjAddStates(35, 36); break; case 12: if ((0x5000000050L & l) != 0L && kind > 84) kind = 84; break; case 14: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAdd(15); break; case 16: if (curChar == 92) jjAddStates(37, 39); break; case 17: if ((0x14404410000000L & l) != 0L) jjCheckNAdd(15); break; case 23: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(7, 9); break; case 24: if (curChar == 92) jjAddStates(40, 42); break; case 25: if ((0x14404410000000L & l) != 0L) jjCheckNAddStates(7, 9); break; case 32: if ((0x87fffffe87fffffeL & l) == 0L) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; case 35: if ((0x2000000020L & l) != 0L) jjAddStates(43, 44); break; case 39: if ((0x2000000020L & l) != 0L) jjAddStates(45, 46); break; case 45: if ((0x2000000020L & l) != 0L) jjAddStates(47, 48); break; case 49: if ((0x100000001000000L & l) != 0L) jjCheckNAdd(50); break; case 50: if ((0x7e0000007eL & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(50, 6); break; case 52: if ((0x100000001000000L & l) != 0L) jjCheckNAddTwoStates(53, 54); break; case 53: if ((0x7e0000007eL & l) != 0L) jjCheckNAddTwoStates(53, 54); break; case 55: if ((0x7e0000007eL & l) != 0L) jjAddStates(49, 50); break; case 56: if ((0x1000000010000L & l) != 0L) jjAddStates(51, 52); break; case 59: if ((0x100000001000000L & l) != 0L) jjCheckNAdd(60); break; case 60: if ((0x7e0000007eL & l) != 0L) jjCheckNAddStates(32, 34); break; case 62: if ((0x1000000010000L & l) != 0L) jjAddStates(53, 54); break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 3: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; case 1: if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 20) kind = 20; break; case 14: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjstateSet[jjnewStateCnt++] = 15; break; case 23: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(7, 9); break; case 32: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; if (kind > 141) kind = 141; jjCheckNAdd(32); break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 65 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private int jjMoveStringLiteralDfa0_4() { switch(curChar) { case 42: return jjMoveStringLiteralDfa1_4(0x2000000L); default : return 1; } } private int jjMoveStringLiteralDfa1_4(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return 1; } switch(curChar) { case 47: if ((active0 & 0x2000000L) != 0L) return jjStopAtPos(1, 25); break; default : return 2; } return 2; } private int jjMoveStringLiteralDfa0_2() { return jjMoveNfa_2(0, 0); } private int jjMoveNfa_2(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 3; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0x2400L & l) != 0L) { if (kind > 23) kind = 23; } if (curChar == 13) jjstateSet[jjnewStateCnt++] = 1; break; case 1: if (curChar == 10 && kind > 23) kind = 23; break; case 2: if (curChar == 13) jjstateSet[jjnewStateCnt++] = 1; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private int jjMoveStringLiteralDfa0_1() { return 1; } private int jjMoveStringLiteralDfa0_3() { switch(curChar) { case 42: return jjMoveStringLiteralDfa1_3(0x1000000L); default : return 1; } } private int jjMoveStringLiteralDfa1_3(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return 1; } switch(curChar) { case 47: if ((active0 & 0x1000000L) != 0L) return jjStopAtPos(1, 24); break; default : return 2; } return 2; } static final int[] jjnextStates = { 34, 35, 12, 38, 39, 42, 43, 23, 24, 26, 14, 16, 49, 51, 6, 52, 59, 8, 9, 12, 23, 24, 28, 26, 34, 35, 12, 44, 45, 12, 53, 54, 60, 61, 62, 10, 11, 17, 18, 20, 25, 27, 29, 36, 37, 40, 41, 46, 47, 55, 56, 57, 58, 63, 64, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec2[i2] & l2) != 0L); default : if ((jjbitVec0[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec4[i2] & l2) != 0L); case 2: return ((jjbitVec5[i2] & l2) != 0L); case 3: return ((jjbitVec6[i2] & l2) != 0L); case 4: return ((jjbitVec7[i2] & l2) != 0L); case 5: return ((jjbitVec8[i2] & l2) != 0L); case 6: return ((jjbitVec9[i2] & l2) != 0L); case 7: return ((jjbitVec10[i2] & l2) != 0L); case 9: return ((jjbitVec11[i2] & l2) != 0L); case 10: return ((jjbitVec12[i2] & l2) != 0L); case 11: return ((jjbitVec13[i2] & l2) != 0L); case 12: return ((jjbitVec14[i2] & l2) != 0L); case 13: return ((jjbitVec15[i2] & l2) != 0L); case 14: return ((jjbitVec16[i2] & l2) != 0L); case 15: return ((jjbitVec17[i2] & l2) != 0L); case 16: return ((jjbitVec18[i2] & l2) != 0L); case 17: return ((jjbitVec19[i2] & l2) != 0L); case 18: return ((jjbitVec20[i2] & l2) != 0L); case 19: return ((jjbitVec21[i2] & l2) != 0L); case 20: return ((jjbitVec0[i2] & l2) != 0L); case 22: return ((jjbitVec22[i2] & l2) != 0L); case 23: return ((jjbitVec23[i2] & l2) != 0L); case 24: return ((jjbitVec24[i2] & l2) != 0L); case 30: return ((jjbitVec25[i2] & l2) != 0L); case 31: return ((jjbitVec26[i2] & l2) != 0L); case 32: return ((jjbitVec27[i2] & l2) != 0L); case 33: return ((jjbitVec28[i2] & l2) != 0L); case 48: return ((jjbitVec29[i2] & l2) != 0L); case 49: return ((jjbitVec30[i2] & l2) != 0L); case 77: return ((jjbitVec31[i2] & l2) != 0L); case 159: return ((jjbitVec32[i2] & l2) != 0L); case 164: return ((jjbitVec33[i2] & l2) != 0L); case 215: return ((jjbitVec34[i2] & l2) != 0L); case 250: return ((jjbitVec35[i2] & l2) != 0L); case 251: return ((jjbitVec36[i2] & l2) != 0L); case 253: return ((jjbitVec37[i2] & l2) != 0L); case 254: return ((jjbitVec38[i2] & l2) != 0L); case 255: return ((jjbitVec39[i2] & l2) != 0L); default : if ((jjbitVec3[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec40[i2] & l2) != 0L); case 2: return ((jjbitVec5[i2] & l2) != 0L); case 3: return ((jjbitVec41[i2] & l2) != 0L); case 4: return ((jjbitVec42[i2] & l2) != 0L); case 5: return ((jjbitVec43[i2] & l2) != 0L); case 6: return ((jjbitVec44[i2] & l2) != 0L); case 7: return ((jjbitVec45[i2] & l2) != 0L); case 9: return ((jjbitVec46[i2] & l2) != 0L); case 10: return ((jjbitVec47[i2] & l2) != 0L); case 11: return ((jjbitVec48[i2] & l2) != 0L); case 12: return ((jjbitVec49[i2] & l2) != 0L); case 13: return ((jjbitVec50[i2] & l2) != 0L); case 14: return ((jjbitVec51[i2] & l2) != 0L); case 15: return ((jjbitVec52[i2] & l2) != 0L); case 16: return ((jjbitVec53[i2] & l2) != 0L); case 17: return ((jjbitVec19[i2] & l2) != 0L); case 18: return ((jjbitVec20[i2] & l2) != 0L); case 19: return ((jjbitVec54[i2] & l2) != 0L); case 20: return ((jjbitVec0[i2] & l2) != 0L); case 22: return ((jjbitVec22[i2] & l2) != 0L); case 23: return ((jjbitVec55[i2] & l2) != 0L); case 24: return ((jjbitVec56[i2] & l2) != 0L); case 30: return ((jjbitVec25[i2] & l2) != 0L); case 31: return ((jjbitVec26[i2] & l2) != 0L); case 32: return ((jjbitVec57[i2] & l2) != 0L); case 33: return ((jjbitVec28[i2] & l2) != 0L); case 48: return ((jjbitVec58[i2] & l2) != 0L); case 49: return ((jjbitVec30[i2] & l2) != 0L); case 77: return ((jjbitVec31[i2] & l2) != 0L); case 159: return ((jjbitVec32[i2] & l2) != 0L); case 164: return ((jjbitVec33[i2] & l2) != 0L); case 215: return ((jjbitVec34[i2] & l2) != 0L); case 250: return ((jjbitVec35[i2] & l2) != 0L); case 251: return ((jjbitVec59[i2] & l2) != 0L); case 253: return ((jjbitVec37[i2] & l2) != 0L); case 254: return ((jjbitVec60[i2] & l2) != 0L); case 255: return ((jjbitVec61[i2] & l2) != 0L); default : if ((jjbitVec3[i1] & l1) != 0L) return true; return false; } } /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", "\114\117\117\113\101\110\105\101\104", "\111\107\116\117\122\105\137\103\101\123\105", "\120\101\122\123\105\122\137\102\105\107\111\116", "\120\101\122\123\105\122\137\105\116\104", "\112\101\126\101\103\117\104\105", "\124\117\113\105\116", "\123\120\105\103\111\101\114\137\124\117\113\105\116", "\115\117\122\105", "\123\113\111\120", "\124\117\113\105\116\137\115\107\122\137\104\105\103\114\123", "\105\117\106", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156", "\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150", "\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164", "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145", "\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145", "\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162", "\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163", "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164", "\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167", "\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145", "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156", "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160", "\163\165\160\145\162", "\163\167\151\164\143\150", "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163", "\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144", "\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73", "\54", "\56", "\75", "\74", "\41", "\176", "\77", "\72", "\75\75", "\74\75", "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", "\55", "\52", "\57", "\46", "\174", "\136", "\45", "\53\75", "\55\75", "\52\75", "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\76\76\76", "\76\76", "\76", "\157\160\164\151\157\156\163", "\43", "\56\56\56", "\74\74\75", "\76\76\75", "\76\76\76\75", "\74\74", "\100", null, null, null, }; /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", "AFTER_EGEN", "IN_SINGLE_LINE_COMMENT", "IN_FORMAL_COMMENT", "IN_MULTI_LINE_COMMENT", }; /** Lex State array. */ public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 2, 3, 4, 4, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; static final long[] jjtoToken = { 0xfffffffff8000fffL, 0xfffffffffe11ffffL, 0x3fffL, }; static final long[] jjtoSkip = { 0x387f000L, 0x0L, 0x0L, }; static final long[] jjtoSpecial = { 0x3800000L, 0x0L, 0x0L, }; static final long[] jjtoMore = { 0x4780000L, 0x0L, 0x0L, }; protected JavaCharStream input_stream; private final int[] jjrounds = new int[65]; private final int[] jjstateSet = new int[130]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; private int lengthOfMatch; protected char curChar; /** Constructor. */ public JTBParserTokenManager(JavaCharStream stream){ if (JavaCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } /** Constructor. */ public JTBParserTokenManager(JavaCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } /** Reinitialise parser. */ public void ReInit(JavaCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } private void ReInitRounds() { int i; jjround = 0x80000001; for (i = 65; i-- > 0;) jjrounds[i] = 0x80000000; } /** Reinitialise parser. */ public void ReInit(JavaCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } /** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 5 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; } protected Token jjFillToken() { final Token t; final String curTokenImage; final int beginLine; final int endLine; final int beginColumn; final int endColumn; String im = jjstrLiteralImages[jjmatchedKind]; curTokenImage = (im == null) ? input_stream.GetImage() : im; beginLine = input_stream.getBeginLine(); beginColumn = input_stream.getBeginColumn(); endLine = input_stream.getEndLine(); endColumn = input_stream.getEndColumn(); t = Token.newToken(jjmatchedKind); t.kind = jjmatchedKind; t.image = curTokenImage; t.beginLine = beginLine; t.endLine = endLine; t.beginColumn = beginColumn; t.endColumn = endColumn; return t; } int curLexState = 0; int defaultLexState = 0; int jjnewStateCnt; int jjround; int jjmatchedPos; int jjmatchedKind; /** Get the next Token. */ public Token getNextToken() { Token specialToken = null; Token matchedToken; int curPos = 0; EOFLoop : for (;;) { try { curChar = input_stream.BeginToken(); } catch(java.io.IOException e) { jjmatchedKind = 0; matchedToken = jjFillToken(); matchedToken.specialToken = specialToken; return matchedToken; } image = jjimage; image.setLength(0); jjimageLen = 0; for (;;) { switch(curLexState) { case 0: try { input_stream.backup(0); while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) curChar = input_stream.BeginToken(); } catch (java.io.IOException e1) { continue EOFLoop; } jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); break; case 1: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_1(); if (jjmatchedPos == 0 && jjmatchedKind > 18) { jjmatchedKind = 18; } break; case 2: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_2(); if (jjmatchedPos == 0 && jjmatchedKind > 26) { jjmatchedKind = 26; } break; case 3: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_3(); if (jjmatchedPos == 0 && jjmatchedKind > 26) { jjmatchedKind = 26; } break; case 4: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_4(); if (jjmatchedPos == 0 && jjmatchedKind > 26) { jjmatchedKind = 26; } break; } if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) input_stream.backup(curPos - jjmatchedPos - 1); if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { matchedToken = jjFillToken(); matchedToken.specialToken = specialToken; TokenLexicalActions(matchedToken); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; return matchedToken; } else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { matchedToken = jjFillToken(); if (specialToken == null) specialToken = matchedToken; else { matchedToken.specialToken = specialToken; specialToken = (specialToken.next = matchedToken); } SkipLexicalActions(matchedToken); } else SkipLexicalActions(null); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; continue EOFLoop; } MoreLexicalActions(); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; curPos = 0; jjmatchedKind = 0x7fffffff; try { curChar = input_stream.readChar(); continue; } catch (java.io.IOException e1) { } } int error_line = input_stream.getEndLine(); int error_column = input_stream.getEndColumn(); String error_after = null; boolean EOFSeen = false; try { input_stream.readChar(); input_stream.backup(1); } catch (java.io.IOException e1) { EOFSeen = true; error_after = curPos <= 1 ? "" : input_stream.GetImage(); if (curChar == '\n' || curChar == '\r') { error_line++; error_column = 0; } else error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) { case 18 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); restoreBeginLineCol(); input_stream.backup(1); break; default : break; } } void MoreLexicalActions() { jjimageLen += (lengthOfMatch = jjmatchedPos + 1); switch(jjmatchedKind) { case 20 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; input_stream.backup(1); break; case 22 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; saveBeginLineCol(input_stream.getBeginLine(), input_stream.getBeginColumn()); break; default : break; } } void TokenLexicalActions(Token matchedToken) { switch(jjmatchedKind) { case 130 : image.append(jjstrLiteralImages[130]); lengthOfMatch = jjstrLiteralImages[130].length(); matchedToken.kind = GT; ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; input_stream.backup(2); matchedToken.image = ">"; break; case 131 : image.append(jjstrLiteralImages[131]); lengthOfMatch = jjstrLiteralImages[131].length(); matchedToken.kind = GT; ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; input_stream.backup(1); matchedToken.image = ">"; break; default : break; } } private void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) { jjstateSet[jjnewStateCnt++] = state; jjrounds[state] = jjround; } } private void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); } private void jjCheckNAddTwoStates(int state1, int state2) { jjCheckNAdd(state1); jjCheckNAdd(state2); } private void jjCheckNAddStates(int start, int end) { do { jjCheckNAdd(jjnextStates[start]); } while (start++ != end); } } jtb-1.4.4/EDU/purdue/jtb/parser/Options.java0000644000175000017500000005405311360636752020431 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import EDU.purdue.jtb.misc.Globals; /** * A class with static state that stores all option information. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar
* 1.4.0 : 11/2009 : MMa : added JTB options */ public class Options { /** * Limit subclassing to derived classes. */ protected Options() { } /** * A mapping of option names (Strings) to values (Integer, Boolean, String). This table is * initialized by the main program. Its contents defines the set of legal options. Its initial * values define the default option values, and the option types can be determined from these * values too.
* MMa : modified (allocated here) for JTB */ // protected static Map optionValues = null; ; protected static Map optionValues = new HashMap(64); ; /** * Convenience method to retrieve integer options. * * @param option the option string key * @return the option integer value */ protected static int intValue(final String option) { return ((Integer) optionValues.get(option)).intValue(); } /** * Convenience method to retrieve boolean options. * * @param option the option string key * @return the option boolean value */ protected static boolean booleanValue(final String option) { return ((Boolean) optionValues.get(option)).booleanValue(); } /** * Convenience method to retrieve string options. * * @param option the option string key * @return the option string value */ protected static String stringValue(final String option) { return (String) optionValues.get(option); } /** * @return the option string value corresponding to the option string key
* MMa : modified (direct reference) for JTB */ public static Map getOptions() { // return new HashMap(optionValues); return optionValues; } /** * Keep track of what options were set as a command line argument. We use this to see if the * options set from the command line and the ones set in the input files clash in any way. */ private static Set cmdLineSetting = null; /** * Keep track of what options were set from the grammar file. We use this to see if the options * set from the command line and the ones set in the input files clash in any way. */ private static Set inputFileSetting = null; /** * Initialize for JavaCC / JJTree / JTB */ public static void init() { cmdLineSetting = new HashSet(); inputFileSetting = new HashSet(); // JavaCC & JJTree options optionValues.put("BUILD_PARSER", Boolean.TRUE); optionValues.put("BUILD_TOKEN_MANAGER", Boolean.TRUE); optionValues.put("CACHE_TOKENS", Boolean.FALSE); optionValues.put("CHOICE_AMBIGUITY_CHECK", new Integer(2)); optionValues.put("COMMON_TOKEN_ACTION", Boolean.FALSE); optionValues.put("DEBUG_LOOKAHEAD", Boolean.FALSE); optionValues.put("DEBUG_PARSER", Boolean.FALSE); optionValues.put("DEBUG_TOKEN_MANAGER", Boolean.FALSE); optionValues.put("ERROR_REPORTING", Boolean.TRUE); optionValues.put("FORCE_LA_CHECK", Boolean.FALSE); optionValues.put("GENERATE_ANNOTATIONS", Boolean.FALSE); optionValues.put("GENERATE_CHAINED_EXCEPTION", Boolean.FALSE); optionValues.put("GENERATE_GENERICS", Boolean.FALSE); optionValues.put("GENERATE_STRING_BUILDER", Boolean.FALSE); optionValues.put("IGNORE_CASE", Boolean.FALSE); optionValues.put("JAVA_UNICODE_ESCAPE", Boolean.FALSE); optionValues.put("JDK_VERSION", "1.5"); optionValues.put("KEEP_LINE_COLUMN", Boolean.TRUE); optionValues.put("LOOKAHEAD", new Integer(1)); optionValues.put("OTHER_AMBIGUITY_CHECK", new Integer(1)); optionValues.put("OUTPUT_DIRECTORY", "."); optionValues.put("SANITY_CHECK", Boolean.TRUE); optionValues.put("STATIC", Boolean.TRUE); optionValues.put("SUPPORT_CLASS_VISIBILITY_PUBLIC", Boolean.TRUE); optionValues.put("TOKEN_EXTENDS", ""); optionValues.put("TOKEN_FACTORY", ""); optionValues.put("TOKEN_MANAGER_USES_PARSER", Boolean.FALSE); optionValues.put("UNICODE_INPUT", Boolean.FALSE); optionValues.put("USER_CHAR_STREAM", Boolean.FALSE); optionValues.put("USER_TOKEN_MANAGER", Boolean.FALSE); // JTB Options (with default values or command line arguments) // -h & -si are not managed in an input file if (optionValues.get("JTB_CL") == null) optionValues.put("JTB_CL", new Boolean(Globals.printClassList)); if (optionValues.get("JTB_D") == null) optionValues.put("JTB_D", ""); if (optionValues.get("JTB_DL") == null) optionValues.put("JTB_DL", new Boolean(Globals.depthLevel)); if (optionValues.get("JTB_E") == null) optionValues.put("JTB_E", new Boolean(Globals.noSemanticCheck)); if (optionValues.get("JTB_F") == null) optionValues.put("JTB_F", new Boolean(Globals.descriptiveFieldNames)); if (optionValues.get("JTB_IA") == null) optionValues.put("JTB_IA", new Boolean(Globals.inlineAcceptMethods)); if (optionValues.get("JTB_JD") == null) optionValues.put("JTB_JD", new Boolean(Globals.javaDocComments)); if (optionValues.get("JTB_ND") == null) optionValues.put("JTB_ND", Globals.nodesDirName); if (optionValues.get("JTB_NP") == null) optionValues.put("JTB_NP", Globals.nodesPackageName); if (optionValues.get("JTB_NS") == null) optionValues.put("JTB_NS", ""); if (optionValues.get("JTB_O") == null) optionValues.put("JTB_O", Globals.DEF_OUT_FILE_NAME); if (optionValues.get("JTB_P") == null) optionValues.put("JTB_P", ""); if (optionValues.get("JTB_PP") == null) optionValues.put("JTB_PP", new Boolean(Globals.parentPointer)); if (optionValues.get("JTB_PRINTER") == null) optionValues.put("JTB_PRINTER", new Boolean(Globals.printerToolkit)); if (optionValues.get("JTB_SCHEME") == null) optionValues.put("JTB_SCHEME", new Boolean(Globals.schemeToolkit)); if (optionValues.get("JTB_TK") == null) optionValues.put("JTB_TK", new Boolean(Globals.keepSpecialTokens)); if (optionValues.get("JTB_VD") == null) optionValues.put("JTB_VD", Globals.visitorsDirName); if (optionValues.get("JTB_VP") == null) optionValues.put("JTB_VP", Globals.visitorsPackageName); if (optionValues.get("JTB_W") == null) optionValues.put("JTB_W", new Boolean(Globals.noOverwrite)); } /** * Returns a string representation of the specified options of interest. Used when, for example, * generating Token.java to record the JavaCC options that were used to generate the file. All of * the options must be boolean values. * * @param interestingOptions the options of interest, eg {"STATIC", "CACHE_TOKENS"} * @return the string representation of the options, eg "STATIC=true,CACHE_TOKENS=false" */ public static String getOptionsString(final String[] interestingOptions) { // MMa : performance improvements (StringBuffer allocation) // StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer(128); for (int i = 0; i < interestingOptions.length; i++) { final String key = interestingOptions[i]; sb.append(key); sb.append('='); sb.append(optionValues.get(key)); if (i != interestingOptions.length - 1) { sb.append(','); } } return sb.toString(); } /** * Determine if a given command line argument might be an option flag. Command line options start * with a dash (-). * * @param opt The command line argument to examine. * @return True when the argument looks like an option flag. */ public static boolean isOption(final String opt) { return opt != null && opt.length() > 1 && opt.charAt(0) == '-'; } /** * Help function to handle cases where the meaning of an option has changed over time. If the user * has supplied an option in the old format, it will be converted to the new format. * * @param name The name of the option being checked. * @param value The option's value. * @return The upgraded value. */ public static Object upgradeValue(final String name, final Object value) { Object val = value; if (name.equalsIgnoreCase("NODE_FACTORY") && value.getClass() == Boolean.class) { if (((Boolean) value).booleanValue()) { val = "*"; } else { val = ""; } } return val; } /** * Sets an option for the input file. * * @param nameloc the option name location * @param valueloc the option value location * @param name the option name * @param value the option value */ public static void setInputFileOption(final Object nameloc, final Object valueloc, final String name, final Object value) { Object val = value; final String s = name.toUpperCase(); if (!optionValues.containsKey(s)) { JavaCCErrors.warning(nameloc, "Bad option name \"" + name + "\". Option setting will be ignored."); return; } final Object existingValue = optionValues.get(s); val = upgradeValue(name, val); if (existingValue != null) { if ((existingValue.getClass() != val.getClass()) || (val instanceof Integer && ((Integer) val).intValue() <= 0)) { JavaCCErrors.warning(valueloc, "Bad option value \"" + val + "\" for \"" + name + "\". Option setting will be ignored."); return; } if (inputFileSetting.contains(s)) { JavaCCErrors.warning(nameloc, "Duplicate option setting for \"" + name + "\" will be ignored."); return; } if (cmdLineSetting.contains(s)) { if (!existingValue.equals(val)) { JavaCCErrors.warning(nameloc, "Command line setting of \"" + name + "\" modifies option value in file."); } return; } } optionValues.put(s, val); inputFileSetting.add(s); } /** * Process a single command line option. The option is parsed and stored in the optionValues map. * (Not used). * * @param arg the command line option */ public static void setCmdLineOption(final String arg) { final String s; if (arg.charAt(0) == '-') { s = arg.substring(1); } else { s = arg; } String name; Object val; // Look for the first ":" or "=", which will separate the option name // from its value (if any). final int index1 = s.indexOf('='); final int index2 = s.indexOf(':'); final int index; if (index1 < 0) index = index2; else if (index2 < 0) index = index1; else if (index1 < index2) index = index1; else index = index2; if (index < 0) { name = s.toUpperCase(); if (optionValues.containsKey(name)) { val = Boolean.TRUE; } else if (name.length() > 2 && name.charAt(0) == 'N' && name.charAt(1) == 'O') { val = Boolean.FALSE; name = name.substring(2); } else { System.out.println("Warning: Bad option \"" + arg + "\" will be ignored."); return; } } else { name = s.substring(0, index).toUpperCase(); if (s.substring(index + 1).equalsIgnoreCase("TRUE")) { val = Boolean.TRUE; } else if (s.substring(index + 1).equalsIgnoreCase("FALSE")) { val = Boolean.FALSE; } else { try { final int i = Integer.parseInt(s.substring(index + 1)); if (i <= 0) { System.out.println("Warning: Bad option value in \"" + arg + "\" will be ignored."); return; } val = new Integer(i); } catch (final NumberFormatException e) { val = s.substring(index + 1); if (s.length() > index + 2) { // i.e., there is space for two '"'s in value if (s.charAt(index + 1) == '"' && s.charAt(s.length() - 1) == '"') { // remove the two '"'s. val = s.substring(index + 2, s.length() - 1); } } } } } if (!optionValues.containsKey(name)) { System.out.println("Warning: Bad option \"" + arg + "\" will be ignored."); return; } final Object valOrig = optionValues.get(name); if (val.getClass() != valOrig.getClass()) { System.out.println("Warning: Bad option value in \"" + arg + "\" will be ignored."); return; } if (cmdLineSetting.contains(name)) { System.out.println("Warning: Duplicate option setting \"" + arg + "\" will be ignored."); return; } val = upgradeValue(name, val); optionValues.put(name, val); cmdLineSetting.add(name); } /** * Normalizes the options (ie checks coherence and dependances). */ // MMa : added public public static void normalize() { if (getDebugLookahead() && !getDebugParser()) { if (cmdLineSetting.contains("DEBUG_PARSER") || inputFileSetting.contains("DEBUG_PARSER")) { JavaCCErrors.warning("True setting of option DEBUG_LOOKAHEAD overrides " + "false setting of option DEBUG_PARSER."); } optionValues.put("DEBUG_PARSER", Boolean.TRUE); } // Now set the "GENERATE" options from the supplied (or default) JDK version. optionValues.put("GENERATE_CHAINED_EXCEPTION", Boolean.valueOf(jdkVersionAtLeast(1.4))); optionValues.put("GENERATE_GENERICS", Boolean.valueOf(jdkVersionAtLeast(1.5))); optionValues.put("GENERATE_STRING_BUILDER", Boolean.valueOf(jdkVersionAtLeast(1.5))); optionValues.put("GENERATE_ANNOTATIONS", Boolean.valueOf(jdkVersionAtLeast(1.5))); } /** * Find the build parser value. * * @return The requested build parser value. */ public static boolean getBuildParser() { return booleanValue("BUILD_PARSER"); } /** * Find the build token manager value. * * @return The requested build token manager value. */ public static boolean getBuildTokenManager() { return booleanValue("BUILD_TOKEN_MANAGER"); } /** * Find the cache tokens value. * * @return The requested cache tokens value. */ public static boolean getCacheTokens() { return booleanValue("CACHE_TOKENS"); } /** * Find the choice ambiguity check value. * * @return The requested choice ambiguity check value. */ public static int getChoiceAmbiguityCheck() { return intValue("CHOICE_AMBIGUITY_CHECK"); } /** * Find the common token action value. * * @return The requested common token action value. */ public static boolean getCommonTokenAction() { return booleanValue("COMMON_TOKEN_ACTION"); } /** * Find the debug parser value. * * @return The requested debug parser value. */ public static boolean getDebugParser() { return booleanValue("DEBUG_PARSER"); } /** * Find the debug lookahead value. * * @return The requested debug lookahead value. */ public static boolean getDebugLookahead() { return booleanValue("DEBUG_LOOKAHEAD"); } /** * Find the debug tokenmanager value. * * @return The requested debug tokenmanager value. */ public static boolean getDebugTokenManager() { return booleanValue("DEBUG_TOKEN_MANAGER"); } /** * Find the error reporting value. * * @return The requested error reporting value. */ public static boolean getErrorReporting() { return booleanValue("ERROR_REPORTING"); } /** * Find the force lookahead check value. * * @return The requested force lookahead value. */ public static boolean getForceLaCheck() { return booleanValue("FORCE_LA_CHECK"); } /** * Should the generated code contain Annotations? * * @return The generate annotations value */ public static boolean getGenerateAnnotations() { return booleanValue("GENERATE_ANNOTATIONS"); } /** * Should the generated code create Exceptions using a constructor taking a nested exception? * * @return The generate chained exception value */ public static boolean getGenerateChainedException() { return booleanValue("GENERATE_CHAINED_EXCEPTION"); } /** * Should the generated code contain Generics? * * @return The generate generics value */ public static boolean getGenerateGenerics() { return booleanValue("GENERATE_GENERICS"); } /** * Should the generated code use StringBuilder rather than StringBuffer? * * @return The generate StringBuilder exception value */ public static boolean getGenerateStringBuilder() { return booleanValue("GENERATE_STRING_BUILDER"); } /** * Find the ignore case value. * * @return The requested ignore case value. */ public static boolean getIgnoreCase() { return booleanValue("IGNORE_CASE"); } /** * Find the Java unicode escape value. * * @return The requested Java unicode escape value. */ public static boolean getJavaUnicodeEscape() { return booleanValue("JAVA_UNICODE_ESCAPE"); } /** * Find the JDK version. * * @return The requested jdk version. */ public static String getJdkVersion() { return stringValue("JDK_VERSION"); } /** * Find the keep line column value. * * @return The requested keep line column value. */ public static boolean getKeepLineColumn() { return booleanValue("KEEP_LINE_COLUMN"); } /** * Find the lookahead setting. * * @return The requested lookahead value. */ public static int getLookahead() { return intValue("LOOKAHEAD"); } /** * Find the other ambiguity check value. * * @return The requested other ambiguity check value. */ public static int getOtherAmbiguityCheck() { return intValue("OTHER_AMBIGUITY_CHECK"); } /** * Find the output directory. * * @return The requested output directory. */ public static File getOutputDirectory() { return new File(stringValue("OUTPUT_DIRECTORY")); } /** * Find the sanity check value. * * @return The requested sanity check value. */ public static boolean getSanityCheck() { return booleanValue("SANITY_CHECK"); } /** * Find the static value. * * @return The requested static value. */ public static boolean getStatic() { return booleanValue("STATIC"); } /** * Should the generated code class visibility public? * * @return The class visibility public value */ public static boolean getSupportClassVisibilityPublic() { return booleanValue("SUPPORT_CLASS_VISIBILITY_PUBLIC"); } /** * Return the Token's superclass. * * @return The required base class for Token. */ public static String getTokenExtends() { return stringValue("TOKEN_EXTENDS"); } /** * Find the token manager uses parser value. * * @return The requested token manager uses parser value; */ public static boolean getTokenManagerUsesParser() { return booleanValue("TOKEN_MANAGER_USES_PARSER"); } /** * Return the Token's factory class. * * @return The required factory class for Token. */ public static String getTokenFactory() { return stringValue("TOKEN_FACTORY"); } /** * Find the unicode input value. * * @return The requested unicode input value. */ public static boolean getUnicodeInput() { return booleanValue("UNICODE_INPUT"); } /** * Find the user charstream value. * * @return The requested user charstream value. */ public static boolean getUserCharStream() { return booleanValue("USER_CHAR_STREAM"); } /** * Find the user tokenmanager value. * * @return The requested user tokenmanager value. */ public static boolean getUserTokenManager() { return booleanValue("USER_TOKEN_MANAGER"); } /** * Determine if the output language is at least the specified version. * * @param version the version to check against. E.g. 1.5 * @return true if the output version is at least the specified version. */ public static boolean jdkVersionAtLeast(final double version) { final double jdkVersion = Double.parseDouble(getJdkVersion()); // Comparing doubles is safe here, as it is two simple assignments. return jdkVersion >= version; } /** * @return the "StringBuilder" or "StringBuffer" string */ public static String stringBufOrBuild() { if (getGenerateStringBuilder()) { return "StringBuilder"; } else { return "StringBuffer"; } } } jtb-1.4.4/EDU/purdue/jtb/parser/NormalProduction.java0000644000175000017500000002065711360636752022300 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Describes JavaCC productions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class NormalProduction { /** * The line and column number of the construct that corresponds * most closely to this node. */ private int column; private int line; /** * The NonTerminal nodes which refer to this production. */ private List parents = new ArrayList(); /** * The access modifier of this production. */ private String accessMod; /** * The name of the non-terminal of this production. */ private String lhs; /** * The tokens that make up the return type of this production. */ private final List return_type_tokens = new ArrayList(); /** * The tokens that make up the parameters of this production. */ private final List parameter_list_tokens = new ArrayList(); /** * Each entry in this list is a list of tokens that represents an * exception in the throws list of this production. This list does not * include ParseException which is always thrown. */ private List> throws_list = new ArrayList>(); /** * The RHS of this production. Not used for JavaCodeProduction. */ private Expansion_ expansion; /** * This boolean flag is true if this production can expand to empty. */ private boolean emptyPossible = false; /** * A list of all non-terminals that this one can expand to without * having to consume any tokens. Also an index that shows how many * pointers exist. */ private NormalProduction[] leftExpansions = new NormalProduction[10]; int leIndex = 0; /** * The following variable is used to maintain state information for the * left-recursion determination algorithm: It is initialized to 0, and * set to -1 if this node has been visited in a pre-order walk, and then * it is set to 1 if the pre-order walk of the whole graph from this * node has been traversed. i.e., -1 indicates partially processed, * and 1 indicates fully processed. */ private int walkStatus = 0; /** * The first and last tokens from the input stream that represent this * production. */ private Token lastToken; private Token firstToken; protected String eol = System.getProperty("line.separator", "\n"); protected StringBuffer dumpPrefix(final int indent) { final StringBuffer sb = new StringBuffer(128); for (int i = 0; i < indent; i++) sb.append(" "); return sb; } protected String getSimpleName() { final String name = getClass().getName(); return name.substring(name.lastIndexOf(".") + 1); // strip the package name } public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = dumpPrefix(indent).append(System.identityHashCode(this)).append(' ').append( getSimpleName()).append( ' ').append( getLhs()); if (!alreadyDumped.contains(this)) { alreadyDumped.add(this); if (getExpansion() != null) { sb.append(eol).append(getExpansion().dump(indent + 1, alreadyDumped)); } } return sb; } /** * @param line the line to set */ public final void setLine(final int ln) { line = ln; } /** * @return the line */ public final int getLine() { return line; } /** * @param column the column to set */ public final void setColumn(final int cl) { column = cl; } /** * @return the column */ public final int getColumn() { return column; } /** * @param parents the parents to set */ final void setParents(final List pa) { parents = pa; } /** * @return the parents */ final List getParents() { return parents; } /** * @param accessMod the accessMod to set */ public final void setAccessMod(final String am) { accessMod = am; } /** * @return the accessMod */ public final String getAccessMod() { return accessMod; } /** * @param lhs the lhs to set */ public final void setLhs(final String l) { lhs = l; } /** * @return the lhs */ public final String getLhs() { return lhs; } /** * @return the return_type_tokens */ public final List getReturnTypeTokens() { return return_type_tokens; } /** * @return the parameter_list_tokens */ public final List getParameterListTokens() { return parameter_list_tokens; } /** * @param throws_list the throws_list to set */ public final void setThrowsList(final List> tl) { throws_list = tl; } /** * @return the throws_list */ public final List> getThrowsList() { return throws_list; } /** * @param expansion the expansion to set */ public final void setExpansion(final Expansion_ ex) { expansion = ex; } /** * @return the expansion */ public final Expansion_ getExpansion() { return expansion; } /** * @param emptyPossible the emptyPossible to set */ final void setEmptyPossible(final boolean ep) { emptyPossible = ep; } /** * @return the emptyPossible */ final boolean isEmptyPossible() { return emptyPossible; } /** * @param leftExpansions the leftExpansions to set */ final void setLeftExpansions(final NormalProduction[] le) { leftExpansions = le; } /** * @return the leftExpansions */ final NormalProduction[] getLeftExpansions() { return leftExpansions; } /** * @param walkStatus the walkStatus to set */ final void setWalkStatus(final int ws) { walkStatus = ws; } /** * @return the walkStatus */ final int getWalkStatus() { return walkStatus; } /** * @param firstToken the firstToken to set */ public final void setFirstToken(final Token ft) { firstToken = ft; } /** * @return the firstToken */ public final Token getFirstToken() { return firstToken; } /** * @param lastToken the lastToken to set */ public final void setLastToken(final Token lt) { lastToken = lt; } /** * @return the lastToken */ public final Token getLastToken() { return lastToken; } } jtb-1.4.4/EDU/purdue/jtb/parser/SingleCharacter.java0000644000175000017500000000477011360636752022035 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes single character descriptors in a character list. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class SingleCharacter { /** * The line and column number of the construct that corresponds * most closely to this node. */ private int column; private int line; /** * The character of this descriptor. */ public char ch; SingleCharacter() { } SingleCharacter(final char c) { ch = c; } /** * @param line the line to set */ final void setLine(final int ln) { line = ln; } /** * @return the line */ final int getLine() { return line; } /** * @param column the column to set */ final void setColumn(final int cl) { column = cl; } /** * @return the column */ final int getColumn() { return column; } } jtb-1.4.4/EDU/purdue/jtb/parser/LexGen.java0000644000175000017500000016121711360636752020161 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.List; /** * Generate lexer. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class LexGen extends JavaCCGlobals implements JavaCCParserConstants { static private java.io.PrintWriter ostr; static private String staticString; static private String tokMgrClassName; // Hashtable of vectors static Hashtable> allTpsForState = new Hashtable>(); public static int lexStateIndex = 0; static int[] kinds; public static int maxOrdinal = 1; public static String lexStateSuffix; static String[] newLexState; public static int[] lexStates; public static boolean[] ignoreCase; public static Action[] actions; public static Hashtable initStates = new Hashtable(); public static int stateSetSize; public static int maxLexStates; public static String[] lexStateName; static NfaState[] singlesToSkip; public static long[] toSkip; public static long[] toSpecial; public static long[] toMore; public static long[] toToken; public static int defaultLexState; public static RegularExpression_[] rexprs; public static int[] maxLongsReqd; public static int[] initMatch; public static int[] canMatchAnyChar; public static boolean hasEmptyMatch; public static boolean[] canLoop; public static boolean[] stateHasActions; public static boolean hasLoop = false; public static boolean[] canReachOnMore; public static boolean[] hasNfa; public static boolean[] mixed; public static NfaState initialState; public static int curKind; static boolean hasSkipActions = false; static boolean hasMoreActions = false; static boolean hasTokenActions = false; static boolean hasSpecial = false; static boolean hasSkip = false; static boolean hasMore = false; public static RegularExpression_ curRE; public static boolean keepLineCol; static void PrintClassHead() { int i, j; try { final File tmp = new File(Options.getOutputDirectory(), tokMgrClassName + ".java"); ostr = new java.io.PrintWriter( new java.io.BufferedWriter( new java.io.FileWriter(tmp), // ModMMa : performance improvements (use big BufferedWriter) // 8092 12 * 8192 ) ); final List tn = new ArrayList(toolNames); tn.add(toolName); ostr.println("/* " + getIdString(tn, tokMgrClassName + ".java") + " */"); int l = 0, kind; i = 1; for (;;) { if (cu_to_insertion_point_1.size() <= l) break; kind = cu_to_insertion_point_1.get(l).kind; if(kind == PACKAGE || kind == IMPORT) { for (; i < cu_to_insertion_point_1.size(); i++) { kind = cu_to_insertion_point_1.get(i).kind; if (kind == SEMICOLON || kind == ABSTRACT || kind == FINAL || kind == PUBLIC || kind == CLASS || kind == INTERFACE) { cline = ((cu_to_insertion_point_1.get(l))).beginLine; ccol = ((cu_to_insertion_point_1.get(l))).beginColumn; for (j = l; j < i; j++) { printToken((cu_to_insertion_point_1.get(j)), ostr); } if (kind == SEMICOLON) printToken((cu_to_insertion_point_1.get(j)), ostr); ostr.println(""); break; } } l = ++i; } else break; } ostr.println(""); ostr.println("/** Token Manager. */"); if(Options.getSupportClassVisibilityPublic()) { ostr.print("public "); } ostr.println("class " + tokMgrClassName + " implements " + cu_name + "Constants"); ostr.println("{"); // } } catch (final java.io.IOException err) { JavaCCErrors.semantic_error("Could not create file : " + tokMgrClassName + ".java\n"); throw new Error(); } if (token_mgr_decls != null && token_mgr_decls.size() > 0) { Token t = token_mgr_decls.get(0); boolean commonTokenActionSeen = false; final boolean commonTokenActionNeeded = Options.getCommonTokenAction(); printTokenSetup(token_mgr_decls.get(0)); ccol = 1; for (j = 0; j < token_mgr_decls.size(); j++) { t = token_mgr_decls.get(j); if (t.kind == IDENTIFIER && commonTokenActionNeeded && !commonTokenActionSeen) commonTokenActionSeen = t.image.equals("CommonTokenAction"); printToken(t, ostr); } ostr.println(""); if (commonTokenActionNeeded && !commonTokenActionSeen) JavaCCErrors.warning("You have the COMMON_TOKEN_ACTION option set. " + "But it appears you have not defined the method :\n"+ " " + staticString + "void CommonTokenAction(Token t)\n" + "in your TOKEN_MGR_DECLS. The generated token manager will not compile."); } else if (Options.getCommonTokenAction()) { JavaCCErrors.warning("You have the COMMON_TOKEN_ACTION option set. " + "But you have not defined the method :\n"+ " " + staticString + "void CommonTokenAction(Token t)\n" + "in your TOKEN_MGR_DECLS. The generated token manager will not compile."); } ostr.println(""); ostr.println(" /** Debug output. */"); ostr.println(" public " + staticString + " java.io.PrintStream debugStream = System.out;"); ostr.println(" /** Set debug output. */"); ostr.println(" public " + staticString + " void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }"); if(Options.getTokenManagerUsesParser() && !Options.getStatic()){ ostr.println(""); ostr.println(" /** The parser. */"); ostr.println(" public " + cu_name + " parser = null;"); } } static void DumpDebugMethods() { ostr.println(" " + staticString + " int kindCnt = 0;"); ostr.println(" protected " + staticString + " final String jjKindsForBitVector(int i, long vec)"); ostr.println(" {"); ostr.println(" String retVal = \"\";"); ostr.println(" if (i == 0)"); ostr.println(" kindCnt = 0;"); ostr.println(" for (int j = 0; j < 64; j++)"); ostr.println(" {"); ostr.println(" if ((vec & (1L << j)) != 0L)"); ostr.println(" {"); ostr.println(" if (kindCnt++ > 0)"); ostr.println(" retVal += \", \";"); ostr.println(" if (kindCnt % 5 == 0)"); ostr.println(" retVal += \"\\n \";"); ostr.println(" retVal += tokenImage[i * 64 + j];"); ostr.println(" }"); ostr.println(" }"); ostr.println(" return retVal;"); ostr.println(" }"); ostr.println(""); ostr.println(" protected " + staticString + " final String jjKindsForStateVector(" + "int lexState, int[] vec, int start, int end)"); ostr.println(" {"); ostr.println(" boolean[] kindDone = new boolean[" + maxOrdinal + "];"); ostr.println(" String retVal = \"\";"); ostr.println(" int cnt = 0;"); ostr.println(" for (int i = start; i < end; i++)"); ostr.println(" {"); ostr.println(" if (vec[i] == -1)"); ostr.println(" continue;"); ostr.println(" int[] stateSet = statesForState[curLexState][vec[i]];"); ostr.println(" for (int j = 0; j < stateSet.length; j++)"); ostr.println(" {"); ostr.println(" int state = stateSet[j];"); ostr.println(" if (!kindDone[kindForState[lexState][state]])"); ostr.println(" {"); ostr.println(" kindDone[kindForState[lexState][state]] = true;"); ostr.println(" if (cnt++ > 0)"); ostr.println(" retVal += \", \";"); ostr.println(" if (cnt % 5 == 0)"); ostr.println(" retVal += \"\\n \";"); ostr.println(" retVal += tokenImage[kindForState[lexState][state]];"); ostr.println(" }"); ostr.println(" }"); ostr.println(" }"); ostr.println(" if (cnt == 0)"); ostr.println(" return \"{ }\";"); ostr.println(" else"); ostr.println(" return \"{ \" + retVal + \" }\";"); ostr.println(" }"); ostr.println(""); } static void BuildLexStatesTable() { final Iterator it = rexprlist.iterator(); TokenProduction tp; int i; final String[] tmpLexStateName = new String[lexstate_I2S.size()]; while (it.hasNext()) { tp = it.next(); final List respecs = tp.respecs; List tps; for (i = 0; i < tp.lexStates.length; i++) { if ((tps = allTpsForState.get(tp.lexStates[i])) == null) { tmpLexStateName[maxLexStates++] = tp.lexStates[i]; allTpsForState.put(tp.lexStates[i], tps = new ArrayList()); } tps.add(tp); } if (respecs == null || respecs.size() == 0) continue; RegularExpression_ re; for (i = 0; i < respecs.size(); i++) if (maxOrdinal <= (re = (respecs.get(i)).rexp).ordinal) maxOrdinal = re.ordinal + 1; } kinds = new int[maxOrdinal]; toSkip = new long[maxOrdinal / 64 + 1]; toSpecial = new long[maxOrdinal / 64 + 1]; toMore = new long[maxOrdinal / 64 + 1]; toToken = new long[maxOrdinal / 64 + 1]; toToken[0] = 1L; actions = new Action[maxOrdinal]; actions[0] = actForEof; hasTokenActions = actForEof != null; initStates = new Hashtable(); canMatchAnyChar = new int[maxLexStates]; canLoop = new boolean[maxLexStates]; stateHasActions = new boolean[maxLexStates]; lexStateName = new String[maxLexStates]; singlesToSkip = new NfaState[maxLexStates]; System.arraycopy(tmpLexStateName, 0, lexStateName, 0, maxLexStates); for (i = 0; i < maxLexStates; i++) canMatchAnyChar[i] = -1; hasNfa = new boolean[maxLexStates]; mixed = new boolean[maxLexStates]; maxLongsReqd = new int[maxLexStates]; initMatch = new int[maxLexStates]; newLexState = new String[maxOrdinal]; newLexState[0] = nextStateForEof; hasEmptyMatch = false; lexStates = new int[maxOrdinal]; ignoreCase = new boolean[maxOrdinal]; rexprs = new RegularExpression_[maxOrdinal]; RStringLiteral.allImages = new String[maxOrdinal]; canReachOnMore = new boolean[maxLexStates]; } static int GetIndex(final String name) { for (int i = 0; i < lexStateName.length; i++) if (lexStateName[i] != null && lexStateName[i].equals(name)) return i; throw new Error(); // Should never come here } public static void AddCharToSkip(final char c, final int kind) { singlesToSkip[lexStateIndex].AddChar(c); singlesToSkip[lexStateIndex].kind = kind; } public static void start() { if (!Options.getBuildTokenManager() || Options.getUserTokenManager() || JavaCCErrors.get_error_count() > 0) return; keepLineCol = Options.getKeepLineColumn(); final List choices = new ArrayList(); Enumeration e; TokenProduction tp; int i, j; staticString = (Options.getStatic() ? "static " : ""); tokMgrClassName = cu_name + "TokenManager"; PrintClassHead(); BuildLexStatesTable(); e = allTpsForState.keys(); boolean ignoring = false; while (e.hasMoreElements()) { NfaState.ReInit(); RStringLiteral.ReInit(); final String key = e.nextElement(); lexStateIndex = GetIndex(key); lexStateSuffix = "_" + lexStateIndex; final List allTps = allTpsForState.get(key); initStates.put(key, initialState = new NfaState()); ignoring = false; singlesToSkip[lexStateIndex] = new NfaState(); singlesToSkip[lexStateIndex].dummy = true; if (key.equals("DEFAULT")) defaultLexState = lexStateIndex; for (i = 0; i < allTps.size(); i++) { tp = allTps.get(i); final int kind = tp.kind; final boolean ignore = tp.ignoreCase; final List rexps = tp.respecs; if (i == 0) ignoring = ignore; for (j = 0; j < rexps.size(); j++) { final RegExprSpec_ respec = rexps.get(j); curRE = respec.rexp; rexprs[curKind = curRE.ordinal] = curRE; lexStates[curRE.ordinal] = lexStateIndex; ignoreCase[curRE.ordinal] = ignore; if (curRE.private_rexp) { kinds[curRE.ordinal] = -1; continue; } if (curRE instanceof RStringLiteral && !((RStringLiteral)curRE).image.equals("")) { // ((RStringLiteral) curRE).GenerateDfa(ostr, curRE.ordinal); ((RStringLiteral) curRE).GenerateDfa(); if (i != 0 && !mixed[lexStateIndex] && ignoring != ignore) mixed[lexStateIndex] = true; } else if (curRE.CanMatchAnyChar()) { if (canMatchAnyChar[lexStateIndex] == -1 || canMatchAnyChar[lexStateIndex] > curRE.ordinal) canMatchAnyChar[lexStateIndex] = curRE.ordinal; } else { Nfa temp; if (curRE instanceof RChoice) choices.add(curRE); temp = curRE.GenerateNfa(ignore); temp.end.isFinal = true; temp.end.kind = curRE.ordinal; initialState.AddMove(temp.start); } if (kinds.length < curRE.ordinal) { final int[] tmp = new int[curRE.ordinal + 1]; System.arraycopy(kinds, 0, tmp, 0, kinds.length); kinds = tmp; } //System.out.println(" ordina : " + curRE.ordinal); kinds[curRE.ordinal] = kind; if (respec.nextState != null && !respec.nextState.equals(lexStateName[lexStateIndex])) newLexState[curRE.ordinal] = respec.nextState; if (respec.act != null && respec.act.getActionTokens() != null && respec.act.getActionTokens().size() > 0) actions[curRE.ordinal] = respec.act; switch(kind) { case TokenProduction.SPECIAL : hasSkipActions |= (actions[curRE.ordinal] != null) || (newLexState[curRE.ordinal] != null); hasSpecial = true; toSpecial[curRE.ordinal / 64] |= 1L << (curRE.ordinal % 64); toSkip[curRE.ordinal / 64] |= 1L << (curRE.ordinal % 64); break; case TokenProduction.SKIP : hasSkipActions |= (actions[curRE.ordinal] != null); hasSkip = true; toSkip[curRE.ordinal / 64] |= 1L << (curRE.ordinal % 64); break; case TokenProduction.MORE : hasMoreActions |= (actions[curRE.ordinal] != null); hasMore = true; toMore[curRE.ordinal / 64] |= 1L << (curRE.ordinal % 64); if (newLexState[curRE.ordinal] != null) canReachOnMore[GetIndex(newLexState[curRE.ordinal])] = true; else canReachOnMore[lexStateIndex] = true; break; case TokenProduction.TOKEN : hasTokenActions |= (actions[curRE.ordinal] != null); toToken[curRE.ordinal / 64] |= 1L << (curRE.ordinal % 64); break; } } } // Generate a static block for initializing the nfa transitions NfaState.ComputeClosures(); for (i = 0; i < initialState.epsilonMoves.size(); i++) (initialState.epsilonMoves.elementAt(i)).GenerateCode(); hasNfa[lexStateIndex] = (NfaState.generatedStates != 0); if (NfaState.generatedStates != 0) { initialState.GenerateCode(); // initialState.GenerateInitMoves(ostr); initialState.GenerateInitMoves(); } if (initialState.kind != Integer.MAX_VALUE && initialState.kind != 0) { if ((toSkip[initialState.kind / 64] & (1L << initialState.kind)) != 0L || (toSpecial[initialState.kind / 64] & (1L << initialState.kind)) != 0L) hasSkipActions = true; else if ((toMore[initialState.kind / 64] & (1L << initialState.kind)) != 0L) hasMoreActions = true; else hasTokenActions = true; if (initMatch[lexStateIndex] == 0 || initMatch[lexStateIndex] > initialState.kind) { initMatch[lexStateIndex] = initialState.kind; hasEmptyMatch = true; } } else if (initMatch[lexStateIndex] == 0) initMatch[lexStateIndex] = Integer.MAX_VALUE; RStringLiteral.FillSubString(); if (hasNfa[lexStateIndex] && !mixed[lexStateIndex]) RStringLiteral.GenerateNfaStartStates(ostr, initialState); RStringLiteral.DumpDfaCode(ostr); if (hasNfa[lexStateIndex]) NfaState.DumpMoveNfa(ostr); if (stateSetSize < NfaState.generatedStates) stateSetSize = NfaState.generatedStates; } for (i = 0; i < choices.size(); i++) ((RChoice)choices.get(i)).CheckUnmatchability(); NfaState.DumpStateSets(ostr); CheckEmptyStringMatch(); NfaState.DumpNonAsciiMoveMethods(ostr); RStringLiteral.DumpStrLiteralImages(ostr); DumpStaticVarDeclarations(); DumpFillToken(); DumpGetNextToken(); if (Options.getDebugTokenManager()) { NfaState.DumpStatesForKind(ostr); DumpDebugMethods(); } if (hasLoop) { ostr.println(staticString + "int[] jjemptyLineNo = new int[" + maxLexStates + "];"); ostr.println(staticString + "int[] jjemptyColNo = new int[" + maxLexStates + "];"); ostr.println(staticString + "boolean[] jjbeenHere = new boolean[" + maxLexStates + "];"); } if (hasSkipActions) DumpSkipActions(); if (hasMoreActions) DumpMoreActions(); if (hasTokenActions) DumpTokenActions(); NfaState.PrintBoilerPlate(ostr); ostr.println(/*{*/ "}"); ostr.close(); } static void CheckEmptyStringMatch() { int i, j, k, len; final boolean[] seen = new boolean[maxLexStates]; final boolean[] done = new boolean[maxLexStates]; String cycle; String reList; Outer: for (i = 0; i < maxLexStates; i++) { if (done[i] || initMatch[i] == 0 || initMatch[i] == Integer.MAX_VALUE || canMatchAnyChar[i] != -1) continue; done[i] = true; len = 0; cycle = ""; reList = ""; for (k = 0; k < maxLexStates; k++) seen[k] = false; j = i; seen[i] = true; cycle += lexStateName[j] + "-->"; while (newLexState[initMatch[j]] != null) { cycle += newLexState[initMatch[j]]; if (seen[j = GetIndex(newLexState[initMatch[j]])]) break; cycle += "-->"; done[j] = true; seen[j] = true; if (initMatch[j] == 0 || initMatch[j] == Integer.MAX_VALUE || canMatchAnyChar[j] != -1) continue Outer; if (len != 0) reList += "; "; reList += "line " + rexprs[initMatch[j]].getLine() + ", column " + rexprs[initMatch[j]].getColumn(); len++; } if (newLexState[initMatch[j]] == null) cycle += lexStateName[lexStates[initMatch[j]]]; for (k = 0; k < maxLexStates; k++) canLoop[k] |= seen[k]; hasLoop = true; if (len == 0) JavaCCErrors.warning(rexprs[initMatch[i]], "Regular expression" + ((rexprs[initMatch[i]].label.equals("")) ? "" : (" for " + rexprs[initMatch[i]].label)) + " can be matched by the empty string (\"\") in lexical state " + lexStateName[i] + ". This can result in an endless loop of " + "empty string matches."); else { JavaCCErrors.warning(rexprs[initMatch[i]], "Regular expression" + ((rexprs[initMatch[i]].label.equals("")) ? "" : (" for " + rexprs[initMatch[i]].label)) + " can be matched by the empty string (\"\") in lexical state " + lexStateName[i] + ". This regular expression along with the " + "regular expressions at " + reList + " forms the cycle \n " + cycle + "\ncontaining regular expressions with empty matches." + " This can result in an endless loop of empty string matches."); } } } static void PrintArrayInitializer(final int noElems) { ostr.print("{"); for (int i = 0; i < noElems; i++) { if (i % 25 == 0) ostr.print("\n "); ostr.print("0, "); } ostr.println("\n};"); } static void DumpStaticVarDeclarations() { int i; String charStreamName; ostr.println(""); ostr.println("/** Lexer state names. */"); ostr.println("public static final String[] lexStateNames = {"); for (i = 0; i < maxLexStates; i++) ostr.println(" \"" + lexStateName[i] + "\","); ostr.println("};"); if (maxLexStates > 1) { ostr.println(""); ostr.println("/** Lex State array. */"); ostr.print("public static final int[] jjnewLexState = {"); for (i = 0; i < maxOrdinal; i++) { if (i % 25 == 0) ostr.print("\n "); if (newLexState[i] == null) ostr.print("-1, "); else ostr.print(GetIndex(newLexState[i]) + ", "); } ostr.println("\n};"); } if (hasSkip || hasMore || hasSpecial) { // Bit vector for TOKEN ostr.print("static final long[] jjtoToken = {"); for (i = 0; i < maxOrdinal / 64 + 1; i++) { if (i % 4 == 0) ostr.print("\n "); ostr.print("0x" + Long.toHexString(toToken[i]) + "L, "); } ostr.println("\n};"); } if (hasSkip || hasSpecial) { // Bit vector for SKIP ostr.print("static final long[] jjtoSkip = {"); for (i = 0; i < maxOrdinal / 64 + 1; i++) { if (i % 4 == 0) ostr.print("\n "); ostr.print("0x" + Long.toHexString(toSkip[i]) + "L, "); } ostr.println("\n};"); } if (hasSpecial) { // Bit vector for SPECIAL ostr.print("static final long[] jjtoSpecial = {"); for (i = 0; i < maxOrdinal / 64 + 1; i++) { if (i % 4 == 0) ostr.print("\n "); ostr.print("0x" + Long.toHexString(toSpecial[i]) + "L, "); } ostr.println("\n};"); } if (hasMore) { // Bit vector for MORE ostr.print("static final long[] jjtoMore = {"); for (i = 0; i < maxOrdinal / 64 + 1; i++) { if (i % 4 == 0) ostr.print("\n "); ostr.print("0x" + Long.toHexString(toMore[i]) + "L, "); } ostr.println("\n};"); } if (Options.getUserCharStream()) charStreamName = "CharStream"; else { if (Options.getJavaUnicodeEscape()) charStreamName = "JavaCharStream"; else charStreamName = "SimpleCharStream"; } ostr.println(staticString + "protected " + charStreamName + " input_stream;"); ostr.println(staticString + "private final int[] jjrounds = " + "new int[" + stateSetSize + "];"); ostr.println(staticString + "private final int[] jjstateSet = " + "new int[" + (2 * stateSetSize) + "];"); if (hasMoreActions || hasSkipActions || hasTokenActions) { ostr.println("private " + staticString + "final " + Options.stringBufOrBuild() + " jjimage = new " + Options.stringBufOrBuild() + "();"); ostr.println("private " + staticString + Options.stringBufOrBuild() + " image = jjimage;"); ostr.println("private " + staticString + "int jjimageLen;"); ostr.println("private " + staticString + "int lengthOfMatch;"); } ostr.println(staticString + "protected char curChar;"); if(Options.getTokenManagerUsesParser() && !Options.getStatic()){ ostr.println(""); ostr.println("/** Constructor with parser. */"); ostr.println("public " + tokMgrClassName + "(" + cu_name + " parserArg, " + charStreamName + " stream){"); ostr.println(" parser = parserArg;"); } else { ostr.println("/** Constructor. */"); ostr.println("public " + tokMgrClassName + "(" + charStreamName + " stream){"); } if (Options.getStatic() && !Options.getUserCharStream()) { ostr.println(" if (input_stream != null)"); ostr.println(" throw new TokenMgrError(\"ERROR: Second call to constructor of static lexer. " + "You must use ReInit() to initialize the static variables.\", TokenMgrError.STATIC_LEXER_ERROR);"); } else if (!Options.getUserCharStream()) { if (Options.getJavaUnicodeEscape()) ostr.println(" if (JavaCharStream.staticFlag)"); else ostr.println(" if (SimpleCharStream.staticFlag)"); ostr.println(" throw new Error(\"ERROR: Cannot use a static CharStream class with a " + "non-static lexical analyzer.\");"); } ostr.println(" input_stream = stream;"); ostr.println("}"); if(Options.getTokenManagerUsesParser() && !Options.getStatic()){ ostr.println(""); ostr.println("/** Constructor with parser. */"); ostr.println("public " + tokMgrClassName + "(" + cu_name + " parserArg, " + charStreamName + " stream, int lexState){"); ostr.println(" this(parserArg, stream);"); } else { ostr.println(""); ostr.println("/** Constructor. */"); ostr.println("public " + tokMgrClassName + "(" + charStreamName + " stream, int lexState){"); ostr.println(" this(stream);"); } ostr.println(" SwitchTo(lexState);"); ostr.println("}"); // Reinit method for reinitializing the parser (for static parsers). ostr.println(""); ostr.println("/** Reinitialise parser. */"); ostr.println(staticString + "public void ReInit(" + charStreamName + " stream)"); ostr.println("{"); ostr.println(" jjmatchedPos = jjnewStateCnt = 0;"); ostr.println(" curLexState = defaultLexState;"); ostr.println(" input_stream = stream;"); ostr.println(" ReInitRounds();"); ostr.println("}"); // Method to reinitialize the jjrounds array. ostr.println(staticString + "private void ReInitRounds()"); ostr.println("{"); ostr.println(" int i;"); ostr.println(" jjround = 0x" + Integer.toHexString(Integer.MIN_VALUE + 1)+ ";"); ostr.println(" for (i = " + stateSetSize + "; i-- > 0;)"); ostr.println(" jjrounds[i] = 0x" + Integer.toHexString(Integer.MIN_VALUE) + ";"); ostr.println("}"); // Reinit method for reinitializing the parser (for static parsers). ostr.println(""); ostr.println("/** Reinitialise parser. */"); ostr.println(staticString + "public void ReInit(" + charStreamName + " stream, int lexState)"); ostr.println("{"); ostr.println(" ReInit(stream);"); ostr.println(" SwitchTo(lexState);"); ostr.println("}"); ostr.println(""); ostr.println("/** Switch to specified lex state. */"); ostr.println(staticString + "public void SwitchTo(int lexState)"); ostr.println("{"); ostr.println(" if (lexState >= " + lexStateName.length + " || lexState < 0)"); ostr.println(" throw new TokenMgrError(\"Error: Ignoring invalid lexical state : \"" + " + lexState + \". State unchanged.\", TokenMgrError.INVALID_LEXICAL_STATE);"); ostr.println(" else"); ostr.println(" curLexState = lexState;"); ostr.println("}"); ostr.println(""); } // Assumes l != 0L static char MaxChar(final long l) { for (int i = 64; i-- > 0; ) if ((l & (1L << i)) != 0L) return (char)i; return 0xffff; } static void DumpFillToken() { final double tokenVersion = JavaFiles.getVersion("Token.java"); final boolean hasBinaryNewToken = tokenVersion > 4.09; ostr.println(staticString + "protected Token jjFillToken()"); ostr.println("{"); ostr.println(" final Token t;"); ostr.println(" final String curTokenImage;"); if (keepLineCol) { ostr.println(" final int startLine;"); ostr.println(" final int endLine;"); ostr.println(" final int beginColumn;"); ostr.println(" final int endColumn;"); } if (hasEmptyMatch) { ostr.println(" if (jjmatchedPos < 0)"); ostr.println(" {"); ostr.println(" if (image == null)"); ostr.println(" curTokenImage = \"\";"); ostr.println(" else"); ostr.println(" curTokenImage = image.toString();"); if (keepLineCol) { ostr.println(" startLine = endLine = input_stream.getBeginLine();"); ostr.println(" beginColumn = endColumn = input_stream.getBeginColumn();"); } ostr.println(" }"); ostr.println(" else"); ostr.println(" {"); ostr.println(" String im = jjstrLiteralImages[jjmatchedKind];"); ostr.println(" curTokenImage = (im == null) ? input_stream.GetImage() : im;"); if (keepLineCol) { ostr.println(" startLine = input_stream.getBeginLine();"); ostr.println(" beginColumn = input_stream.getBeginColumn();"); ostr.println(" endLine = input_stream.getEndLine();"); ostr.println(" endColumn = input_stream.getEndColumn();"); } ostr.println(" }"); } else { ostr.println(" String im = jjstrLiteralImages[jjmatchedKind];"); ostr.println(" curTokenImage = (im == null) ? input_stream.GetImage() : im;"); if (keepLineCol) { ostr.println(" startLine = input_stream.getBeginLine();"); ostr.println(" beginColumn = input_stream.getBeginColumn();"); ostr.println(" endLine = input_stream.getEndLine();"); ostr.println(" endColumn = input_stream.getEndColumn();"); } } if (Options.getTokenFactory().length() > 0) { ostr.println(" t = " + Options.getTokenFactory() + ".newToken(jjmatchedKind, curTokenImage);"); } else if (hasBinaryNewToken) { ostr.println(" t = Token.newToken(jjmatchedKind, curTokenImage);"); } else { ostr.println(" t = Token.newToken(jjmatchedKind);"); ostr.println(" t.kind = jjmatchedKind;"); ostr.println(" t.image = curTokenImage;"); } if (keepLineCol) { ostr.println(""); ostr.println(" t.beginLine = startLine;"); ostr.println(" t.endLine = endLine;"); ostr.println(" t.beginColumn = beginColumn;"); ostr.println(" t.endColumn = endColumn;"); } ostr.println(""); ostr.println(" return t;"); ostr.println("}"); } static void DumpGetNextToken() { int i; ostr.println(""); ostr.println(staticString + "int curLexState = " + defaultLexState + ";"); ostr.println(staticString + "int defaultLexState = " + defaultLexState + ";"); ostr.println(staticString + "int jjnewStateCnt;"); ostr.println(staticString + "int jjround;"); ostr.println(staticString + "int jjmatchedPos;"); ostr.println(staticString + "int jjmatchedKind;"); ostr.println(""); ostr.println("/** Get the next Token. */"); ostr.println("public " + staticString + "Token getNextToken()" + " "); ostr.println("{"); if (hasSpecial) { ostr.println(" Token specialToken = null;"); } ostr.println(" Token matchedToken;"); ostr.println(" int curPos = 0;"); ostr.println(""); ostr.println(" EOFLoop :\n for (;;)"); ostr.println(" {"); ostr.println(" try"); ostr.println(" {"); ostr.println(" curChar = input_stream.BeginToken();"); ostr.println(" }"); ostr.println(" catch(java.io.IOException e)"); ostr.println(" {"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\"Returning the token.\");"); ostr.println(" jjmatchedKind = 0;"); ostr.println(" matchedToken = jjFillToken();"); if (hasSpecial) ostr.println(" matchedToken.specialToken = specialToken;"); if (nextStateForEof != null || actForEof != null) ostr.println(" TokenLexicalActions(matchedToken);"); if (Options.getCommonTokenAction()) ostr.println(" CommonTokenAction(matchedToken);"); ostr.println(" return matchedToken;"); ostr.println(" }"); if (hasMoreActions || hasSkipActions || hasTokenActions) { ostr.println(" image = jjimage;"); ostr.println(" image.setLength(0);"); ostr.println(" jjimageLen = 0;"); } ostr.println(""); String prefix = ""; if (hasMore) { ostr.println(" for (;;)"); ostr.println(" {"); prefix = " "; } String endSwitch = ""; String caseStr = ""; // this also sets up the start state of the nfa if (maxLexStates > 1) { ostr.println(prefix + " switch(curLexState)"); ostr.println(prefix + " {"); endSwitch = prefix + " }"; caseStr = prefix + " case "; prefix += " "; } prefix += " "; for(i = 0; i < maxLexStates; i++) { if (maxLexStates > 1) ostr.println(caseStr + i + ":"); if (singlesToSkip[i].HasTransitions()) { // added the backup(0) to make JIT happy ostr.println(prefix + "try { input_stream.backup(0);"); if (singlesToSkip[i].asciiMoves[0] != 0L && singlesToSkip[i].asciiMoves[1] != 0L) { ostr.println(prefix + " while ((curChar < 64" + " && (0x" + Long.toHexString(singlesToSkip[i].asciiMoves[0]) + "L & (1L << curChar)) != 0L) || \n" + prefix + " (curChar >> 6) == 1" + " && (0x" + Long.toHexString(singlesToSkip[i].asciiMoves[1]) + "L & (1L << (curChar & 077))) != 0L)"); } else if (singlesToSkip[i].asciiMoves[1] == 0L) { ostr.println(prefix + " while (curChar <= " + (int)MaxChar(singlesToSkip[i].asciiMoves[0]) + " && (0x" + Long.toHexString(singlesToSkip[i].asciiMoves[0]) + "L & (1L << curChar)) != 0L)"); } else if (singlesToSkip[i].asciiMoves[0] == 0L) { ostr.println(prefix + " while (curChar > 63 && curChar <= " + (MaxChar(singlesToSkip[i].asciiMoves[1]) + 64) + " && (0x" + Long.toHexString(singlesToSkip[i].asciiMoves[1]) + "L & (1L << (curChar & 077))) != 0L)"); } if (Options.getDebugTokenManager()) { ostr.println(prefix + "{"); ostr.println(" debugStream.println(" + (maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Skipping character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \")\");"); } ostr.println(prefix + " curChar = input_stream.BeginToken();"); if (Options.getDebugTokenManager()) ostr.println(prefix + "}"); ostr.println(prefix + "}"); ostr.println(prefix + "catch (java.io.IOException e1) { continue EOFLoop; }"); } if (initMatch[i] != Integer.MAX_VALUE && initMatch[i] != 0) { if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\" Matched the empty string as \" + tokenImage[" + initMatch[i] + "] + \" token.\");"); ostr.println(prefix + "jjmatchedKind = " + initMatch[i] + ";"); ostr.println(prefix + "jjmatchedPos = -1;"); ostr.println(prefix + "curPos = 0;"); } else { ostr.println(prefix + "jjmatchedKind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); ostr.println(prefix + "jjmatchedPos = 0;"); } if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(" + (maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(prefix + "curPos = jjMoveStringLiteralDfa0_" + i + "();"); if (canMatchAnyChar[i] != -1) { if (initMatch[i] != Integer.MAX_VALUE && initMatch[i] != 0) ostr.println(prefix + "if (jjmatchedPos < 0 || (jjmatchedPos == 0 && jjmatchedKind > " + canMatchAnyChar[i] + "))"); else ostr.println(prefix + "if (jjmatchedPos == 0 && jjmatchedKind > " + canMatchAnyChar[i] + ")"); ostr.println(prefix + "{"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\" Current character matched as a \" + tokenImage[" + canMatchAnyChar[i] + "] + \" token.\");"); ostr.println(prefix + " jjmatchedKind = " + canMatchAnyChar[i] + ";"); if (initMatch[i] != Integer.MAX_VALUE && initMatch[i] != 0) ostr.println(prefix + " jjmatchedPos = 0;"); ostr.println(prefix + "}"); } if (maxLexStates > 1) ostr.println(prefix + "break;"); } if (maxLexStates > 1) ostr.println(endSwitch); else if (maxLexStates == 0) ostr.println(" jjmatchedKind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); if (maxLexStates > 1) prefix = " "; else prefix = ""; if (maxLexStates > 0) { ostr.println(prefix + " if (jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr.println(prefix + " {"); ostr.println(prefix + " if (jjmatchedPos + 1 < curPos)"); if (Options.getDebugTokenManager()) { ostr.println(prefix + " {"); ostr.println(prefix + " debugStream.println(" + "\" Putting back \" + (curPos - jjmatchedPos - 1) + \" characters into the input stream.\");"); } ostr.println(prefix + " input_stream.backup(curPos - jjmatchedPos - 1);"); if (Options.getDebugTokenManager()) ostr.println(prefix + " }"); if (Options.getDebugTokenManager()) { if (Options.getJavaUnicodeEscape() || Options.getUserCharStream()) ostr.println(" debugStream.println(" + "\"****** FOUND A \" + tokenImage[jjmatchedKind] + \" MATCH " + "(\" + TokenMgrError.addEscapes(new String(input_stream.GetSuffix(jjmatchedPos + 1))) + " + "\") ******\\n\");"); else ostr.println(" debugStream.println(" + "\"****** FOUND A \" + tokenImage[jjmatchedKind] + \" MATCH " + "(\" + TokenMgrError.addEscapes(new String(input_stream.GetSuffix(jjmatchedPos + 1))) + " + "\") ******\\n\");"); } if (hasSkip || hasMore || hasSpecial) { ostr.println(prefix + " if ((jjtoToken[jjmatchedKind >> 6] & " + "(1L << (jjmatchedKind & 077))) != 0L)"); ostr.println(prefix + " {"); } ostr.println(prefix + " matchedToken = jjFillToken();"); if (hasSpecial) ostr.println(prefix + " matchedToken.specialToken = specialToken;"); if (hasTokenActions) ostr.println(prefix + " TokenLexicalActions(matchedToken);"); if (maxLexStates > 1) { ostr.println(" if (jjnewLexState[jjmatchedKind] != -1)"); ostr.println(prefix + " curLexState = jjnewLexState[jjmatchedKind];"); } if (Options.getCommonTokenAction()) ostr.println(prefix + " CommonTokenAction(matchedToken);"); ostr.println(prefix + " return matchedToken;"); if (hasSkip || hasMore || hasSpecial) { ostr.println(prefix + " }"); if (hasSkip || hasSpecial) { if (hasMore) { ostr.println(prefix + " else if ((jjtoSkip[jjmatchedKind >> 6] & " + "(1L << (jjmatchedKind & 077))) != 0L)"); } else ostr.println(prefix + " else"); ostr.println(prefix + " {"); if (hasSpecial) { ostr.println(prefix + " if ((jjtoSpecial[jjmatchedKind >> 6] & " + "(1L << (jjmatchedKind & 077))) != 0L)"); ostr.println(prefix + " {"); ostr.println(prefix + " matchedToken = jjFillToken();"); ostr.println(prefix + " if (specialToken == null)"); ostr.println(prefix + " specialToken = matchedToken;"); ostr.println(prefix + " else"); ostr.println(prefix + " {"); ostr.println(prefix + " matchedToken.specialToken = specialToken;"); ostr.println(prefix + " specialToken = (specialToken.next = matchedToken);"); ostr.println(prefix + " }"); if (hasSkipActions) ostr.println(prefix + " SkipLexicalActions(matchedToken);"); ostr.println(prefix + " }"); if (hasSkipActions) { ostr.println(prefix + " else"); ostr.println(prefix + " SkipLexicalActions(null);"); } } else if (hasSkipActions) ostr.println(prefix + " SkipLexicalActions(null);"); if (maxLexStates > 1) { ostr.println(" if (jjnewLexState[jjmatchedKind] != -1)"); ostr.println(prefix + " curLexState = jjnewLexState[jjmatchedKind];"); } ostr.println(prefix + " continue EOFLoop;"); ostr.println(prefix + " }"); } if (hasMore) { if (hasMoreActions) ostr.println(prefix + " MoreLexicalActions();"); else if (hasSkipActions || hasTokenActions) ostr.println(prefix + " jjimageLen += jjmatchedPos + 1;"); if (maxLexStates > 1) { ostr.println(" if (jjnewLexState[jjmatchedKind] != -1)"); ostr.println(prefix + " curLexState = jjnewLexState[jjmatchedKind];"); } ostr.println(prefix + " curPos = 0;"); ostr.println(prefix + " jjmatchedKind = 0x" + Integer.toHexString(Integer.MAX_VALUE) + ";"); ostr.println(prefix + " try {"); ostr.println(prefix + " curChar = input_stream.readChar();"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(" + (maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(prefix + " continue;"); ostr.println(prefix + " }"); ostr.println(prefix + " catch (java.io.IOException e1) { }"); } } ostr.println(prefix + " }"); ostr.println(prefix + " int error_line = input_stream.getEndLine();"); ostr.println(prefix + " int error_column = input_stream.getEndColumn();"); ostr.println(prefix + " String error_after = null;"); ostr.println(prefix + " boolean EOFSeen = false;"); ostr.println(prefix + " try { input_stream.readChar(); input_stream.backup(1); }"); ostr.println(prefix + " catch (java.io.IOException e1) {"); ostr.println(prefix + " EOFSeen = true;"); ostr.println(prefix + " error_after = curPos <= 1 ? \"\" : input_stream.GetImage();"); ostr.println(prefix + " if (curChar == '\\n' || curChar == '\\r') {"); ostr.println(prefix + " error_line++;"); ostr.println(prefix + " error_column = 0;"); ostr.println(prefix + " }"); ostr.println(prefix + " else"); ostr.println(prefix + " error_column++;"); ostr.println(prefix + " }"); ostr.println(prefix + " if (!EOFSeen) {"); ostr.println(prefix + " input_stream.backup(1);"); ostr.println(prefix + " error_after = curPos <= 1 ? \"\" : input_stream.GetImage();"); ostr.println(prefix + " }"); ostr.println(prefix + " throw new TokenMgrError(" + "EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);"); } if (hasMore) ostr.println(prefix + " }"); ostr.println(" }"); ostr.println("}"); ostr.println(""); } public static void DumpSkipActions() { Action act; ostr.println(staticString + "void SkipLexicalActions(Token matchedToken)"); ostr.println("{"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (int i = 0; i < maxOrdinal; i++) { if ((toSkip[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = actions[i]) == null || act.getActionTokens() == null || act.getActionTokens().size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() &&"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError(" + "(\"Error: Bailing out of infinite loop caused by repeated empty string matches " + "at line \" + input_stream.getBeginLine() + \", " + "column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = actions[i]) == null || act.getActionTokens().size() == 0) break; ostr.print( " image.append"); if (RStringLiteral.allImages[i] != null) { ostr.println("(jjstrLiteralImages[" + i + "]);"); ostr.println(" lengthOfMatch = jjstrLiteralImages[" + i + "].length();"); } else { ostr.println("(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));"); } printTokenSetup(act.getActionTokens().get(0)); ccol = 1; for (int j = 0; j < act.getActionTokens().size(); j++) printToken(act.getActionTokens().get(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default :"); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void DumpMoreActions() { Action act; ostr.println(staticString + "void MoreLexicalActions()"); ostr.println("{"); ostr.println(" jjimageLen += (lengthOfMatch = jjmatchedPos + 1);"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (int i = 0; i < maxOrdinal; i++) { if ((toMore[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = actions[i]) == null || act.getActionTokens() == null || act.getActionTokens().size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() &&"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError(" + "(\"Error: Bailing out of infinite loop caused by repeated empty string matches " + "at line \" + input_stream.getBeginLine() + \", " + "column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = actions[i]) == null || act.getActionTokens().size() == 0) { break; } ostr.print( " image.append"); if (RStringLiteral.allImages[i] != null) ostr.println("(jjstrLiteralImages[" + i + "]);"); else ostr.println("(input_stream.GetSuffix(jjimageLen));"); ostr.println(" jjimageLen = 0;"); printTokenSetup(act.getActionTokens().get(0)); ccol = 1; for (int j = 0; j < act.getActionTokens().size(); j++) printToken(act.getActionTokens().get(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default :"); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void DumpTokenActions() { Action act; int i; ostr.println(staticString + "void TokenLexicalActions(Token matchedToken)"); ostr.println("{"); ostr.println(" switch(jjmatchedKind)"); ostr.println(" {"); Outer: for (i = 0; i < maxOrdinal; i++) { if ((toToken[i / 64] & (1L << (i % 64))) == 0L) continue; for (;;) { if (((act = actions[i]) == null || act.getActionTokens() == null || act.getActionTokens().size() == 0) && !canLoop[lexStates[i]]) continue Outer; ostr.println(" case " + i + " :"); if (initMatch[lexStates[i]] == i && canLoop[lexStates[i]]) { ostr.println(" if (jjmatchedPos == -1)"); ostr.println(" {"); ostr.println(" if (jjbeenHere[" + lexStates[i] + "] &&"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] == input_stream.getBeginLine() &&"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] == input_stream.getBeginColumn())"); ostr.println(" throw new TokenMgrError(" + "(\"Error: Bailing out of infinite loop caused by repeated empty string matches " + "at line \" + input_stream.getBeginLine() + \", " + "column \" + input_stream.getBeginColumn() + \".\"), TokenMgrError.LOOP_DETECTED);"); ostr.println(" jjemptyLineNo[" + lexStates[i] + "] = input_stream.getBeginLine();"); ostr.println(" jjemptyColNo[" + lexStates[i] + "] = input_stream.getBeginColumn();"); ostr.println(" jjbeenHere[" + lexStates[i] + "] = true;"); ostr.println(" }"); } if ((act = actions[i]) == null || act.getActionTokens().size() == 0) break; if (i == 0) { ostr.println(" image.setLength(0);"); // For EOF no image is there } else { ostr.print( " image.append"); if (RStringLiteral.allImages[i] != null) { ostr.println("(jjstrLiteralImages[" + i + "]);"); ostr.println(" lengthOfMatch = jjstrLiteralImages[" + i + "].length();"); } else { ostr.println("(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));"); } } printTokenSetup(act.getActionTokens().get(0)); ccol = 1; for (int j = 0; j < act.getActionTokens().size(); j++) printToken(act.getActionTokens().get(j), ostr); ostr.println(""); break; } ostr.println(" break;"); } ostr.println(" default :"); ostr.println(" break;"); ostr.println(" }"); ostr.println("}"); } public static void reInit() { ostr = null; staticString = null; tokMgrClassName = null; allTpsForState = new Hashtable>(); lexStateIndex = 0; kinds = null; maxOrdinal = 1; lexStateSuffix = null; newLexState = null; lexStates = null; ignoreCase = null; actions = null; initStates = new Hashtable(); stateSetSize = 0; maxLexStates = 0; lexStateName = null; singlesToSkip = null; toSkip = null; toSpecial = null; toMore = null; toToken = null; defaultLexState = 0; rexprs = null; maxLongsReqd = null; initMatch = null; canMatchAnyChar = null; hasEmptyMatch = false; canLoop = null; stateHasActions = null; hasLoop = false; canReachOnMore = null; hasNfa = null; mixed = null; initialState = null; curKind = 0; hasSkipActions = false; hasMoreActions = false; hasTokenActions = false; hasSpecial = false; hasSkip = false; hasMore = false; curRE = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/CharacterRange.java0000644000175000017500000000633511360636752021647 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes character range descriptors in a character list. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class CharacterRange { /** * The line and column number of the construct that corresponds * most closely to this node. */ private int column; private int line; /** * The leftmost and the rightmost characters in this character range. */ private char right; private char left; CharacterRange() { } CharacterRange(final char l, final char r) { if (l > r) JavaCCErrors .semantic_error(this, "Invalid range : \"" + (int) l + "\" - \"" + (int) r + "\". First character shoud be less than or equal to the second one in a range."); setLeft(l); setRight(r); } /** * @param line the line to set */ final void setLine(final int ln) { line = ln; } /** * @return the line */ final int getLine() { return line; } /** * @param column the column to set */ final void setColumn(final int cl) { column = cl; } /** * @return the column */ final int getColumn() { return column; } /** * @param left the left to set */ public final void setLeft(final char lf) { left = lf; } /** * @return the left */ public final char getLeft() { return left; } /** * @param right the right to set */ public final void setRight(final char rg) { right = rg; } /** * @return the right */ public final char getRight() { return right; } } jtb-1.4.4/EDU/purdue/jtb/parser/Token.java0000644000175000017500000001104411416555666020055 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.2.s.m */ /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package EDU.purdue.jtb.parser; /** * Describes the input token stream. * ModMMa : updated for GTToken */ public class Token implements java.io.Serializable { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** The line number of the first character of this Token. */ public int beginLine; /** The column number of the first character of this Token. */ public int beginColumn; /** The line number of the last character of this Token. */ public int endLine; /** The column number of the last character of this Token. */ public int endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * An optional attribute value of the Token. * Tokens which are not used as syntactic sugar will often contain * meaningful values that will be used later on by the compiler or * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. */ public Object getValue() { return null; } /** * No-argument constructor */ public Token() { /* empty */ } /** * Constructs a new token for the specified Image. */ public Token(int ki) { this(ki, null); } /** * Constructs a new token for the specified Image and Kind. */ public Token(int ki, String im) { kind = ki; image = im; } /** * Returns the image. */ @Override public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simply add something like : * * case MyParserConstants.ID : return new IDToken(ofKind, image); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind, String image) { switch(ofKind) { default : return new Token(ofKind, image); case JTBParserConstants.RUNSIGNEDSHIFT: case JTBParserConstants.RSIGNEDSHIFT: case JTBParserConstants.GT: return new GTToken(ofKind, image); } } public static final Token newToken(int ofKind) { return newToken(ofKind, null); } /** * Greater than Token. */ public static class GTToken extends Token { public GTToken(int ki, String im) { super(ki, im); } int realKind = JTBParserConstants.GT; } } /* JavaCC - OriginalChecksum=6121002dddb7374c22bf7aa2e798f51a (do not edit this line) */ jtb-1.4.4/EDU/purdue/jtb/parser/ZeroOrOne.java0000644000175000017500000000523411360636752020655 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.Set; /** * Describes zero-or-one expansions (e.g., [foo], foo?). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class ZeroOrOne extends Expansion_ { /** * The expansion which is repeated zero or one times. */ public Expansion_ expansion; public ZeroOrOne() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.ZERO_OR_ONE; } public ZeroOrOne(final Token t, final Expansion_ e) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(t.beginLine); this.setColumn(t.beginColumn); this.expansion = e; e.parent = this; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); if (alreadyDumped.contains(this)) return sb; alreadyDumped.add(this); sb.append(eol).append(expansion.dump(indent + 1, alreadyDumped)); return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/REndOfFile.java0000644000175000017500000000367211360636752020714 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes the EOF regular expression * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class REndOfFile extends RegularExpression_ { @Override public Nfa GenerateNfa(@SuppressWarnings("unused") final boolean ignoreCase) { return null; } } jtb-1.4.4/EDU/purdue/jtb/parser/MatchInfo.java0000644000175000017500000000367611360636752020653 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes a match, within a given lookahead. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class MatchInfo { public static int laLimit; int[] match = new int[laLimit]; int firstFreeLoc; public static void reInit() { laLimit = 0; } } jtb-1.4.4/EDU/purdue/jtb/parser/TokenMgrError.java0000644000175000017500000001074211416555666021541 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ /* JavaCCOptions: */ package EDU.purdue.jtb.parser; /** Token Manager Error. */ public class TokenMgrError extends Error { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occurred. */ static final int LEXICAL_ERROR = 0; /** * An attempt was made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their escaped (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexical error * curLexState : lexical state in which this error occurred * errorLine : line number when the error occurred * errorColumn : column number when the error occurred * errorAfter : prefix that was seen before this error occurred * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ /** No arg constructor. */ public TokenMgrError() { } /** Constructor with message and reason. */ public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } /** Full Constructor. */ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } /* JavaCC - OriginalChecksum=5408808d93e07c2ddbd05d7879dcb9f8 (do not edit this line) */ jtb-1.4.4/EDU/purdue/jtb/parser/ParseGen.java0000644000175000017500000011613111360636752020476 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Generate the parser. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class ParseGen extends JavaCCGlobals implements JavaCCParserConstants { // ModMMa : modified for Token.template with GTToken //static public void start() throws MetaParseException { static public String start() throws MetaParseException { Token t = null; if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); if (Options.getBuildParser()) { try { ostr = new PrintWriter( new BufferedWriter( new FileWriter( new File( Options .getOutputDirectory(), cu_name + ".java")), // ModMMa : performance improvements (use big BufferedWriter) // 8192 4 * 8192)); } catch (final IOException e) { JavaCCErrors.semantic_error("Could not open file " + cu_name + ".java for writing."); throw new Error(); } final List tn = new ArrayList(toolNames); tn.add(toolName); ostr.println("/* " + getIdString(tn, cu_name + ".java") + " */"); boolean implementsExists = false; // ModMMa : get rid of static access warning final String tsClassOrVar = (Options.getStatic() ? cu_name + "TokenManager" : "token_source"); if (cu_to_insertion_point_1.size() != 0) { printTokenSetup((cu_to_insertion_point_1.get(0))); ccol = 1; for (final Iterator it = cu_to_insertion_point_1.iterator(); it.hasNext();) { t = it.next(); if (t.kind == IMPLEMENTS) { implementsExists = true; } else if (t.kind == CLASS) { implementsExists = false; } printToken(t, ostr); } } if (implementsExists) { ostr.print(", "); } else { ostr.print(" implements "); } ostr.print(cu_name + "Constants "); if (cu_to_insertion_point_2.size() != 0) { printTokenSetup((cu_to_insertion_point_2.get(0))); for (final Iterator it = cu_to_insertion_point_2.iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } } ostr.println(""); ostr.println(""); ParseEngine.build(ostr); if (Options.getStatic()) { ostr.println(" static private boolean jj_initialized_once = false;"); } if (Options.getUserTokenManager()) { ostr.println(" /** User defined Token Manager. */"); ostr.println(" " + staticOpt() + "public TokenManager token_source;"); } else { ostr.println(" /** Generated Token Manager. */"); ostr.println(" " + staticOpt() + "public " + cu_name + "TokenManager token_source;"); if (!Options.getUserCharStream()) { if (Options.getJavaUnicodeEscape()) { ostr.println(" " + staticOpt() + "JavaCharStream jj_input_stream;"); } else { ostr.println(" " + staticOpt() + "SimpleCharStream jj_input_stream;"); } } } ostr.println(" /** Current token. */"); ostr.println(" " + staticOpt() + "public Token token;"); ostr.println(" /** Next token. */"); ostr.println(" " + staticOpt() + "public Token jj_nt;"); if (!Options.getCacheTokens()) { ostr.println(" " + staticOpt() + "private int jj_ntk;"); } if (jj2index != 0) { ostr.println(" " + staticOpt() + "private Token jj_scanpos, jj_lastpos;"); ostr.println(" " + staticOpt() + "private int jj_la;"); if (lookaheadNeeded) { ostr.println(" /** Whether we are looking ahead. */"); ostr.println(" " + staticOpt() + "private boolean jj_lookingAhead = false;"); ostr.println(" " + staticOpt() + "private boolean jj_semLA;"); } } if (Options.getErrorReporting()) { ostr.println(" " + staticOpt() + "private int jj_gen;"); ostr.println(" " + staticOpt() + "final private int[] jj_la1 = new int[" + maskindex + "];"); final int tokenMaskSize = (tokenCount - 1) / 32 + 1; for (int i = 0; i < tokenMaskSize; i++) ostr.println(" static private int[] jj_la1_" + i + ";"); ostr.println(" static {"); for (int i = 0; i < tokenMaskSize; i++) ostr.println(" jj_la1_init_" + i + "();"); ostr.println(" }"); for (int i = 0; i < tokenMaskSize; i++) { ostr.println(" private static void jj_la1_init_" + i + "() {"); ostr.print(" jj_la1_" + i + " = new int[] {"); for (final Iterator it = maskVals.iterator(); it.hasNext();) { final int[] tokenMask = (it.next()); ostr.print("0x" + Integer.toHexString(tokenMask[i]) + ","); } ostr.println("};"); ostr.println(" }"); } } if (jj2index != 0 && Options.getErrorReporting()) { ostr.println(" " + staticOpt() + "final private JJCalls[] jj_2_rtns = new JJCalls[" + jj2index + "];"); ostr.println(" " + staticOpt() + "private boolean jj_rescan = false;"); ostr.println(" " + staticOpt() + "private int jj_gc = 0;"); } ostr.println(""); if (!Options.getUserTokenManager()) { if (Options.getUserCharStream()) { ostr.println(" /** Constructor with user supplied CharStream. */"); ostr.println(" public " + cu_name + "(CharStream stream) {"); if (Options.getStatic()) { ostr.println(" if (jj_initialized_once) {"); ostr .println(" System.out.println(\"ERROR: Second call to constructor of static parser. \");"); ostr.println(" System.out.println(\" You must either use ReInit() " + "or set the JavaCC option STATIC to false\");"); ostr.println(" System.out.println(\" during parser generation.\");"); ostr.println(" throw new Error();"); ostr.println(" }"); ostr.println(" jj_initialized_once = true;"); } if (Options.getTokenManagerUsesParser() && !Options.getStatic()) { ostr.println(" token_source = new " + cu_name + "TokenManager(this, stream);"); } else { ostr.println(" token_source = new " + cu_name + "TokenManager(stream);"); } ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr.println(" " + staticOpt() + "public void ReInit(final CharStream stream) {"); ostr.println(" " + tsClassOrVar + ".ReInit(stream);"); ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (lookaheadNeeded) { ostr.println(" jj_lookingAhead = false;"); } if (jjtreeGenerated) { ostr.println(" jjtree.reset();"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); } else { ostr.println(" /** Constructor with InputStream. */"); ostr.println(" public " + cu_name + "(java.io.InputStream stream) {"); ostr.println(" this(stream, null);"); ostr.println(" }"); ostr.println(" /** Constructor with InputStream and supplied encoding */"); ostr.println(" public " + cu_name + "(java.io.InputStream stream, String encoding) {"); if (Options.getStatic()) { ostr.println(" if (jj_initialized_once) {"); ostr .println(" System.out.println(\"ERROR: Second call to constructor of static parser. \");"); ostr.println(" System.out.println(\" You must either use ReInit() or " + "set the JavaCC option STATIC to false\");"); ostr.println(" System.out.println(\" during parser generation.\");"); ostr.println(" throw new Error();"); ostr.println(" }"); ostr.println(" jj_initialized_once = true;"); } if (Options.getJavaUnicodeEscape()) { if (!Options.getGenerateChainedException()) { ostr .println(" try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) {" + " throw new RuntimeException(e.getMessage()); }"); } else { ostr .println(" try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }"); } } else { if (!Options.getGenerateChainedException()) { ostr .println(" try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) { " + "throw new RuntimeException(e.getMessage()); }"); } else { ostr .println(" try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }"); } } if (Options.getTokenManagerUsesParser() && !Options.getStatic()) { ostr.println(" token_source = new " + cu_name + "TokenManager(this, jj_input_stream);"); } else { ostr.println(" token_source = new " + cu_name + "TokenManager(jj_input_stream);"); } ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr.println(" " + staticOpt() + "public void ReInit(final java.io.InputStream stream) {"); ostr.println(" ReInit(stream, null);"); ostr.println(" }"); // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr .println(" " + staticOpt() + "public void ReInit(final java.io.InputStream stream, final String encoding) {"); if (!Options.getGenerateChainedException()) { ostr.println(" try { jj_input_stream.ReInit(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) { " + "throw new RuntimeException(e.getMessage()); }"); } else { ostr .println(" try { jj_input_stream.ReInit(stream, encoding, 1, 1); } " + "catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }"); } ostr.println(" " + tsClassOrVar + ".ReInit(jj_input_stream);"); ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (jjtreeGenerated) { ostr.println(" jjtree.reset();"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); ostr.println(" /** Constructor. */"); ostr.println(" public " + cu_name + "(java.io.Reader stream) {"); if (Options.getStatic()) { ostr.println(" if (jj_initialized_once) {"); ostr .println(" System.out.println(\"ERROR: Second call to constructor of static parser. \");"); ostr.println(" System.out.println(\" You must either use ReInit() or " + "set the JavaCC option STATIC to false\");"); ostr.println(" System.out.println(\" during parser generation.\");"); ostr.println(" throw new Error();"); ostr.println(" }"); ostr.println(" jj_initialized_once = true;"); } if (Options.getJavaUnicodeEscape()) { ostr.println(" jj_input_stream = new JavaCharStream(stream, 1, 1);"); } else { ostr.println(" jj_input_stream = new SimpleCharStream(stream, 1, 1);"); } if (Options.getTokenManagerUsesParser() && !Options.getStatic()) { ostr.println(" token_source = new " + cu_name + "TokenManager(this, jj_input_stream);"); } else { ostr.println(" token_source = new " + cu_name + "TokenManager(jj_input_stream);"); } ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr.println(" " + staticOpt() + "public void ReInit(final java.io.Reader stream) {"); if (Options.getJavaUnicodeEscape()) { ostr.println(" jj_input_stream.ReInit(stream, 1, 1);"); } else { ostr.println(" jj_input_stream.ReInit(stream, 1, 1);"); } ostr.println(" " + tsClassOrVar + ".ReInit(jj_input_stream);"); ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (jjtreeGenerated) { ostr.println(" jjtree.reset();"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); } } ostr.println(""); if (Options.getUserTokenManager()) { ostr.println(" /** Constructor with user supplied Token Manager. */"); ostr.println(" public " + cu_name + "(TokenManager tm) {"); } else { ostr.println(" /** Constructor with generated Token Manager. */"); ostr.println(" public " + cu_name + "(" + cu_name + "TokenManager tm) {"); } if (Options.getStatic()) { ostr.println(" if (jj_initialized_once) {"); ostr .println(" System.out.println(\"ERROR: Second call to constructor of static parser. \");"); ostr.println(" System.out.println(\" You must either use ReInit() or " + "set the JavaCC option STATIC to false\");"); ostr.println(" System.out.println(\" during parser generation.\");"); ostr.println(" throw new Error();"); ostr.println(" }"); ostr.println(" jj_initialized_once = true;"); } ostr.println(" token_source = tm;"); ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); if (Options.getUserTokenManager()) { // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr.println(" public void ReInit(final TokenManager tm) {"); } else { // ModMMa : correct spelling ostr.println(" /** Reinitialize. */"); // ModMMa : added final ostr.println(" public void ReInit(final " + cu_name + "TokenManager tm) {"); } ostr.println(" token_source = tm;"); ostr.println(" token = new Token();"); if (Options.getCacheTokens()) { ostr.println(" token.next = jj_nt = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" jj_ntk = -1;"); } if (jjtreeGenerated) { ostr.println(" jjtree.reset();"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen = 0;"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) jj_la1[i] = -1;"); if (jj2index != 0) { ostr .println(" for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();"); } } ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private Token jj_consume_token(int kind) throws ParseException {"); if (Options.getCacheTokens()) { ostr.println(" Token oldToken = token;"); ostr.println(" if ((token = jj_nt).next != null) jj_nt = jj_nt.next;"); ostr.println(" else jj_nt = jj_nt.next = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" Token oldToken;"); ostr.println(" if ((oldToken = token).next != null) token = token.next;"); ostr.println(" else token = token.next = " + tsClassOrVar + ".getNextToken();"); ostr.println(" jj_ntk = -1;"); } ostr.println(" if (token.kind == kind) {"); if (Options.getErrorReporting()) { ostr.println(" jj_gen++;"); if (jj2index != 0) { ostr.println(" if (++jj_gc > 100) {"); ostr.println(" jj_gc = 0;"); ostr.println(" for (int i = 0; i < jj_2_rtns.length; i++) {"); ostr.println(" JJCalls c = jj_2_rtns[i];"); ostr.println(" while (c != null) {"); ostr.println(" if (c.gen < jj_gen) c.first = null;"); ostr.println(" c = c.next;"); ostr.println(" }"); ostr.println(" }"); ostr.println(" }"); } } if (Options.getDebugParser()) { ostr.println(" trace_token(token, \"\");"); } ostr.println(" return token;"); ostr.println(" }"); if (Options.getCacheTokens()) { ostr.println(" jj_nt = token;"); } ostr.println(" token = oldToken;"); if (Options.getErrorReporting()) { ostr.println(" jj_kind = kind;"); } ostr.println(" throw generateParseException();"); ostr.println(" }"); ostr.println(""); if (jj2index != 0) { ostr.println(" static private final class LookaheadSuccess extends java.lang.Error { }"); ostr.println(" " + staticOpt() + "final private LookaheadSuccess jj_ls = new LookaheadSuccess();"); ostr.println(" " + staticOpt() + "private boolean jj_scan_token(int kind) {"); ostr.println(" if (jj_scanpos == jj_lastpos) {"); ostr.println(" jj_la--;"); ostr.println(" if (jj_scanpos.next == null) {"); ostr.println(" jj_lastpos = jj_scanpos = jj_scanpos.next = " + tsClassOrVar + ".getNextToken();"); ostr.println(" } else {"); ostr.println(" jj_lastpos = jj_scanpos = jj_scanpos.next;"); ostr.println(" }"); ostr.println(" } else {"); ostr.println(" jj_scanpos = jj_scanpos.next;"); ostr.println(" }"); if (Options.getErrorReporting()) { ostr.println(" if (jj_rescan) {"); ostr.println(" int i = 0; Token tok = token;"); ostr.println(" while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }"); ostr.println(" if (tok != null) jj_add_error_token(kind, i);"); if (Options.getDebugLookahead()) { ostr.println(" } else {"); ostr.println(" trace_scan(jj_scanpos, kind);"); } ostr.println(" }"); } else if (Options.getDebugLookahead()) { ostr.println(" trace_scan(jj_scanpos, kind);"); } ostr.println(" if (jj_scanpos.kind != kind) return true;"); ostr.println(" if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;"); ostr.println(" return false;"); ostr.println(" }"); ostr.println(""); } ostr.println(""); ostr.println("/** Get the next Token. */"); ostr.println(" " + staticOpt() + "final public Token getNextToken() {"); if (Options.getCacheTokens()) { ostr.println(" if ((token = jj_nt).next != null) jj_nt = jj_nt.next;"); ostr.println(" else jj_nt = jj_nt.next = " + tsClassOrVar + ".getNextToken();"); } else { ostr.println(" if (token.next != null) token = token.next;"); ostr.println(" else token = token.next = " + tsClassOrVar + ".getNextToken();"); ostr.println(" jj_ntk = -1;"); } if (Options.getErrorReporting()) { ostr.println(" jj_gen++;"); } if (Options.getDebugParser()) { ostr.println(" trace_token(token, \" (in getNextToken)\");"); } ostr.println(" return token;"); ostr.println(" }"); ostr.println(""); ostr.println("/** Get the specific Token. */"); ostr.println(" " + staticOpt() + "final public Token getToken(int index) {"); if (lookaheadNeeded) { ostr.println(" Token t = jj_lookingAhead ? jj_scanpos : token;"); } else { ostr.println(" Token t = token;"); } ostr.println(" for (int i = 0; i < index; i++) {"); ostr.println(" if (t.next != null) t = t.next;"); ostr.println(" else t = t.next = " + tsClassOrVar + ".getNextToken();"); ostr.println(" }"); ostr.println(" return t;"); ostr.println(" }"); ostr.println(""); if (!Options.getCacheTokens()) { ostr.println(" " + staticOpt() + "private int jj_ntk() {"); ostr.println(" if ((jj_nt=token.next) == null)"); ostr.println(" return (jj_ntk = (token.next = " + tsClassOrVar + ".getNextToken()).kind);"); ostr.println(" else"); ostr.println(" return (jj_ntk = jj_nt.kind);"); ostr.println(" }"); ostr.println(""); } if (Options.getErrorReporting()) { if (!Options.getGenerateGenerics()) ostr.println(" " + staticOpt() + "private java.util.List jj_expentries = new java.util.ArrayList();"); else ostr .println(" " + staticOpt() + "private java.util.List jj_expentries = new java.util.ArrayList();"); ostr.println(" " + staticOpt() + "private int[] jj_expentry;"); ostr.println(" " + staticOpt() + "private int jj_kind = -1;"); if (jj2index != 0) { ostr.println(" " + staticOpt() + "private int[] jj_lasttokens = new int[100];"); ostr.println(" " + staticOpt() + "private int jj_endpos;"); ostr.println(""); ostr.println(" " + staticOpt() + "private void jj_add_error_token(int kind, int pos) {"); ostr.println(" if (pos >= 100) return;"); ostr.println(" if (pos == jj_endpos + 1) {"); ostr.println(" jj_lasttokens[jj_endpos++] = kind;"); ostr.println(" } else if (jj_endpos != 0) {"); ostr.println(" jj_expentry = new int[jj_endpos];"); ostr.println(" for (int i = 0; i < jj_endpos; i++) {"); ostr.println(" jj_expentry[i] = jj_lasttokens[i];"); ostr.println(" }"); ostr .println(" jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {"); ostr.println(" int[] oldentry = (int[])(it.next());"); ostr.println(" if (oldentry.length == jj_expentry.length) {"); ostr.println(" for (int i = 0; i < jj_expentry.length; i++) {"); ostr.println(" if (oldentry[i] != jj_expentry[i]) {"); ostr.println(" continue jj_entries_loop;"); ostr.println(" }"); ostr.println(" }"); ostr.println(" jj_expentries.add(jj_expentry);"); ostr.println(" break jj_entries_loop;"); ostr.println(" }"); ostr.println(" }"); ostr.println(" if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;"); ostr.println(" }"); ostr.println(" }"); } ostr.println(""); ostr.println(" /** Generate ParseException. */"); ostr.println(" " + staticOpt() + "public ParseException generateParseException() {"); ostr.println(" jj_expentries.clear();"); ostr.println(" boolean[] la1tokens = new boolean[" + tokenCount + "];"); ostr.println(" if (jj_kind >= 0) {"); ostr.println(" la1tokens[jj_kind] = true;"); ostr.println(" jj_kind = -1;"); ostr.println(" }"); ostr.println(" for (int i = 0; i < " + maskindex + "; i++) {"); ostr.println(" if (jj_la1[i] == jj_gen) {"); ostr.println(" for (int j = 0; j < 32; j++) {"); for (int i = 0; i < (tokenCount - 1) / 32 + 1; i++) { ostr.println(" if ((jj_la1_" + i + "[i] & (1<. " + "Encountered: \" + mess);"); ostr.println(" }"); } ostr.println(""); if (Options.getDebugParser()) { ostr.println(" " + staticOpt() + "private int trace_indent = 0;"); ostr.println(" " + staticOpt() + "private boolean trace_enabled = true;"); ostr.println(""); ostr.println("/** Enable tracing. */"); ostr.println(" " + staticOpt() + "final public void enable_tracing() {"); ostr.println(" trace_enabled = true;"); ostr.println(" }"); ostr.println(""); ostr.println("/** Disable tracing. */"); ostr.println(" " + staticOpt() + "final public void disable_tracing() {"); ostr.println(" trace_enabled = false;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_call(String s) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.println(\"Call: \" + s);"); ostr.println(" }"); ostr.println(" trace_indent = trace_indent + 2;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_return(String s) {"); ostr.println(" trace_indent = trace_indent - 2;"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.println(\"Return: \" + s);"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_token(Token t, String where) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.print(\"Consumed token: <\" + tokenImage[t.kind]);"); ostr .println(" if (t.kind != 0 && !tokenImage[t.kind].equals(\"\\\"\" + t.image + \"\\\"\")) {"); ostr.println(" System.out.print(\": \\\"\" + t.image + \"\\\"\");"); ostr.println(" }"); ostr.println(" System.out.println(\" at line \" + t.beginLine + " + "\" column \" + t.beginColumn + \">\" + where);"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void trace_scan(Token t1, int t2) {"); ostr.println(" if (trace_enabled) {"); ostr.println(" for (int i = 0; i < trace_indent; i++) { System.out.print(\" \"); }"); ostr.println(" System.out.print(\"Visited token: <\" + tokenImage[t1.kind]);"); ostr .println(" if (t1.kind != 0 && !tokenImage[t1.kind].equals(\"\\\"\" + t1.image + \"\\\"\")) {"); ostr.println(" System.out.print(\": \\\"\" + t1.image + \"\\\"\");"); ostr.println(" }"); ostr .println(" System.out.println(\" at line \" + t1.beginLine + \"" + " column \" + t1.beginColumn + \">; Expected token: <\" + tokenImage[t2] + \">\");"); ostr.println(" }"); ostr.println(" }"); ostr.println(""); } else { ostr.println(" /** Enable tracing. */"); ostr.println(" " + staticOpt() + "final public void enable_tracing() {"); ostr.println(" }"); ostr.println(""); ostr.println(" /** Disable tracing. */"); ostr.println(" " + staticOpt() + "final public void disable_tracing() {"); ostr.println(" }"); ostr.println(""); } if (jj2index != 0 && Options.getErrorReporting()) { ostr.println(" " + staticOpt() + "private void jj_rescan_token() {"); ostr.println(" jj_rescan = true;"); ostr.println(" for (int i = 0; i < " + jj2index + "; i++) {"); ostr.println(" try {"); ostr.println(" JJCalls p = jj_2_rtns[i];"); ostr.println(" do {"); ostr.println(" if (p.gen > jj_gen) {"); ostr.println(" jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;"); ostr.println(" switch (i) {"); for (int i = 0; i < jj2index; i++) { ostr.println(" case " + i + ": jj_3_" + (i + 1) + "(); break;"); } ostr.println(" }"); ostr.println(" }"); ostr.println(" p = p.next;"); ostr.println(" } while (p != null);"); ostr.println(" } catch(LookaheadSuccess ls) { }"); ostr.println(" }"); ostr.println(" jj_rescan = false;"); ostr.println(" }"); ostr.println(""); ostr.println(" " + staticOpt() + "private void jj_save(int index, int xla) {"); ostr.println(" JJCalls p = jj_2_rtns[index];"); ostr.println(" while (p.gen > jj_gen) {"); ostr.println(" if (p.next == null) { p = p.next = new JJCalls(); break; }"); ostr.println(" p = p.next;"); ostr.println(" }"); ostr.println(" p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;"); ostr.println(" }"); ostr.println(""); } if (jj2index != 0 && Options.getErrorReporting()) { ostr.println(" static final class JJCalls {"); ostr.println(" int gen;"); ostr.println(" Token first;"); ostr.println(" int arg;"); ostr.println(" JJCalls next;"); ostr.println(" }"); ostr.println(""); } if (cu_from_insertion_point_2.size() != 0) { printTokenSetup((cu_from_insertion_point_2.get(0))); ccol = 1; for (final Iterator it = cu_from_insertion_point_2.iterator(); it.hasNext();) { t = it.next(); printToken(t, ostr); } printTrailingComments(t, ostr); } ostr.println(""); ostr.close(); } // matches "if (Options.getBuildParser())" // ModMMa : added for Token.template with GTToken return cu_name; } static private PrintWriter ostr; public static void reInit() { ostr = null; lookaheadNeeded = false; } } jtb-1.4.4/EDU/purdue/jtb/parser/NonTerminal.java0000644000175000017500000000705711360636752021226 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Describes non terminals. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class NonTerminal extends Expansion_ { /** * The LHS to which the return value of the non-terminal * is assigned. In case there is no LHS, then the vector * remains empty. */ private List lhsTokens = new ArrayList(); /** * The name of the non-terminal. */ private String name; /** * The list of all tokens in the argument list. */ private List argument_tokens = new ArrayList(); /** * The production this non-terminal corresponds to. */ private NormalProduction prod; @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer value = super.dump(indent, alreadyDumped).append(' ').append(name); return value; } /** * @param lhsTokens the lhsTokens to set */ public final void setLhsTokens(final List lt) { lhsTokens = lt; } /** * @return the lhsTokens */ public final List getLhsTokens() { return lhsTokens; } /** * @param ref the name to set */ public final void setName(final String nm) { name = nm; } /** * @return the name */ public final String getName() { return name; } /** * @param argument_tokens the argument_tokens to set */ public final void setArgumentTokens(final List tk) { argument_tokens = tk; } /** * @return the argument_tokens */ public final List getArgumentTokens() { return argument_tokens; } /** * @param prod the prod to set */ public final NormalProduction setProd(final NormalProduction pr) { return prod = pr; } /** * @return the prod */ public final NormalProduction getProd() { return prod; } } jtb-1.4.4/EDU/purdue/jtb/parser/RZeroOrMore.java0000644000175000017500000000535311360636752021162 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * Describes zero-or-more regular expressions (). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RZeroOrMore extends RegularExpression_ { /** * The regular expression which is repeated zero or more times. */ public RegularExpression_ regexpr; @Override public Nfa GenerateNfa(final boolean ignoreCase) { final Nfa retVal = new Nfa(); final NfaState startState = retVal.start; final NfaState finalState = retVal.end; final Nfa temp = regexpr.GenerateNfa(ignoreCase); startState.AddMove(temp.start); startState.AddMove(finalState); temp.end.AddMove(finalState); temp.end.AddMove(temp.start); return retVal; } public RZeroOrMore() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.R_ZERO_OR_MORE; } public RZeroOrMore(final Token t, final RegularExpression_ r) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(t.beginLine); this.setColumn(t.beginColumn); this.regexpr = r; } } jtb-1.4.4/EDU/purdue/jtb/parser/Container.java0000644000175000017500000000336611360636752020721 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; /** * An object container. Used to pass references to objects as parameter. */ public class Container { public Object member; } jtb-1.4.4/EDU/purdue/jtb/parser/RStringLiteral.java0000644000175000017500000012576411360636752021713 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; import java.util.Set; final class KindInfo { long[] validKinds; long[] finalKinds; int validKindCnt = 0; int finalKindCnt = 0; KindInfo(final int maxKind) { validKinds = new long[maxKind / 64 + 1]; finalKinds = new long[maxKind / 64 + 1]; } public void InsertValidKind(final int kind) { validKinds[kind / 64] |= (1L << (kind % 64)); validKindCnt++; } public void InsertFinalKind(final int kind) { finalKinds[kind / 64] |= (1L << (kind % 64)); finalKindCnt++; } } /** * Describes string literals. */ public class RStringLiteral extends RegularExpression_ { /** * The string image of the literal. */ public String image; public RStringLiteral() { } public RStringLiteral(final Token t, final String im) { setLine(t.beginLine); setColumn(t.beginColumn); image = im; } private static int maxStrKind = 0; private static int maxLen = 0; private static int charCnt = 0; private static List> charPosKind = new ArrayList>(); // Elements are hashtables // with single char keys; private static int[] maxLenForActive = new int[100]; // 6400 tokens public static String[] allImages; private static int[][] intermediateKinds; private static int[][] intermediateMatchedPos; // private static int startStateCnt = 0; private static boolean subString[]; private static boolean subStringAtPos[]; private static Hashtable[] statesForPos; /** * Initialize all the static variables, so that there is no interference * between the various states of the lexer. * * Need to call this method after generating code for each lexical state. */ public static void ReInit() { maxStrKind = 0; maxLen = 0; charPosKind = new ArrayList>(); maxLenForActive = new int[100]; // 6400 tokens intermediateKinds = null; intermediateMatchedPos = null; // startStateCnt = 0; subString = null; subStringAtPos = null; statesForPos = null; } public static void DumpStrLiteralImages(final java.io.PrintWriter ostr) { String image; int i; charCnt = 0; // Set to zero in reInit() but just to be sure ostr.println(""); ostr.println("/** Token literal values. */"); ostr.println("public static final String[] jjstrLiteralImages = {"); if (allImages == null || allImages.length == 0) { ostr.println("};"); return; } allImages[0] = ""; for (i = 0; i < allImages.length; i++) { if ((image = allImages[i]) == null || ((LexGen.toSkip[i / 64] & (1L << (i % 64))) == 0L && (LexGen.toMore[i / 64] & (1L << (i % 64))) == 0L && (LexGen.toToken[i / 64] & (1L << (i % 64))) == 0L) || (LexGen.toSkip[i / 64] & (1L << (i % 64))) != 0L || (LexGen.toMore[i / 64] & (1L << (i % 64))) != 0L || LexGen.canReachOnMore[LexGen.lexStates[i]] || ((Options.getIgnoreCase() || LexGen.ignoreCase[i]) && (!image.equals(image.toLowerCase()) || !image .equals(image .toUpperCase())))) { allImages[i] = null; if ((charCnt += 6) > 80) { ostr.println(""); charCnt = 0; } ostr.print("null, "); continue; } // ModMMa : performance improvements (String concatenation) // String toPrint = "\""; // // for (int j = 0; j < image.length(); j++) // { // if (image.charAt(j) <= 0xff) // toPrint += ("\\" + Integer.toOctalString((int)image.charAt(j))); // else // { // String hexVal = Integer.toHexString((int)image.charAt(j)); // // if (hexVal.length() == 3) // hexVal = "0" + hexVal; // toPrint += ("\\u" + hexVal); // } // } // // toPrint += ("\", "); // // if ((charCnt += toPrint.length()) >= 80) // { // ostr.println(""); // charCnt = 0; // } // // ostr.print(toPrint); // } final StringBuffer buff = new StringBuffer(64); buff.append("\""); for (int j = 0; j < image.length(); j++) { final char cij = image.charAt(j); if (cij <= 0xff) buff.append("\\").append(Integer.toOctalString(cij)); else { final String hexVal = Integer.toHexString(cij); buff.append("\\u"); if (hexVal.length() == 3) buff.append("0"); buff.append(hexVal); } } buff.append("\", "); final String toPrint = buff.toString(); if ((charCnt += toPrint.length()) >= 80) { ostr.println(""); charCnt = 0; } ostr.print(toPrint); } while (++i < LexGen.maxOrdinal) { if ((charCnt += 6) > 80) { ostr.println(""); charCnt = 0; } ostr.print("null, "); continue; } ostr.println("};"); } /** * Used for top level string literals. */ // public void GenerateDfa(final java.io.PrintWriter ostr, final int kind) { public void GenerateDfa() { String s; Hashtable temp; KindInfo info; int len; if (maxStrKind <= ordinal) maxStrKind = ordinal + 1; if ((len = image.length()) > maxLen) maxLen = len; char c; for (int i = 0; i < len; i++) { if (Options.getIgnoreCase()) s = ("" + (c = image.charAt(i))).toLowerCase(); else s = "" + (c = image.charAt(i)); if (!NfaState.unicodeWarningGiven && c > 0xff && !Options.getJavaUnicodeEscape() && !Options.getUserCharStream()) { NfaState.unicodeWarningGiven = true; JavaCCErrors .warning( LexGen.curRE, "Non-ASCII characters used in regular expression." + "Please make sure you use the correct Reader when you create the parser, " + "one that can handle your character set."); } if (i >= charPosKind.size()) // Kludge, but OK charPosKind.add(temp = new Hashtable()); else temp = charPosKind.get(i); if ((info = temp.get(s)) == null) temp.put(s, info = new KindInfo(LexGen.maxOrdinal)); if (i + 1 == len) info.InsertFinalKind(ordinal); else info.InsertValidKind(ordinal); if (!Options.getIgnoreCase() && LexGen.ignoreCase[ordinal] && c != Character.toLowerCase(c)) { s = ("" + image.charAt(i)).toLowerCase(); if (i >= charPosKind.size()) // Kludge, but OK charPosKind.add(temp = new Hashtable()); else temp = charPosKind.get(i); if ((info = temp.get(s)) == null) temp.put(s, info = new KindInfo(LexGen.maxOrdinal)); if (i + 1 == len) info.InsertFinalKind(ordinal); else info.InsertValidKind(ordinal); } if (!Options.getIgnoreCase() && LexGen.ignoreCase[ordinal] && c != Character.toUpperCase(c)) { s = ("" + image.charAt(i)).toUpperCase(); if (i >= charPosKind.size()) // Kludge, but OK charPosKind.add(temp = new Hashtable()); else temp = charPosKind.get(i); if ((info = temp.get(s)) == null) temp.put(s, info = new KindInfo(LexGen.maxOrdinal)); if (i + 1 == len) info.InsertFinalKind(ordinal); else info.InsertValidKind(ordinal); } } maxLenForActive[ordinal / 64] = Math.max(maxLenForActive[ordinal / 64], len - 1); allImages[ordinal] = image; } @Override public Nfa GenerateNfa(final boolean ignoreCase) { if (image.length() == 1) { final RCharacterList temp = new RCharacterList(image.charAt(0)); return temp.GenerateNfa(ignoreCase); } NfaState startState = new NfaState(); final NfaState theStartState = startState; NfaState finalState = null; if (image.length() == 0) return new Nfa(theStartState, theStartState); int i; for (i = 0; i < image.length(); i++) { finalState = new NfaState(); startState.charMoves = new char[1]; startState.AddChar(image.charAt(i)); if (Options.getIgnoreCase() || ignoreCase) { startState.AddChar(Character.toLowerCase(image.charAt(i))); startState.AddChar(Character.toUpperCase(image.charAt(i))); } startState.next = finalState; startState = finalState; } return new Nfa(theStartState, finalState); } static void DumpNullStrLiterals(final java.io.PrintWriter ostr) { ostr.println("{"); if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", 0);"); else ostr.println(" return 1;"); ostr.println("}"); } private static int GetStateSetForKind(final int pos, final int kind) { if (LexGen.mixed[LexGen.lexStateIndex] || NfaState.generatedStates == 0) return -1; final Hashtable allStateSets = statesForPos[pos]; if (allStateSets == null) return -1; final Enumeration e = allStateSets.keys(); while (e.hasMoreElements()) { String s = e.nextElement(); final long[] actives = allStateSets.get(s); s = s.substring(s.indexOf(", ") + 2); s = s.substring(s.indexOf(", ") + 2); if (s.equals("null;")) continue; if (actives != null && (actives[kind / 64] & (1L << (kind % 64))) != 0L) { return NfaState.AddStartStateSet(s); } } return -1; } static String GetLabel(final int kind) { final RegularExpression_ re = LexGen.rexprs[kind]; if (re instanceof RStringLiteral) return " \"" + JavaCCGlobals.add_escapes(((RStringLiteral) re).image) + "\""; else if (!re.label.equals("")) return " <" + re.label + ">"; else return " "; } static final int GetLine(final int kind) { return LexGen.rexprs[kind].getLine(); } static final int GetColumn(final int kind) { return LexGen.rexprs[kind].getColumn(); } /** * Returns true if s1 starts with s2 (ignoring case for each character). */ static private boolean StartsWithIgnoreCase(final String s1, final String s2) { if (s1.length() < s2.length()) return false; for (int i = 0; i < s2.length(); i++) { final char c1 = s1.charAt(i), c2 = s2.charAt(i); if (c1 != c2 && Character.toLowerCase(c2) != c1 && Character.toUpperCase(c2) != c1) return false; } return true; } static void FillSubString() { String image; subString = new boolean[maxStrKind + 1]; subStringAtPos = new boolean[maxLen]; for (int i = 0; i < maxStrKind; i++) { subString[i] = false; if ((image = allImages[i]) == null || LexGen.lexStates[i] != LexGen.lexStateIndex) continue; if (LexGen.mixed[LexGen.lexStateIndex]) { // We will not optimize for mixed case subString[i] = true; subStringAtPos[image.length() - 1] = true; continue; } for (int j = 0; j < maxStrKind; j++) { if (j != i && LexGen.lexStates[j] == LexGen.lexStateIndex && (allImages[j]) != null) { if ((allImages[j]).indexOf(image) == 0) { subString[i] = true; subStringAtPos[image.length() - 1] = true; break; } else if (Options.getIgnoreCase() && StartsWithIgnoreCase(allImages[j], image)) { subString[i] = true; subStringAtPos[image.length() - 1] = true; break; } } } } } static void DumpStartWithStates(final java.io.PrintWriter ostr) { ostr.println((Options.getStatic() ? "static " : "") + "private int " + "jjStartNfaWithStates" + LexGen.lexStateSuffix + "(int pos, int kind, int state)"); ostr.println("{"); ostr.println(" jjmatchedKind = kind;"); ostr.println(" jjmatchedPos = pos;"); if (Options.getDebugTokenManager()) { ostr .println(" debugStream.println(\" No more string literal token matches are possible.\");"); ostr .println(" debugStream.println(\" Currently matched the first \" " + "+ (jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");"); } ostr.println(" try { curChar = input_stream.readChar(); }"); ostr.println(" catch(java.io.IOException e) { return pos + 1; }"); if (Options.getDebugTokenManager()) ostr .println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(state, pos + 1);"); ostr.println("}"); } private static boolean boilerPlateDumped = false; static void DumpBoilerPlate(final java.io.PrintWriter ostr) { ostr.println((Options.getStatic() ? "static " : "") + "private int " + "jjStopAtPos(int pos, int kind)"); ostr.println("{"); ostr.println(" jjmatchedKind = kind;"); ostr.println(" jjmatchedPos = pos;"); if (Options.getDebugTokenManager()) { ostr .println(" debugStream.println(\" No more string literal token matches are possible.\");"); ostr .println(" debugStream.println(\" Currently matched the first \" + (jjmatchedPos + 1) + " + "\" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");"); } ostr.println(" return pos + 1;"); ostr.println("}"); } static String[] ReArrange(final Hashtable tab) { final String[] ret = new String[tab.size()]; final Enumeration e = tab.keys(); int cnt = 0; while (e.hasMoreElements()) { int i = 0, j; String s; final char c = (s = e.nextElement()).charAt(0); while (i < cnt && ret[i].charAt(0) < c) i++; if (i < cnt) for (j = cnt - 1; j >= i; j--) ret[j + 1] = ret[j]; ret[i] = s; cnt++; } return ret; } static void DumpDfaCode(final java.io.PrintWriter ostr) { Hashtable tab; String key; KindInfo info; final int maxLongsReqd = maxStrKind / 64 + 1; int i, j, k; boolean ifGenerated; LexGen.maxLongsReqd[LexGen.lexStateIndex] = maxLongsReqd; if (maxLen == 0) { ostr.println((Options.getStatic() ? "static " : "") + "private int " + "jjMoveStringLiteralDfa0" + LexGen.lexStateSuffix + "()"); DumpNullStrLiterals(ostr); return; } if (!boilerPlateDumped) { DumpBoilerPlate(ostr); boilerPlateDumped = true; } boolean createStartNfa = false; ; for (i = 0; i < maxLen; i++) { boolean atLeastOne = false; boolean startNfaNeeded = false; tab = charPosKind.get(i); final String[] keys = ReArrange(tab); ostr.print((Options.getStatic() ? "static " : "") + "private int " + "jjMoveStringLiteralDfa" + i + LexGen.lexStateSuffix + "("); if (i != 0) { if (i == 1) { for (j = 0; j < maxLongsReqd - 1; j++) if (i <= maxLenForActive[j]) { if (atLeastOne) ostr.print(", "); else atLeastOne = true; ostr.print("final long active" + j); } if (i <= maxLenForActive[j]) { if (atLeastOne) ostr.print(", "); ostr.print("final long active" + j); } } else { for (j = 0; j < maxLongsReqd - 1; j++) if (i <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(", "); else atLeastOne = true; // ModMMa : modified to get rid of "parameter should not be assigned" and to add final // ostr.print("long old" + j + ", long active" + j); ostr.print("final long old" + j + ", final long act" + j); } if (i <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(", "); // ModMMa : modified to get rid of "parameter should not be assigned" and to add final // ostr.print("long old" + j + ", long active" + j); ostr.print("final long old" + j + ", final long act" + j); } } } ostr.println(")"); ostr.println("{"); if (i != 0) { if (i > 1) { // ModMMa : modified to get rid of "parameter should not be assigned" : beg for (j = 0; j < maxLongsReqd - 1; j++) if (i <= maxLenForActive[j] + 1) { ostr.println(" long active" + j + " = act" + j + ";"); } if (i <= maxLenForActive[j] + 1) { ostr.println(" long active" + j + " = act" + j + ";"); } // ModMMa : modified to get rid of "parameter should not be assigned" : end atLeastOne = false; ostr.print(" if (("); for (j = 0; j < maxLongsReqd - 1; j++) if (i <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(" | "); else atLeastOne = true; ostr.print("(active" + j + " &= old" + j + ")"); } if (i <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(" | "); ostr.print("(active" + j + " &= old" + j + ")"); } ostr.println(") == 0L)"); if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0) { ostr.print(" return jjStartNfa" + LexGen.lexStateSuffix + "(" + (i - 2) + ", "); for (j = 0; j < maxLongsReqd - 1; j++) if (i <= maxLenForActive[j] + 1) ostr.print("old" + j + ", "); else ostr.print("0L, "); if (i <= maxLenForActive[j] + 1) ostr.println("old" + j + ");"); else ostr.println("0L);"); } else if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", " + (i - 1) + ");"); else ostr.println(" return " + i + ";"); } if (i != 0 && Options.getDebugTokenManager()) { ostr.println(" if (jjmatchedKind != 0 && jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr .println(" debugStream.println(\" Currently matched the first \" + " + "(jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");"); ostr.println(" debugStream.println(\" Possible string literal matches : { \""); for (int vecs = 0; vecs < maxStrKind / 64 + 1; vecs++) { if (i <= maxLenForActive[vecs]) { ostr.println(" +"); ostr.print(" jjKindsForBitVector(" + vecs + ", "); ostr.print("active" + vecs + ") "); } } ostr.println(" + \" } \");"); } ostr.println(" try { curChar = input_stream.readChar(); }"); ostr.println(" catch(java.io.IOException e) {"); if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0) { ostr.print(" jjStopStringLiteralDfa" + LexGen.lexStateSuffix + "(" + (i - 1) + ", "); for (k = 0; k < maxLongsReqd - 1; k++) if (i <= maxLenForActive[k]) ostr.print("active" + k + ", "); else ostr.print("0L, "); if (i <= maxLenForActive[k]) ostr.println("active" + k + ");"); else ostr.println("0L);"); if (i != 0 && Options.getDebugTokenManager()) { ostr.println(" if (jjmatchedKind != 0 && jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")"); ostr .println(" debugStream.println(\" Currently matched the first \" + " + "(jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");"); } ostr.println(" return " + i + ";"); } else if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", " + (i - 1) + ");"); else ostr.println(" return " + i + ";"); ostr.println(" }"); } if (i != 0 && Options.getDebugTokenManager()) ostr .println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " + "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") " + "at line \" + input_stream.getEndLine() + \" column \" + input_stream.getEndColumn());"); ostr.println(" switch(curChar)"); ostr.println(" {"); CaseLoop: for (int q = 0; q < keys.length; q++) { key = keys[q]; info = tab.get(key); ifGenerated = false; final char c = key.charAt(0); if (i == 0 && c < 128 && info.finalKindCnt != 0 && (NfaState.generatedStates == 0 || !NfaState.CanStartNfaUsingAscii(c))) { int kind; for (j = 0; j < maxLongsReqd; j++) if (info.finalKinds[j] != 0L) break; for (k = 0; k < 64; k++) if ((info.finalKinds[j] & (1L << k)) != 0L && !subString[kind = (j * 64 + k)]) { if ((intermediateKinds != null && intermediateKinds[(j * 64 + k)] != null && intermediateKinds[(j * 64 + k)][i] < (j * 64 + k) && intermediateMatchedPos != null && intermediateMatchedPos[(j * 64 + k)][i] == i) || (LexGen.canMatchAnyChar[LexGen.lexStateIndex] >= 0 && LexGen.canMatchAnyChar[LexGen.lexStateIndex] < (j * 64 + k))) break; else if ((LexGen.toSkip[kind / 64] & (1L << (kind % 64))) != 0L && (LexGen.toSpecial[kind / 64] & (1L << (kind % 64))) == 0L && LexGen.actions[kind] == null && LexGen.newLexState[kind] == null) { LexGen.AddCharToSkip(c, kind); if (Options.getIgnoreCase()) { if (c != Character.toUpperCase(c)) LexGen.AddCharToSkip(Character.toUpperCase(c), kind); if (c != Character.toLowerCase(c)) LexGen.AddCharToSkip(Character.toLowerCase(c), kind); } continue CaseLoop; } } } // Since we know key is a single character ... if (Options.getIgnoreCase()) { if (c != Character.toUpperCase(c)) ostr.println(" case " + (int) Character.toUpperCase(c) + ":"); if (c != Character.toLowerCase(c)) ostr.println(" case " + (int) Character.toLowerCase(c) + ":"); } ostr.println(" case " + (int) c + ":"); long matchedKind; final String prefix = (i == 0) ? " " : " "; if (info.finalKindCnt != 0) { for (j = 0; j < maxLongsReqd; j++) { if ((matchedKind = info.finalKinds[j]) == 0L) continue; for (k = 0; k < 64; k++) { if ((matchedKind & (1L << k)) == 0L) continue; if (ifGenerated) { ostr.print(" else if "); } else if (i != 0) ostr.print(" if "); ifGenerated = true; int kindToPrint; if (i != 0) { ostr.println("((active" + j + " & 0x" + Long.toHexString(1L << k) + "L) != 0L)"); } if (intermediateKinds != null && intermediateKinds[(j * 64 + k)] != null && intermediateKinds[(j * 64 + k)][i] < (j * 64 + k) && intermediateMatchedPos != null && intermediateMatchedPos[(j * 64 + k)][i] == i) { JavaCCErrors.warning(" \"" + JavaCCGlobals.add_escapes(allImages[j * 64 + k]) + "\" cannot be matched as a string literal token " + "at line " + GetLine(j * 64 + k) + ", column " + GetColumn(j * 64 + k) + ". It will be matched as " + GetLabel(intermediateKinds[(j * 64 + k)][i]) + "."); kindToPrint = intermediateKinds[(j * 64 + k)][i]; } else if (i == 0 && LexGen.canMatchAnyChar[LexGen.lexStateIndex] >= 0 && LexGen.canMatchAnyChar[LexGen.lexStateIndex] < (j * 64 + k)) { JavaCCErrors.warning(" \"" + JavaCCGlobals.add_escapes(allImages[j * 64 + k]) + "\" cannot be matched as a string literal token " + "at line " + GetLine(j * 64 + k) + ", column " + GetColumn(j * 64 + k) + ". It will be matched as " + GetLabel(LexGen.canMatchAnyChar[LexGen.lexStateIndex]) + "."); kindToPrint = LexGen.canMatchAnyChar[LexGen.lexStateIndex]; } else kindToPrint = j * 64 + k; if (!subString[(j * 64 + k)]) { final int stateSetName = GetStateSetForKind(i, j * 64 + k); if (stateSetName != -1) { createStartNfa = true; ostr.println(prefix + "return jjStartNfaWithStates" + LexGen.lexStateSuffix + "(" + i + ", " + kindToPrint + ", " + stateSetName + ");"); } else ostr.println(prefix + "return jjStopAtPos" + "(" + i + ", " + kindToPrint + ");"); } else { if ((LexGen.initMatch[LexGen.lexStateIndex] != 0 && LexGen.initMatch[LexGen.lexStateIndex] != Integer.MAX_VALUE) || i != 0) { ostr.println(" {"); ostr.println(prefix + "jjmatchedKind = " + kindToPrint + ";"); ostr.println(prefix + "jjmatchedPos = " + i + ";"); ostr.println(" }"); } else ostr.println(prefix + "jjmatchedKind = " + kindToPrint + ";"); } } } } if (info.validKindCnt != 0) { atLeastOne = false; if (i == 0) { ostr.print(" return "); ostr.print("jjMoveStringLiteralDfa" + (i + 1) + LexGen.lexStateSuffix + "("); for (j = 0; j < maxLongsReqd - 1; j++) if ((i + 1) <= maxLenForActive[j]) { if (atLeastOne) ostr.print(", "); else atLeastOne = true; ostr.print("0x" + Long.toHexString(info.validKinds[j]) + "L"); } if ((i + 1) <= maxLenForActive[j]) { if (atLeastOne) ostr.print(", "); ostr.print("0x" + Long.toHexString(info.validKinds[j]) + "L"); } ostr.println(");"); } else { ostr.print(" return "); ostr.print("jjMoveStringLiteralDfa" + (i + 1) + LexGen.lexStateSuffix + "("); for (j = 0; j < maxLongsReqd - 1; j++) if ((i + 1) <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(", "); else atLeastOne = true; if (info.validKinds[j] != 0L) ostr.print("active" + j + ", 0x" + Long.toHexString(info.validKinds[j]) + "L"); else ostr.print("active" + j + ", 0L"); } if ((i + 1) <= maxLenForActive[j] + 1) { if (atLeastOne) ostr.print(", "); if (info.validKinds[j] != 0L) ostr.print("active" + j + ", 0x" + Long.toHexString(info.validKinds[j]) + "L"); else ostr.print("active" + j + ", 0L"); } ostr.println(");"); } } else { // A very special case. if (i == 0 && LexGen.mixed[LexGen.lexStateIndex]) { if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", 0);"); else ostr.println(" return 1;"); } else if (i != 0) // No more str literals to look for { ostr.println(" break;"); startNfaNeeded = true; } } } /* default means that the current character is not in any of the strings at this position. */ ostr.println(" default :"); if (Options.getDebugTokenManager()) ostr.println(" debugStream.println(\" No string literal matches possible.\");"); if (NfaState.generatedStates != 0) { if (i == 0) { /* This means no string literal is possible. Just move nfa with this guy and return. */ ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", 0);"); } else { ostr.println(" break;"); startNfaNeeded = true; } } else { ostr.println(" return " + (i + 1) + ";"); } ostr.println(" }"); if (i != 0) { if (startNfaNeeded) { if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0) { /* Here, a string literal is successfully matched and no more string literals are possible. So set the kind and state set upto and including this position for the matched string. */ ostr.print(" return jjStartNfa" + LexGen.lexStateSuffix + "(" + (i - 1) + ", "); for (k = 0; k < maxLongsReqd - 1; k++) if (i <= maxLenForActive[k]) ostr.print("active" + k + ", "); else ostr.print("0L, "); if (i <= maxLenForActive[k]) ostr.println("active" + k + ");"); else ostr.println("0L);"); } else if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", " + i + ");"); else ostr.println(" return " + (i + 1) + ";"); } } ostr.println("}"); } if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0 && createStartNfa) DumpStartWithStates(ostr); } static final int GetStrKind(final String str) { for (int i = 0; i < maxStrKind; i++) { if (LexGen.lexStates[i] != LexGen.lexStateIndex) continue; final String image = allImages[i]; if (image != null && image.equals(str)) return i; } return Integer.MAX_VALUE; } @SuppressWarnings("unchecked") // for statesForPos = new Hashtable[maxLen]; static void GenerateNfaStartStates(final java.io.PrintWriter ostr, final NfaState initialState) { final boolean[] seen = new boolean[NfaState.generatedStates]; final Hashtable stateSets = new Hashtable(); String stateSetString = ""; int i, j, kind, jjmatchedPos = 0; final int maxKindsReqd = maxStrKind / 64 + 1; long[] actives; List newStates = new ArrayList(); List oldStates = null, jjtmpStates; statesForPos = new Hashtable[maxLen]; intermediateKinds = new int[maxStrKind + 1][]; intermediateMatchedPos = new int[maxStrKind + 1][]; for (i = 0; i < maxStrKind; i++) { if (LexGen.lexStates[i] != LexGen.lexStateIndex) continue; final String image = allImages[i]; if (image == null || image.length() < 1) continue; try { if ((oldStates = (List) initialState.epsilonMoves.clone()) == null || oldStates.size() == 0) { DumpNfaStartStatesCode(statesForPos, ostr); return; } } catch (final Exception e) { JavaCCErrors.semantic_error("Error cloning state vector"); } intermediateKinds[i] = new int[image.length()]; intermediateMatchedPos[i] = new int[image.length()]; jjmatchedPos = 0; kind = Integer.MAX_VALUE; for (j = 0; j < image.length(); j++) { if (oldStates == null || oldStates.size() <= 0) { // Here, j > 0 kind = intermediateKinds[i][j] = intermediateKinds[i][j - 1]; jjmatchedPos = intermediateMatchedPos[i][j] = intermediateMatchedPos[i][j - 1]; } else { kind = NfaState.MoveFromSet(image.charAt(j), oldStates, newStates); oldStates.clear(); if (j == 0 && kind != Integer.MAX_VALUE && LexGen.canMatchAnyChar[LexGen.lexStateIndex] != -1 && kind > LexGen.canMatchAnyChar[LexGen.lexStateIndex]) kind = LexGen.canMatchAnyChar[LexGen.lexStateIndex]; if (GetStrKind(image.substring(0, j + 1)) < kind) { intermediateKinds[i][j] = kind = Integer.MAX_VALUE; jjmatchedPos = 0; } else if (kind != Integer.MAX_VALUE) { intermediateKinds[i][j] = kind; jjmatchedPos = intermediateMatchedPos[i][j] = j; } else if (j == 0) kind = intermediateKinds[i][j] = Integer.MAX_VALUE; else { kind = intermediateKinds[i][j] = intermediateKinds[i][j - 1]; jjmatchedPos = intermediateMatchedPos[i][j] = intermediateMatchedPos[i][j - 1]; } stateSetString = NfaState.GetStateSetString(newStates); } if (kind == Integer.MAX_VALUE && (newStates == null || newStates.size() == 0)) continue; int p; if (stateSets.get(stateSetString) == null) { stateSets.put(stateSetString, stateSetString); for (p = 0; p < newStates.size(); p++) { if (seen[newStates.get(p).stateName]) newStates.get(p).inNextOf++; else seen[newStates.get(p).stateName] = true; } } else { for (p = 0; p < newStates.size(); p++) seen[newStates.get(p).stateName] = true; } jjtmpStates = oldStates; oldStates = newStates; (newStates = jjtmpStates).clear(); if (statesForPos[j] == null) statesForPos[j] = new Hashtable(); if ((actives = statesForPos[j].get(kind + ", " + jjmatchedPos + ", " + stateSetString)) == null) { actives = new long[maxKindsReqd]; statesForPos[j].put(kind + ", " + jjmatchedPos + ", " + stateSetString, actives); } actives[i / 64] |= 1L << (i % 64); //String name = NfaState.StoreStateSet(stateSetString); } } DumpNfaStartStatesCode(statesForPos, ostr); } // ModMMa : renamed argument statesForPos into states static void DumpNfaStartStatesCode(final Hashtable[] states, final java.io.PrintWriter ostr) { if (maxStrKind == 0) { // No need to generate this function return; } int i; final int maxKindsReqd = maxStrKind / 64 + 1; boolean condGenerated = false; int ind = 0; ostr.print("private" + (Options.getStatic() ? " static" : "") + " final int jjStopStringLiteralDfa" + LexGen.lexStateSuffix + "(int pos, "); for (i = 0; i < maxKindsReqd - 1; i++) ostr.print("long active" + i + ", "); ostr.println("long active" + i + ")\n{"); if (Options.getDebugTokenManager()) ostr .println(" debugStream.println(\" No more string literal token matches are possible.\");"); ostr.println(" switch (pos)\n {"); for (i = 0; i < maxLen - 1; i++) { if (states[i] == null) continue; ostr.println(" case " + i + ":"); final Enumeration e = states[i].keys(); while (e.hasMoreElements()) { String stateSetString = e.nextElement(); final long[] actives = states[i].get(stateSetString); for (int j = 0; j < maxKindsReqd; j++) { if (actives[j] == 0L) continue; if (condGenerated) ostr.print(" || "); else ostr.print(" if ("); condGenerated = true; ostr.print("(active" + j + " & 0x" + Long.toHexString(actives[j]) + "L) != 0L"); } if (condGenerated) { ostr.println(")"); String kindStr = stateSetString.substring(0, ind = stateSetString.indexOf(", ")); String afterKind = stateSetString.substring(ind + 2); final int jjmatchedPos = Integer .parseInt(afterKind.substring(0, afterKind.indexOf(", "))); if (!kindStr.equals(String.valueOf(Integer.MAX_VALUE))) ostr.println(" {"); if (!kindStr.equals(String.valueOf(Integer.MAX_VALUE))) { if (i == 0) { ostr.println(" jjmatchedKind = " + kindStr + ";"); if ((LexGen.initMatch[LexGen.lexStateIndex] != 0 && LexGen.initMatch[LexGen.lexStateIndex] != Integer.MAX_VALUE)) ostr.println(" jjmatchedPos = 0;"); } else if (i == jjmatchedPos) { if (subStringAtPos[i]) { ostr.println(" if (jjmatchedPos != " + i + ")"); ostr.println(" {"); ostr.println(" jjmatchedKind = " + kindStr + ";"); ostr.println(" jjmatchedPos = " + i + ";"); ostr.println(" }"); } else { ostr.println(" jjmatchedKind = " + kindStr + ";"); ostr.println(" jjmatchedPos = " + i + ";"); } } else { if (jjmatchedPos > 0) ostr.println(" if (jjmatchedPos < " + jjmatchedPos + ")"); else ostr.println(" if (jjmatchedPos == 0)"); ostr.println(" {"); ostr.println(" jjmatchedKind = " + kindStr + ";"); ostr.println(" jjmatchedPos = " + jjmatchedPos + ";"); ostr.println(" }"); } } kindStr = stateSetString.substring(0, ind = stateSetString.indexOf(", ")); afterKind = stateSetString.substring(ind + 2); stateSetString = afterKind.substring(afterKind.indexOf(", ") + 2); if (stateSetString.equals("null;")) ostr.println(" return -1;"); else ostr .println(" return " + NfaState.AddStartStateSet(stateSetString) + ";"); if (!kindStr.equals(String.valueOf(Integer.MAX_VALUE))) ostr.println(" }"); condGenerated = false; } } ostr.println(" return -1;"); } ostr.println(" default :"); ostr.println(" return -1;"); ostr.println(" }"); ostr.println("}"); ostr.print("private" + (Options.getStatic() ? " static" : "") + " final int jjStartNfa" + LexGen.lexStateSuffix + "(int pos, "); for (i = 0; i < maxKindsReqd - 1; i++) ostr.print("long active" + i + ", "); ostr.println("long active" + i + ")\n{"); if (LexGen.mixed[LexGen.lexStateIndex]) { if (NfaState.generatedStates != 0) ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", pos + 1);"); else ostr.println(" return pos + 1;"); ostr.println("}"); return; } ostr.print(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + "jjStopStringLiteralDfa" + LexGen.lexStateSuffix + "(pos, "); for (i = 0; i < maxKindsReqd - 1; i++) ostr.print("active" + i + ", "); ostr.print("active" + i + ")"); ostr.println(", pos + 1);"); ostr.println("}"); } /** * Return to original state. */ public static void reInit() { ReInit(); charCnt = 0; allImages = null; boilerPlateDumped = false; } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped).append(' ').append(image); return sb; } @Override public String toString() { return super.toString() + " - " + image; } } jtb-1.4.4/EDU/purdue/jtb/parser/JavaCCParserConstants.java0000644000175000017500000002361011360636752023132 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. JavaCCParserConstants.java */ /** * This file contains the code for JavaCCParser generated * by JavaCCParser itself. */ package EDU.purdue.jtb.parser; /** * Token literal values and constants. * Generated by org.javacc.parser.OtherFilesGen#start() */ public interface JavaCCParserConstants { /** End of File. */ int EOF = 0; /** RegularExpression Id. */ int _LOOKAHEAD = 1; /** RegularExpression Id. */ int _IGNORE_CASE = 2; /** RegularExpression Id. */ int _PARSER_BEGIN = 3; /** RegularExpression Id. */ int _PARSER_END = 4; /** RegularExpression Id. */ int _JAVACODE = 5; /** RegularExpression Id. */ int _TOKEN = 6; /** RegularExpression Id. */ int _SPECIAL_TOKEN = 7; /** RegularExpression Id. */ int _MORE = 8; /** RegularExpression Id. */ int _SKIP = 9; /** RegularExpression Id. */ int _TOKEN_MGR_DECLS = 10; /** RegularExpression Id. */ int _EOF = 11; /** RegularExpression Id. */ int SINGLE_LINE_COMMENT = 23; /** RegularExpression Id. */ int FORMAL_COMMENT = 24; /** RegularExpression Id. */ int MULTI_LINE_COMMENT = 25; /** RegularExpression Id. */ int ABSTRACT = 27; /** RegularExpression Id. */ int ASSERT = 28; /** RegularExpression Id. */ int BOOLEAN = 29; /** RegularExpression Id. */ int BREAK = 30; /** RegularExpression Id. */ int BYTE = 31; /** RegularExpression Id. */ int CASE = 32; /** RegularExpression Id. */ int CATCH = 33; /** RegularExpression Id. */ int CHAR = 34; /** RegularExpression Id. */ int CLASS = 35; /** RegularExpression Id. */ int CONST = 36; /** RegularExpression Id. */ int CONTINUE = 37; /** RegularExpression Id. */ int _DEFAULT = 38; /** RegularExpression Id. */ int DO = 39; /** RegularExpression Id. */ int DOUBLE = 40; /** RegularExpression Id. */ int ELSE = 41; /** RegularExpression Id. */ int ENUM = 42; /** RegularExpression Id. */ int EXTENDS = 43; /** RegularExpression Id. */ int FALSE = 44; /** RegularExpression Id. */ int FINAL = 45; /** RegularExpression Id. */ int FINALLY = 46; /** RegularExpression Id. */ int FLOAT = 47; /** RegularExpression Id. */ int FOR = 48; /** RegularExpression Id. */ int GOTO = 49; /** RegularExpression Id. */ int IF = 50; /** RegularExpression Id. */ int IMPLEMENTS = 51; /** RegularExpression Id. */ int IMPORT = 52; /** RegularExpression Id. */ int INSTANCEOF = 53; /** RegularExpression Id. */ int INT = 54; /** RegularExpression Id. */ int INTERFACE = 55; /** RegularExpression Id. */ int LONG = 56; /** RegularExpression Id. */ int NATIVE = 57; /** RegularExpression Id. */ int NEW = 58; /** RegularExpression Id. */ int NULL = 59; /** RegularExpression Id. */ int PACKAGE = 60; /** RegularExpression Id. */ int PRIVATE = 61; /** RegularExpression Id. */ int PROTECTED = 62; /** RegularExpression Id. */ int PUBLIC = 63; /** RegularExpression Id. */ int RETURN = 64; /** RegularExpression Id. */ int SHORT = 65; /** RegularExpression Id. */ int STATIC = 66; /** RegularExpression Id. */ int STRICTFP = 67; /** RegularExpression Id. */ int SUPER = 68; /** RegularExpression Id. */ int SWITCH = 69; /** RegularExpression Id. */ int SYNCHRONIZED = 70; /** RegularExpression Id. */ int THIS = 71; /** RegularExpression Id. */ int THROW = 72; /** RegularExpression Id. */ int THROWS = 73; /** RegularExpression Id. */ int TRANSIENT = 74; /** RegularExpression Id. */ int TRUE = 75; /** RegularExpression Id. */ int TRY = 76; /** RegularExpression Id. */ int VOID = 77; /** RegularExpression Id. */ int VOLATILE = 78; /** RegularExpression Id. */ int WHILE = 79; /** RegularExpression Id. */ int INTEGER_LITERAL = 80; /** RegularExpression Id. */ int DECIMAL_LITERAL = 81; /** RegularExpression Id. */ int HEX_LITERAL = 82; /** RegularExpression Id. */ int OCTAL_LITERAL = 83; /** RegularExpression Id. */ int FLOATING_POINT_LITERAL = 84; /** RegularExpression Id. */ int DECIMAL_FLOATING_POINT_LITERAL = 85; /** RegularExpression Id. */ int DECIMAL_EXPONENT = 86; /** RegularExpression Id. */ int HEXADECIMAL_FLOATING_POINT_LITERAL = 87; /** RegularExpression Id. */ int HEXADECIMAL_EXPONENT = 88; /** RegularExpression Id. */ int CHARACTER_LITERAL = 89; /** RegularExpression Id. */ int STRING_LITERAL = 90; /** RegularExpression Id. */ int LPAREN = 91; /** RegularExpression Id. */ int RPAREN = 92; /** RegularExpression Id. */ int LBRACE = 93; /** RegularExpression Id. */ int RBRACE = 94; /** RegularExpression Id. */ int LBRACKET = 95; /** RegularExpression Id. */ int RBRACKET = 96; /** RegularExpression Id. */ int SEMICOLON = 97; /** RegularExpression Id. */ int COMMA = 98; /** RegularExpression Id. */ int DOT = 99; /** RegularExpression Id. */ int ASSIGN = 100; /** RegularExpression Id. */ int LT = 101; /** RegularExpression Id. */ int BANG = 102; /** RegularExpression Id. */ int TILDE = 103; /** RegularExpression Id. */ int HOOK = 104; /** RegularExpression Id. */ int COLON = 105; /** RegularExpression Id. */ int EQ = 106; /** RegularExpression Id. */ int LE = 107; /** RegularExpression Id. */ int GE = 108; /** RegularExpression Id. */ int NE = 109; /** RegularExpression Id. */ int SC_OR = 110; /** RegularExpression Id. */ int SC_AND = 111; /** RegularExpression Id. */ int INCR = 112; /** RegularExpression Id. */ int DECR = 113; /** RegularExpression Id. */ int PLUS = 114; /** RegularExpression Id. */ int MINUS = 115; /** RegularExpression Id. */ int STAR = 116; /** RegularExpression Id. */ int SLASH = 117; /** RegularExpression Id. */ int BIT_AND = 118; /** RegularExpression Id. */ int BIT_OR = 119; /** RegularExpression Id. */ int XOR = 120; /** RegularExpression Id. */ int REM = 121; /** RegularExpression Id. */ int PLUSASSIGN = 122; /** RegularExpression Id. */ int MINUSASSIGN = 123; /** RegularExpression Id. */ int STARASSIGN = 124; /** RegularExpression Id. */ int SLASHASSIGN = 125; /** RegularExpression Id. */ int ANDASSIGN = 126; /** RegularExpression Id. */ int ORASSIGN = 127; /** RegularExpression Id. */ int XORASSIGN = 128; /** RegularExpression Id. */ int REMASSIGN = 129; /** RegularExpression Id. */ int RUNSIGNEDSHIFT = 130; /** RegularExpression Id. */ int RSIGNEDSHIFT = 131; /** RegularExpression Id. */ int GT = 132; /** RegularExpression Id. */ int LANGLE = 101; /** RegularExpression Id. */ int RANGLE = 132; /** RegularExpression Id. */ int IDENTIFIER = 140; /** RegularExpression Id. */ int LETTER = 141; /** RegularExpression Id. */ int PART_LETTER = 142; /** Lexical state. */ int DEFAULT = 0; /** Lexical state. */ int AFTER_EGEN = 1; /** Lexical state. */ int IN_SINGLE_LINE_COMMENT = 2; /** Lexical state. */ int IN_FORMAL_COMMENT = 3; /** Lexical state. */ int IN_MULTI_LINE_COMMENT = 4; /** Literal token values. */ String[] tokenImage = { "", "\"LOOKAHEAD\"", "\"IGNORE_CASE\"", "\"PARSER_BEGIN\"", "\"PARSER_END\"", "\"JAVACODE\"", "\"TOKEN\"", "\"SPECIAL_TOKEN\"", "\"MORE\"", "\"SKIP\"", "\"TOKEN_MGR_DECLS\"", "\"EOF\"", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "\"\\f\"", "\"/*@egen*/\"", "", "\"//\"", "", "\"/*\"", "\"/*@bgen(jjtree\"", "", "\"*/\"", "\"*/\"", "", "\"abstract\"", "\"assert\"", "\"boolean\"", "\"break\"", "\"byte\"", "\"case\"", "\"catch\"", "\"char\"", "\"class\"", "\"const\"", "\"continue\"", "\"default\"", "\"do\"", "\"double\"", "\"else\"", "\"enum\"", "\"extends\"", "\"false\"", "\"final\"", "\"finally\"", "\"float\"", "\"for\"", "\"goto\"", "\"if\"", "\"implements\"", "\"import\"", "\"instanceof\"", "\"int\"", "\"interface\"", "\"long\"", "\"native\"", "\"new\"", "\"null\"", "\"package\"", "\"private\"", "\"protected\"", "\"public\"", "\"return\"", "\"short\"", "\"static\"", "\"strictfp\"", "\"super\"", "\"switch\"", "\"synchronized\"", "\"this\"", "\"throw\"", "\"throws\"", "\"transient\"", "\"true\"", "\"try\"", "\"void\"", "\"volatile\"", "\"while\"", "", "", "", "", "", "", "", "", "", "", "", "\"(\"", "\")\"", "\"{\"", "\"}\"", "\"[\"", "\"]\"", "\";\"", "\",\"", "\".\"", "\"=\"", "\"<\"", "\"!\"", "\"~\"", "\"?\"", "\":\"", "\"==\"", "\"<=\"", "\">=\"", "\"!=\"", "\"||\"", "\"&&\"", "\"++\"", "\"--\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"&\"", "\"|\"", "\"^\"", "\"%\"", "\"+=\"", "\"-=\"", "\"*=\"", "\"/=\"", "\"&=\"", "\"|=\"", "\"^=\"", "\"%=\"", "\">>>\"", "\">>\"", "\">\"", "\"#\"", "\"...\"", "\"<<=\"", "\">>=\"", "\">>>=\"", "\"<<\"", "\"@\"", "", "", "", }; } jtb-1.4.4/EDU/purdue/jtb/parser/Action.java0000644000175000017500000000503111360636752020203 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Describes actions that may occur on the right hand side * of productions. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Action extends Expansion_ { /** * Contains the list of tokens that make up the action. This * list does not include the surrounding braces. */ private final List action_tokens = new ArrayList(); @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { final StringBuffer sb = super.dump(indent, alreadyDumped); alreadyDumped.add(this); if (getActionTokens().size() > 0) { sb.append(' ').append(getActionTokens().get(0)); } return sb; } /** * @return the action_tokens */ public final List getActionTokens() { return action_tokens; } } jtb-1.4.4/EDU/purdue/jtb/parser/Sequence.java0000644000175000017500000000604211360636752020541 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; /** * Describes expansions that are sequences of expansion * units. (c1 c2 ...) * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Sequence extends Expansion_ { /** * The list of units in this expansion sequence. Each * List component will narrow to Expansion_. */ public List units = new ArrayList(); public Sequence() { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker expType = EXP_TYPE.SEQUENCE; } public Sequence(final Token token, final Lookahead lookahead) { // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker this(); this.setLine(token.beginLine); this.setColumn(token.beginColumn); this.units.add(lookahead); } @Override public StringBuffer dump(final int indent, final Set alreadyDumped) { if (alreadyDumped.contains(this)) { return super.dump(0, alreadyDumped).insert(0, '[').append(']').insert(0, dumpPrefix(indent)); } alreadyDumped.add(this); final StringBuffer sb = super.dump(indent, alreadyDumped); for (final Iterator it = units.iterator(); it.hasNext();) { final Expansion_ next = it.next(); sb.append(eol).append(next.dump(indent + 1, alreadyDumped)); } return sb; } } jtb-1.4.4/EDU/purdue/jtb/parser/LookaheadWalk.java0000644000175000017500000002133311360636752021477 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public final class LookaheadWalk { public static boolean considerSemanticLA; public static ArrayList sizeLimitedMatches; private LookaheadWalk() { } private static void listAppend(final List vToAppendTo, final List vToAppend) { for (int i = 0; i < vToAppend.size(); i++) { vToAppendTo.add(vToAppend.get(i)); } } public static List genFirstSet(final List partialMatches, final Expansion_ exp) { if (exp instanceof RegularExpression_) { final List retval = new ArrayList(); for (int i = 0; i < partialMatches.size(); i++) { final MatchInfo m = partialMatches.get(i); final MatchInfo mnew = new MatchInfo(); for (int j = 0; j < m.firstFreeLoc; j++) { mnew.match[j] = m.match[j]; } mnew.firstFreeLoc = m.firstFreeLoc; mnew.match[mnew.firstFreeLoc++] = ((RegularExpression_) exp).ordinal; if (mnew.firstFreeLoc == MatchInfo.laLimit) { sizeLimitedMatches.add(mnew); } else { retval.add(mnew); } } return retval; } else if (exp instanceof NonTerminal) { final NormalProduction prod = ((NonTerminal) exp).getProd(); if (prod instanceof JavaCodeProduction_) { return new ArrayList(); } else { return genFirstSet(partialMatches, prod.getExpansion()); } } else if (exp instanceof Choice) { final List retval = new ArrayList(); final Choice ch = (Choice) exp; for (int i = 0; i < ch.getChoices().size(); i++) { final List v = genFirstSet(partialMatches, ch.getChoices().get(i)); listAppend(retval, v); } return retval; } else if (exp instanceof Sequence) { List v = partialMatches; final Sequence seq = (Sequence) exp; for (int i = 0; i < seq.units.size(); i++) { v = genFirstSet(v, seq.units.get(i)); if (v.size() == 0) break; } return v; } else if (exp instanceof OneOrMore) { final List retval = new ArrayList(); List v = partialMatches; final OneOrMore om = (OneOrMore) exp; while (true) { v = genFirstSet(v, om.expansion); if (v.size() == 0) break; listAppend(retval, v); } return retval; } else if (exp instanceof ZeroOrMore) { final List retval = new ArrayList(); listAppend(retval, partialMatches); List v = partialMatches; final ZeroOrMore zm = (ZeroOrMore) exp; while (true) { v = genFirstSet(v, zm.expansion); if (v.size() == 0) break; listAppend(retval, v); } return retval; } else if (exp instanceof ZeroOrOne) { final List retval = new ArrayList(); listAppend(retval, partialMatches); listAppend(retval, genFirstSet(partialMatches, ((ZeroOrOne) exp).expansion)); return retval; } else if (exp instanceof TryBlock) { return genFirstSet(partialMatches, ((TryBlock) exp).exp); } else if (considerSemanticLA && exp instanceof Lookahead && ((Lookahead) exp).getActionTokens().size() != 0) { return new ArrayList(); } else { final List retval = new ArrayList(); listAppend(retval, partialMatches); return retval; } } private static void listSplit(final List toSplit, final List mask, final List partInMask, final List rest) { OuterLoop: for (int i = 0; i < toSplit.size(); i++) { for (int j = 0; j < mask.size(); j++) { if (toSplit.get(i) == mask.get(j)) { partInMask.add(toSplit.get(i)); continue OuterLoop; } } rest.add(toSplit.get(i)); } } public static List genFollowSet(final List partialMatches, final Expansion_ exp, final long generation) { if (exp.myGeneration == generation) { return new ArrayList(); } // System.out.println("*** Parent: " + exp.parent); exp.myGeneration = generation; if (exp.parent == null) { final List retval = new ArrayList(); listAppend(retval, partialMatches); return retval; } else if (exp.parent instanceof NormalProduction) { final List parents = ((NormalProduction) exp.parent).getParents(); final List retval = new ArrayList(); // System.out.println("1; gen: " + generation + "; exp: " + exp); for (int i = 0; i < parents.size(); i++) { final List v = genFollowSet(partialMatches, (Expansion_) parents.get(i), generation); listAppend(retval, v); } return retval; } else if (exp.parent instanceof Sequence) { final Sequence seq = (Sequence) exp.parent; List v = partialMatches; for (int i = exp.ordinal + 1; i < seq.units.size(); i++) { v = genFirstSet(v, seq.units.get(i)); if (v.size() == 0) return v; } List v1 = new ArrayList(); List v2 = new ArrayList(); listSplit(v, partialMatches, v1, v2); if (v1.size() != 0) { // System.out.println("2; gen: " + generation + "; exp: " + exp); v1 = genFollowSet(v1, seq, generation); } if (v2.size() != 0) { // System.out.println("3; gen: " + generation + "; exp: " + exp); v2 = genFollowSet(v2, seq, Expansion_.nextGenerationIndex++); } listAppend(v2, v1); return v2; } else if (exp.parent instanceof OneOrMore || exp.parent instanceof ZeroOrMore) { final List moreMatches = new ArrayList(); listAppend(moreMatches, partialMatches); List v = partialMatches; while (true) { v = genFirstSet(v, exp); if (v.size() == 0) break; listAppend(moreMatches, v); } List v1 = new ArrayList(); List v2 = new ArrayList(); listSplit(moreMatches, partialMatches, v1, v2); if (v1.size() != 0) { // System.out.println("4; gen: " + generation + "; exp: " + exp); v1 = genFollowSet(v1, (Expansion_) exp.parent, generation); } if (v2.size() != 0) { // System.out.println("5; gen: " + generation + "; exp: " + exp); v2 = genFollowSet(v2, (Expansion_) exp.parent, Expansion_.nextGenerationIndex++); } listAppend(v2, v1); return v2; } else { // System.out.println("6; gen: " + generation + "; exp: " + exp); return genFollowSet(partialMatches, (Expansion_) exp.parent, generation); } } public static void reInit() { considerSemanticLA = false; sizeLimitedMatches = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/Semanticize.java0000644000175000017500000011412611360636752021247 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.List; /** * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class Semanticize extends JavaCCGlobals { static List> removeList = new ArrayList>(); static List itemList = new ArrayList(); static void prepareToRemove(final List vec, final Object item) { removeList.add(vec); itemList.add(item); } static void removePreparedItems() { for (int i = 0; i < removeList.size(); i++) { final List list = (removeList.get(i)); list.remove(itemList.get(i)); } removeList.clear(); itemList.clear(); } static public void start() throws MetaParseException { if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); if (Options.getLookahead() > 1 && !Options.getForceLaCheck() && Options.getSanityCheck()) { JavaCCErrors .warning("Lookahead adequacy checking not being performed since option LOOKAHEAD " + "is more than 1. Set option FORCE_LA_CHECK to true to force checking."); } /* * The following walks the entire parse tree to convert all LOOKAHEAD's * that are not at choice points (but at beginning of sequences) and converts * them to trivial choices. This way, their semantic lookahead specification * can be evaluated during other lookahead evaluations. */ for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { ExpansionTreeWalker.postOrderWalk(it.next().getExpansion(), new LookaheadFixer()); } /* * The following loop populates "production_table" */ for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { final NormalProduction p = it.next(); if (production_table.put(p.getLhs(), p) != null) { JavaCCErrors .semantic_error(p, p.getLhs() + " occurs on the left hand side of more than one production."); } } /* * The following walks the entire parse tree to make sure that all * non-terminals on RHS's are defined on the LHS. */ for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { ExpansionTreeWalker.preOrderWalk(it.next().getExpansion(), new ProductionDefinedChecker()); } /* * The following loop ensures that all target lexical states are * defined. Also piggybacking on this loop is the detection of * and in token productions. After reporting an * error, these entries are removed. Also checked are definitions * on inline private regular expressions. * This loop works slightly differently when USER_TOKEN_MANAGER * is set to true. In this case, occurrences are OK, while * regular expression specs generate a warning. */ for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); if (res.nextState != null) { if (lexstate_S2I.get(res.nextState) == null) { JavaCCErrors.semantic_error(res.nsTok, "Lexical state \"" + res.nextState + "\" has not been defined."); } } if (res.rexp instanceof REndOfFile) { // JavaCCErrors.semantic_error(res.rexp, "Badly placed ."); if (tp.lexStates != null) JavaCCErrors.semantic_error(res.rexp, "EOF action/state change must be specified for all states, " + "i.e., <*>TOKEN:."); if (tp.kind != TokenProduction.TOKEN) JavaCCErrors.semantic_error(res.rexp, "EOF action/state change can be specified only in a " + "TOKEN specification."); if (nextStateForEof != null || actForEof != null) JavaCCErrors.semantic_error(res.rexp, "Duplicate action/state change specification for ."); actForEof = res.act; nextStateForEof = res.nextState; prepareToRemove(respecs, res); } else if (tp.isExplicit && Options.getUserTokenManager()) { JavaCCErrors.warning(res.rexp, "Ignoring regular expression specification since " + "option USER_TOKEN_MANAGER has been set to true."); } else if (tp.isExplicit && !Options.getUserTokenManager() && res.rexp instanceof RJustName) { JavaCCErrors .warning( res.rexp, "Ignoring free-standing regular expression reference. " + "If you really want this, you must give it a different label as >."); prepareToRemove(respecs, res); } else if (!tp.isExplicit && res.rexp.private_rexp) { JavaCCErrors.semantic_error(res.rexp, "Private (#) regular expression cannot be defined within " + "grammar productions."); } } } removePreparedItems(); /* * The following loop inserts all names of regular expressions into * "named_tokens_table" and "ordered_named_tokens". * Duplications are flagged as errors. */ for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); if (!(res.rexp instanceof RJustName) && !res.rexp.label.equals("")) { final String s = res.rexp.label; final Object obj = named_tokens_table.put(s, res.rexp); if (obj != null) { JavaCCErrors.semantic_error(res.rexp, "Multiply defined lexical token name \"" + s + "\"."); } else { ordered_named_tokens.add(res.rexp); } if (lexstate_S2I.get(s) != null) { JavaCCErrors .semantic_error(res.rexp, "Lexical token name \"" + s + "\" is the same as " + "that of a lexical state."); } } } } /* * The following code merges multiple uses of the same string in the same * lexical state and produces error messages when there are multiple * explicit occurrences (outside the BNF) of the string in the same * lexical state, or when within BNF occurrences of a string are duplicates * of those that occur as non-TOKEN's (SKIP, MORE, SPECIAL_TOKEN) or private * regular expressions. While doing this, this code also numbers all * regular expressions (by setting their ordinal values), and populates the * table "names_of_tokens". */ tokenCount = 1; for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; if (tp.lexStates == null) { tp.lexStates = new String[lexstate_I2S.size()]; int i = 0; for (final Enumeration enum1 = lexstate_I2S.elements(); enum1.hasMoreElements();) { tp.lexStates[i++] = (enum1.nextElement()); } } @SuppressWarnings("unchecked") final Hashtable> table[] = new Hashtable[tp.lexStates.length]; for (int i = 0; i < tp.lexStates.length; i++) { table[i] = simple_tokens_table.get(tp.lexStates[i]); } for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); if (res.rexp instanceof RStringLiteral) { final RStringLiteral sl = (RStringLiteral) res.rexp; // This loop performs the checks and actions with respect to each lexical state. for (int i = 0; i < table.length; i++) { // Get table of all case variants of "sl.image" into table2. Hashtable table2 = (table[i].get(sl.image.toUpperCase())); if (table2 == null) { // There are no case variants of "sl.image" earlier than the current one. // So go ahead and insert this item. if (sl.ordinal == 0) { sl.ordinal = tokenCount++; } table2 = new Hashtable(); table2.put(sl.image, sl); table[i].put(sl.image.toUpperCase(), table2); } else if (hasIgnoreCase(table2, sl.image)) { // hasIgnoreCase sets "other" if it is found. // Since IGNORE_CASE version exists, current one is useless and bad. if (!sl.tpContext.isExplicit) { // inline BNF string is used earlier with an IGNORE_CASE. JavaCCErrors .semantic_error( sl, "String \"" + sl.image + "\" can never be matched " + "due to presence of more general (IGNORE_CASE) regular expression " + "at line " + other.getLine() + ", column " + other.getColumn() + "."); } else { // give the standard error message. JavaCCErrors.semantic_error(sl, "Duplicate definition of string token \"" + sl.image + "\" " + "can never be matched."); } } else if (sl.tpContext.ignoreCase) { // This has to be explicit. A warning needs to be given with respect // to all previous strings. String pos = ""; int count = 0; for (final Enumeration enum2 = table2.elements(); enum2 .hasMoreElements();) { final RegularExpression_ rexp = (enum2.nextElement()); if (count != 0) pos += ","; pos += " line " + rexp.getLine(); count++; } if (count == 1) { JavaCCErrors .warning( sl, "String with IGNORE_CASE is partially superceded by string at" + pos + "."); } else { JavaCCErrors .warning( sl, "String with IGNORE_CASE is partially superceded by strings at" + pos + "."); } // This entry is legitimate. So insert it. if (sl.ordinal == 0) { sl.ordinal = tokenCount++; } table2.put(sl.image, sl); // The above "put" may override an existing entry (that is not IGNORE_CASE) and that's // the desired behavior. } else { // The rest of the cases do not involve IGNORE_CASE. final RegularExpression_ re = table2.get(sl.image); if (re == null) { if (sl.ordinal == 0) { sl.ordinal = tokenCount++; } table2.put(sl.image, sl); } else if (tp.isExplicit) { // This is an error even if the first occurrence was implicit. if (tp.lexStates[i].equals("DEFAULT")) { JavaCCErrors.semantic_error(sl, "Duplicate definition of string token \"" + sl.image + "\"."); } else { JavaCCErrors.semantic_error(sl, "Duplicate definition of string token \"" + sl.image + "\" in lexical state \"" + tp.lexStates[i] + "\"."); } } else if (re.tpContext.kind != TokenProduction.TOKEN) { JavaCCErrors.semantic_error(sl, "String token \"" + sl.image + "\" has been defined as a \"" + TokenProduction.kindImage[re.tpContext.kind] + "\" token."); } else if (re.private_rexp) { JavaCCErrors .semantic_error(sl, "String token \"" + sl.image + "\" has been defined as a private regular expression."); } else { // This is now a legitimate reference to an existing RStringLiteral. // So we assign it a number and take it out of "rexprlist". // Therefore, if all is OK (no errors), then there will be only unequal // string literals in each lexical state. Note that the only way // this can be legal is if this is a string declared inline within the // BNF. Hence, it belongs to only one lexical state - namely "DEFAULT". sl.ordinal = re.ordinal; prepareToRemove(respecs, res); } } } } else if (!(res.rexp instanceof RJustName)) { res.rexp.ordinal = tokenCount++; } if (!(res.rexp instanceof RJustName) && !res.rexp.label.equals("")) { names_of_tokens.put(new Integer(res.rexp.ordinal), res.rexp.label); } if (!(res.rexp instanceof RJustName)) { rexps_of_tokens.put(new Integer(res.rexp.ordinal), res.rexp); } } } removePreparedItems(); /* * The following code performs a tree walk on all regular expressions * attaching links to "RJustName"s. Error messages are given if * undeclared names are used, or if "RJustNames" refer to private * regular expressions or to regular expressions of any kind other * than TOKEN. In addition, this loop also removes top level * "RJustName"s from "rexprlist". * This code is not executed if Options.getUserTokenManager() is set to * true. Instead the following block of code is executed. */ if (!Options.getUserTokenManager()) { final FixRJustNames frjn = new FixRJustNames(); for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); frjn.root = res.rexp; ExpansionTreeWalker.preOrderWalk(res.rexp, frjn); if (res.rexp instanceof RJustName) { prepareToRemove(respecs, res); } } } } removePreparedItems(); /* * The following code is executed only if Options.getUserTokenManager() is * set to true. This code visits all top-level "RJustName"s (ignores * "RJustName"s nested within regular expressions). Since regular expressions * are optional in this case, "RJustName"s without corresponding regular * expressions are given ordinal values here. If "RJustName"s refer to * a named regular expression, their ordinal values are set to reflect this. * All but one "RJustName" node is removed from the lists by the end of * execution of this code. */ if (Options.getUserTokenManager()) { for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); if (res.rexp instanceof RJustName) { final RJustName jn = (RJustName) res.rexp; final RegularExpression_ rexp = named_tokens_table.get(jn.label); if (rexp == null) { jn.ordinal = tokenCount++; named_tokens_table.put(jn.label, jn); ordered_named_tokens.add(jn); names_of_tokens.put(new Integer(jn.ordinal), jn.label); } else { jn.ordinal = rexp.ordinal; prepareToRemove(respecs, res); } } } } } removePreparedItems(); /* * The following code is executed only if Options.getUserTokenManager() is * set to true. This loop labels any unlabeled regular expression and * prints a warning that it is doing so. These labels are added to * "ordered_named_tokens" so that they may be generated into the ...Constants * file. */ if (Options.getUserTokenManager()) { for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); final Integer ii = new Integer(res.rexp.ordinal); if (names_of_tokens.get(ii) == null) { JavaCCErrors.warning(res.rexp, "Unlabeled regular expression cannot be referred to by " + "user generated token manager."); } } } } if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); // The following code sets the value of the "emptyPossible" field of NormalProduction // nodes. This field is initialized to false, and then the entire list of // productions is processed. This is repeated as long as at least one item // got updated from false to true in the pass. boolean emptyUpdate = true; while (emptyUpdate) { emptyUpdate = false; for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { final NormalProduction prod = it.next(); if (emptyExpansionExists(prod.getExpansion())) { if (!prod.isEmptyPossible()) { prod.setEmptyPossible(true); emptyUpdate = true; } } } } if (Options.getSanityCheck() && JavaCCErrors.get_error_count() == 0) { // The following code checks that all ZeroOrMore, ZeroOrOne, and OneOrMore nodes // do not contain expansions that can expand to the empty token list. for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { ExpansionTreeWalker.preOrderWalk((it.next()).getExpansion(), new EmptyChecker()); } // The following code goes through the productions and adds pointers to other // productions that it can expand to without consuming any tokens. Once this is // done, a left-recursion check can be performed. for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { final NormalProduction prod = it.next(); addLeftMost(prod, prod.getExpansion()); } // Now the following loop calls a recursive walk routine that searches for // actual left recursions. The way the algorithm is coded, once a node has // been determined to participate in a left recursive loop, it is not tried // in any other loop. for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { final NormalProduction prod = it.next(); if (prod.getWalkStatus() == 0) { prodWalk(prod); } } // Now we do a similar, but much simpler walk for the regular expression part of // the grammar. Here we are looking for any kind of loop, not just left recursions, // so we only need to do the equivalent of the above walk. // This is not done if option USER_TOKEN_MANAGER is set to true. if (!Options.getUserTokenManager()) { for (final Iterator it = rexprlist.iterator(); it.hasNext();) { final TokenProduction tp = (it.next()); final List respecs = tp.respecs; for (final Iterator it1 = respecs.iterator(); it1.hasNext();) { final RegExprSpec_ res = (it1.next()); final RegularExpression_ rexp = res.rexp; if (rexp.walkStatus == 0) { rexp.walkStatus = -1; if (rexpWalk(rexp)) { loopString = "..." + rexp.label + "... --> " + loopString; JavaCCErrors.semantic_error(rexp, "Loop in regular expression detected: \"" + loopString + "\""); } rexp.walkStatus = 1; } } } } /* * The following code performs the lookahead ambiguity checking. */ if (JavaCCErrors.get_error_count() == 0) { for (final Iterator it = bnfproductions.iterator(); it.hasNext();) { ExpansionTreeWalker.preOrderWalk((it.next()).getExpansion(), new LookaheadChecker()); } } } // matches "if (Options.getSanityCheck()) {" if (JavaCCErrors.get_error_count() != 0) throw new MetaParseException(); } public static RegularExpression_ other; // Checks to see if the "str" is superceded by another equal (except case) string // in table. public static boolean hasIgnoreCase(final Hashtable table, final String str) { RegularExpression_ rexp; rexp = (table.get(str)); if (rexp != null && !rexp.tpContext.ignoreCase) { return false; } for (final Enumeration enumeration = table.elements(); enumeration .hasMoreElements();) { rexp = (enumeration.nextElement()); if (rexp.tpContext.ignoreCase) { other = rexp; return true; } } return false; } // returns true if "exp" can expand to the empty string, returns false otherwise. public static boolean emptyExpansionExists(final Expansion_ exp) { if (exp instanceof NonTerminal) { return ((NonTerminal) exp).getProd().isEmptyPossible(); } else if (exp instanceof Action) { return true; } else if (exp instanceof RegularExpression_) { return false; } else if (exp instanceof OneOrMore) { return emptyExpansionExists(((OneOrMore) exp).expansion); } else if (exp instanceof ZeroOrMore || exp instanceof ZeroOrOne) { return true; } else if (exp instanceof Lookahead) { return true; } else if (exp instanceof Choice) { for (final Iterator it = ((Choice) exp).getChoices().iterator(); it.hasNext();) { if (emptyExpansionExists(it.next())) { return true; } } return false; } else if (exp instanceof Sequence) { for (final Iterator it = ((Sequence) exp).units.iterator(); it.hasNext();) { if (!emptyExpansionExists(it.next())) { return false; } } return true; } else if (exp instanceof TryBlock) { return emptyExpansionExists(((TryBlock) exp).exp); } else { return false; // This should be dead code. } } // Updates prod.leftExpansions based on a walk of exp. static private void addLeftMost(final NormalProduction prod, final Expansion_ exp) { if (exp instanceof NonTerminal) { for (int i = 0; i < prod.leIndex; i++) { if (prod.getLeftExpansions()[i] == ((NonTerminal) exp).getProd()) { return; } } if (prod.leIndex == prod.getLeftExpansions().length) { final NormalProduction[] newle = new NormalProduction[prod.leIndex * 2]; System.arraycopy(prod.getLeftExpansions(), 0, newle, 0, prod.leIndex); prod.setLeftExpansions(newle); } prod.getLeftExpansions()[prod.leIndex++] = ((NonTerminal) exp).getProd(); } else if (exp instanceof OneOrMore) { addLeftMost(prod, ((OneOrMore) exp).expansion); } else if (exp instanceof ZeroOrMore) { addLeftMost(prod, ((ZeroOrMore) exp).expansion); } else if (exp instanceof ZeroOrOne) { addLeftMost(prod, ((ZeroOrOne) exp).expansion); } else if (exp instanceof Choice) { for (final Iterator it = ((Choice) exp).getChoices().iterator(); it.hasNext();) { addLeftMost(prod, it.next()); } } else if (exp instanceof Sequence) { for (final Iterator it = ((Sequence) exp).units.iterator(); it.hasNext();) { final Expansion_ e = it.next(); addLeftMost(prod, e); if (!emptyExpansionExists(e)) { break; } } } else if (exp instanceof TryBlock) { addLeftMost(prod, ((TryBlock) exp).exp); } } // The string in which the following methods store information. static private String loopString; // Returns true to indicate an unraveling of a detected left recursion loop, // and returns false otherwise. static private boolean prodWalk(final NormalProduction prod) { prod.setWalkStatus(-1); for (int i = 0; i < prod.leIndex; i++) { if (prod.getLeftExpansions()[i].getWalkStatus() == -1) { prod.getLeftExpansions()[i].setWalkStatus(-2); loopString = prod.getLhs() + "... --> " + prod.getLeftExpansions()[i].getLhs() + "..."; if (prod.getWalkStatus() == -2) { prod.setWalkStatus(1); JavaCCErrors.semantic_error(prod, "Left recursion detected: \"" + loopString + "\""); return false; } else { prod.setWalkStatus(1); return true; } } else if (prod.getLeftExpansions()[i].getWalkStatus() == 0) { if (prodWalk(prod.getLeftExpansions()[i])) { loopString = prod.getLhs() + "... --> " + loopString; if (prod.getWalkStatus() == -2) { prod.setWalkStatus(1); JavaCCErrors.semantic_error(prod, "Left recursion detected: \"" + loopString + "\""); return false; } else { prod.setWalkStatus(1); return true; } } } } prod.setWalkStatus(1); return false; } // Returns true to indicate an unraveling of a detected loop, // and returns false otherwise. static private boolean rexpWalk(final RegularExpression_ rexp) { if (rexp instanceof RJustName) { final RJustName jn = (RJustName) rexp; if (jn.regexpr.walkStatus == -1) { jn.regexpr.walkStatus = -2; loopString = "..." + jn.regexpr.label + "..."; // Note: Only the regexpr's of RJustName nodes and the top leve // regexpr's can have labels. Hence it is only in these cases that // the labels are checked for to be added to the loopString. return true; } else if (jn.regexpr.walkStatus == 0) { jn.regexpr.walkStatus = -1; if (rexpWalk(jn.regexpr)) { loopString = "..." + jn.regexpr.label + "... --> " + loopString; if (jn.regexpr.walkStatus == -2) { jn.regexpr.walkStatus = 1; JavaCCErrors.semantic_error(jn.regexpr, "Loop in regular expression detected: \"" + loopString + "\""); return false; } else { jn.regexpr.walkStatus = 1; return true; } } else { jn.regexpr.walkStatus = 1; return false; } } } else if (rexp instanceof RChoice) { for (final Iterator it = ((RChoice) rexp).getChoices().iterator(); it .hasNext();) { if (rexpWalk(it.next())) { return true; } } return false; } else if (rexp instanceof RSequence) { for (final Iterator it = ((RSequence) rexp).units.iterator(); it .hasNext();) { if (rexpWalk(it.next())) { return true; } } return false; } else if (rexp instanceof ROneOrMore) { return rexpWalk(((ROneOrMore) rexp).regexpr); } else if (rexp instanceof RZeroOrMore) { return rexpWalk(((RZeroOrMore) rexp).regexpr); } else if (rexp instanceof RZeroOrOne) { return rexpWalk(((RZeroOrOne) rexp).regexpr); } else if (rexp instanceof RRepetitionRange) { return rexpWalk(((RRepetitionRange) rexp).regexpr); } return false; } /** * Objects of this class are created from class Semanticize to work on * references to regular expressions from RJustName's. */ static class FixRJustNames extends JavaCCGlobals implements TreeWalkerOp { public RegularExpression_ root; public boolean goDeeper(@SuppressWarnings("unused") final Expansion_ e) { return true; } public void action(final Expansion_ e) { if (e instanceof RJustName) { final RJustName jn = (RJustName) e; final RegularExpression_ rexp = named_tokens_table.get(jn.label); if (rexp == null) { JavaCCErrors.semantic_error(e, "Undefined lexical token name \"" + jn.label + "\"."); } else if (jn == root && !jn.tpContext.isExplicit && rexp.private_rexp) { JavaCCErrors.semantic_error(e, "Token name \"" + jn.label + "\" refers to a private " + "(with a #) regular expression."); } else if (jn == root && !jn.tpContext.isExplicit && rexp.tpContext.kind != TokenProduction.TOKEN) { JavaCCErrors.semantic_error(e, "Token name \"" + jn.label + "\" refers to a non-token " + "(SKIP, MORE, IGNORE_IN_BNF) regular expression."); } else { jn.ordinal = rexp.ordinal; jn.regexpr = rexp; } } } } static class LookaheadFixer extends JavaCCGlobals implements TreeWalkerOp { public boolean goDeeper(final Expansion_ e) { if (e instanceof RegularExpression_) { return false; } else { return true; } } public void action(final Expansion_ e) { if (e instanceof Sequence) { if (e.parent instanceof Choice || e.parent instanceof ZeroOrMore || e.parent instanceof OneOrMore || e.parent instanceof ZeroOrOne) { return; } final Sequence seq = (Sequence) e; final Lookahead la = (Lookahead) (seq.units.get(0)); if (!la.isExplicit()) { return; } // Create a singleton choice with an empty action. final Choice ch = new Choice(); ch.setLine(la.getLine()); ch.setColumn(la.getColumn()); ch.parent = seq; final Sequence seq1 = new Sequence(); seq1.setLine(la.getLine()); seq1.setColumn(la.getColumn()); seq1.parent = ch; seq1.units.add(la); la.parent = seq1; final Action act = new Action(); act.setLine(la.getLine()); act.setColumn(la.getColumn()); act.parent = seq1; seq1.units.add(act); ch.getChoices().add(seq1); if (la.getAmount() != 0) { if (la.getActionTokens().size() != 0) { JavaCCErrors.warning(la, "Encountered LOOKAHEAD(...) at a non-choice location. " + "Only semantic lookahead will be considered here."); } else { JavaCCErrors .warning(la, "Encountered LOOKAHEAD(...) at a non-choice location. This will be ignored."); } } // Now we have moved the lookahead into the singleton choice. Now create // a new dummy lookahead node to replace this one at its original location. final Lookahead la1 = new Lookahead(); la1.setExplicit(false); la1.setLine(la.getLine()); la1.setColumn(la.getColumn()); la1.parent = seq; // Now set the la_expansion field of la and la1 with a dummy expansion (we use EOF). la.setLaExpansion(new REndOfFile()); la1.setLaExpansion(new REndOfFile()); seq.units.set(0, la1); seq.units.add(1, ch); } } } static class ProductionDefinedChecker extends JavaCCGlobals implements TreeWalkerOp { public boolean goDeeper(final Expansion_ e) { if (e instanceof RegularExpression_) { return false; } else { return true; } } public void action(final Expansion_ e) { if (e instanceof NonTerminal) { final NonTerminal nt = (NonTerminal) e; if ((nt.setProd(production_table.get(nt.getName()))) == null) { JavaCCErrors.semantic_error(e, "Non-terminal " + nt.getName() + " has not been defined."); } else { nt.getProd().getParents().add(nt); } } } } static class EmptyChecker extends JavaCCGlobals implements TreeWalkerOp { public boolean goDeeper(final Expansion_ e) { if (e instanceof RegularExpression_) { return false; } else { return true; } } public void action(final Expansion_ e) { if (e instanceof OneOrMore) { if (Semanticize.emptyExpansionExists(((OneOrMore) e).expansion)) { JavaCCErrors .semantic_error(e, "Expansion_ within \"(...)+\" can be matched by empty string."); } } else if (e instanceof ZeroOrMore) { if (Semanticize.emptyExpansionExists(((ZeroOrMore) e).expansion)) { JavaCCErrors .semantic_error(e, "Expansion_ within \"(...)*\" can be matched by empty string."); } } else if (e instanceof ZeroOrOne) { if (Semanticize.emptyExpansionExists(((ZeroOrOne) e).expansion)) { JavaCCErrors .semantic_error(e, "Expansion_ within \"(...)?\" can be matched by empty string."); } } } } static class LookaheadChecker extends JavaCCGlobals implements TreeWalkerOp { public boolean goDeeper(final Expansion_ e) { if (e instanceof RegularExpression_) { return false; } else if (e instanceof Lookahead) { return false; } else { return true; } } public void action(final Expansion_ e) { if (e instanceof Choice) { if (Options.getLookahead() == 1 || Options.getForceLaCheck()) { LookaheadCalc.choiceCalc((Choice) e); } } else if (e instanceof OneOrMore) { final OneOrMore exp = (OneOrMore) e; if (Options.getForceLaCheck() || (implicitLA(exp.expansion) && Options.getLookahead() == 1)) { LookaheadCalc.ebnfCalc(exp, exp.expansion); } } else if (e instanceof ZeroOrMore) { final ZeroOrMore exp = (ZeroOrMore) e; if (Options.getForceLaCheck() || (implicitLA(exp.expansion) && Options.getLookahead() == 1)) { LookaheadCalc.ebnfCalc(exp, exp.expansion); } } else if (e instanceof ZeroOrOne) { final ZeroOrOne exp = (ZeroOrOne) e; if (Options.getForceLaCheck() || (implicitLA(exp.expansion) && Options.getLookahead() == 1)) { LookaheadCalc.ebnfCalc(exp, exp.expansion); } } } static boolean implicitLA(final Expansion_ exp) { if (!(exp instanceof Sequence)) { return true; } final Sequence seq = (Sequence) exp; final Object obj = seq.units.get(0); if (!(obj instanceof Lookahead)) { return true; } final Lookahead la = (Lookahead) obj; return !la.isExplicit(); } } public static void reInit() { removeList = new ArrayList>(); itemList = new ArrayList(); other = null; loopString = null; } } jtb-1.4.4/EDU/purdue/jtb/parser/RRepetitionRange.java0000644000175000017500000000553511360636752022220 0ustar cavedoncavedon/* Copyright (c) 2006, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package EDU.purdue.jtb.parser; import java.util.ArrayList; import java.util.List; /** * Describes one-or-more regular expressions (). * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar */ public class RRepetitionRange extends RegularExpression_ { /** * The regular expression which is repeated one or more times. */ public RegularExpression_ regexpr; public int min = 0; public int max = -1; public boolean hasMax; // ModMMa : added to get rid of 'instanceof' in ExpansionTreeWalker public RRepetitionRange() { expType = EXP_TYPE.R_REPETITION_RANGE; } @Override public Nfa GenerateNfa(final boolean ignoreCase) { final List units = new ArrayList(); RSequence seq; int i; for (i = 0; i < min; i++) { units.add(regexpr); } if (hasMax && max == -1) // Unlimited { final RZeroOrMore zoo = new RZeroOrMore(); zoo.regexpr = regexpr; units.add(zoo); } while (i++ < max) { final RZeroOrOne zoo = new RZeroOrOne(); zoo.regexpr = regexpr; units.add(zoo); } seq = new RSequence(units); return seq.GenerateNfa(ignoreCase); } } jtb-1.4.4/EDU/purdue/jtb/jtbgram.jtb0000644000175000017500000024005211360636752016762 0ustar cavedoncavedon/** * JavaCC Grammar used by JTB. * * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.x : 05-11/2009 : MMa * adapted from JavaCC v4.2 grammar (JavaCC.jj) * to fit with JTB.java and * to use the try-ExpansionChoices-catch-finally syntax * through the ExpansionUnitInTCF production */ /* * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * JTB 1.3.x is a derivation of JTB 1.2.1 which has the following * license: **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao and Jens Palsberg. No charge may be made * for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ // // Java Tree Builder (JTB) Grammar // // Converted from the JavaCC 0.6 grammar in the documentation. // Appended to the Java1.1.jj grammar provided in JavaCC. // // AUTHOR: Kevin Tao, taokr@cs.purdue.edu // // This grammar is basically the JavaCC grammar, adapted from the // documentation. A few changes have been made to fix possible bugs in the // grammar. // /***************************************************************************/ /* * * Copyright (C) 1996, 1997 Sun Microsystems Inc. * * Use of this file and the system it is part of is constrained by the * file COPYRIGHT in the root directory of this system. You may, however, * make any modifications you wish to this file. * * Java files generated by running JavaCC on this file (or modified versions * of this file) may be used in exactly the same manner as Java files * generated from any grammar developed by you. * * Author: Sriram Sankar * Date: 3/5/97 * * This file contains a Java grammar and actions that implement a front-end. * */ options { // MMa : added (does not exist in JavaCC.jj nor in jtbgram.jj, but needed for Eclipse plugin) OUTPUT_DIRECTORY = "parser"; // MMa : kept (from JavaCC.jj and jtbgram.jj) JAVA_UNICODE_ESCAPE = true; // MMa : kept (from JavaCC.jj, but it does not exist in jtbgram.jj) STATIC = false; } // MMa : adapted from JavaCC.jj to fit to JTB parser name, package, imports PARSER_BEGIN(JTBParser) package EDU.purdue.jtb.parser; import java.util.List; import java.util.ArrayList; /** * This file contains the code for JavaCCParser generated * by JavaCCParser itself. */ // MMa : adapted from JavaCC.jj to fit to JTB class name public class JTBParser extends JavaCCParserInternals { /** * The name of the parser class. */ String parser_class_name; /** * This flag is set to true when the part between PARSER_BEGIN and * PARSER_END is being parsed. */ boolean processing_cu = false; /** * The level of class nesting. */ int class_nesting = 0; /** * This int variable is incremented while parsing local lookaheads. * Hence it keeps track of *syntactic* lookahead nesting. * This is used to provide warnings when actions and nested lookaheads * are used in syntactic lookahead productions. This is to prevent * typos such as leaving out the comma in LOOKAHEAD( foo(), {check()} ). */ int inLocalLA = 0; /** * Set to true when the parser is within an action. */ boolean inAction = false; /** * This flag keeps track of whether or not return and throw * statements have been patched during the parsing of a production. * The value of this flag is assigned the field with the same * name in BNFProduction_.java. */ boolean jumpPatched = false; /* * Returns true if the next token is not in the FOLLOW list of "expansion". * It is used to decide when the end of an "expansion" has been reached. */ private boolean notTailOfExpansionUnit() { final Token t = getToken(1); if (t.kind == BIT_OR || t.kind == COMMA || t.kind == RPAREN || t.kind == RBRACE || t.kind == RBRACKET) return false; return true; } /** * Class to hold modifiers. */ static public final class ModifierSet { /* Definitions of the bits in the modifiers field */ public static final int M_PUBLIC = 0x0001; public static final int M_PROTECTED = 0x0002; public static final int M_PRIVATE = 0x0004; public static final int M_ABSTRACT = 0x0008; public static final int M_STATIC = 0x0010; public static final int M_FINAL = 0x0020; public static final int M_SYNCHRONIZED = 0x0040; public static final int M_NATIVE = 0x0080; public static final int M_TRANSIENT = 0x0100; public static final int M_VOLATILE = 0x0200; public static final int M_STRICTFP = 0x1000; /* A set of accessors that indicate whether the specified modifier is in the set */ public boolean isPublic(int modifiers) { return (modifiers & M_PUBLIC) != 0; } public boolean isProtected(int modifiers) { return (modifiers & M_PROTECTED) != 0; } public boolean isPrivate(int modifiers) { return (modifiers & M_PRIVATE) != 0; } public boolean isStatic(int modifiers) { return (modifiers & M_STATIC) != 0; } public boolean isAbstract(int modifiers) { return (modifiers & M_ABSTRACT) != 0; } public boolean isFinal(int modifiers) { return (modifiers & M_FINAL) != 0; } public boolean isNative(int modifiers) { return (modifiers & M_NATIVE) != 0; } public boolean isStrictfp(int modifiers) { return (modifiers & M_STRICTFP) != 0; } public boolean isSynchronized(int modifiers) { return (modifiers & M_SYNCHRONIZED) != 0; } public boolean isTransient(int modifiers) { return (modifiers & M_TRANSIENT) != 0; } public boolean isVolatile(int modifiers) { return (modifiers & M_VOLATILE) != 0; } /* Removes the given modifier */ static int removeModifier(int modifiers, int mod) { return modifiers & ~mod; } } } // MMa : adapted from JavaCC.jj to fit to JTB parser name PARSER_END(JTBParser) TOKEN_MGR_DECLS : { int size = 20; int beginLine[] = new int[size]; int beginCol[] = new int[size]; int depth = 0; final void saveBeginLineCol(final int l, final int c) { if (depth == size) { size += 10; final int tmpbeginLine[] = new int[size]; final int tmpbeginCol [] = new int[size]; System.arraycopy(beginLine, 0, tmpbeginLine, 0, depth); System.arraycopy(beginCol, 0, tmpbeginCol, 0, depth); beginLine = tmpbeginLine; beginCol = tmpbeginCol; } beginLine[depth] = l; beginCol[depth] = c; depth++; } final void restoreBeginLineCol() { depth--; input_stream.adjustBeginLineColumn(beginLine[depth], beginCol[depth]); } } /********************************************** * THE JAVACC TOKEN SPECIFICATION STARTS HERE * **********************************************/ /* JAVACC RESERVED WORDS: These are the only tokens in JavaCC but not in Java */ TOKEN : { // "options" is no longer reserved (see issue 126). // < _OPTIONS: "options" > < _LOOKAHEAD : "LOOKAHEAD" > | < _IGNORE_CASE : "IGNORE_CASE" > | < _PARSER_BEGIN : "PARSER_BEGIN" > | < _PARSER_END : "PARSER_END" > | < _JAVACODE : "JAVACODE" > | < _TOKEN : "TOKEN" > | < _SPECIAL_TOKEN : "SPECIAL_TOKEN" > | < _MORE : "MORE" > | < _SKIP : "SKIP" > | < _TOKEN_MGR_DECLS : "TOKEN_MGR_DECLS" > | < _EOF : "EOF" > } /* * The remainder of the tokens are exactly (except for the removal of tokens * containing ">>" and "<<") as in the Java grammar and must be diff equivalent * (again with the exceptions above) to it. */ /* WHITE SPACE */ SKIP : { " " | "\t" | "\n" | "\r" | "\f" | "/*@egen*/" : AFTER_EGEN } < AFTER_EGEN > SKIP : { < ~[ ] > { restoreBeginLineCol(); input_stream.backup(1); } : DEFAULT } /* COMMENTS */ MORE : { "//" : IN_SINGLE_LINE_COMMENT | < "/**" ~[ "/" ] > { input_stream.backup(1); } : IN_FORMAL_COMMENT | "/*" : IN_MULTI_LINE_COMMENT | "/*@bgen(jjtree" { saveBeginLineCol(input_stream.getBeginLine(), input_stream.getBeginColumn()); } : IN_MULTI_LINE_COMMENT } < IN_SINGLE_LINE_COMMENT > SPECIAL_TOKEN : { < SINGLE_LINE_COMMENT : "\n" | "\r" | "\r\n" > : DEFAULT } < IN_FORMAL_COMMENT > SPECIAL_TOKEN : { < FORMAL_COMMENT : "*/" > : DEFAULT } < IN_MULTI_LINE_COMMENT > SPECIAL_TOKEN : { < MULTI_LINE_COMMENT : "*/" > : DEFAULT } < IN_SINGLE_LINE_COMMENT, IN_FORMAL_COMMENT, IN_MULTI_LINE_COMMENT > MORE : { < ~[ ] > } /* JAVA RESERVED WORDS AND LITERALS */ TOKEN : { < ABSTRACT : "abstract" > | < ASSERT : "assert" > | < BOOLEAN : "boolean" > | < BREAK : "break" > | < BYTE : "byte" > | < CASE : "case" > | < CATCH : "catch" > | < CHAR : "char" > | < CLASS : "class" > | < CONST : "const" > | < CONTINUE : "continue" > | < _DEFAULT : "default" > | < DO : "do" > | < DOUBLE : "double" > | < ELSE : "else" > | < ENUM : "enum" > | < EXTENDS : "extends" > | < FALSE : "false" > | < FINAL : "final" > | < FINALLY : "finally" > | < FLOAT : "float" > | < FOR : "for" > | < GOTO : "goto" > | < IF : "if" > | < IMPLEMENTS : "implements" > | < IMPORT : "import" > | < INSTANCEOF : "instanceof" > | < INT : "int" > | < INTERFACE : "interface" > | < LONG : "long" > | < NATIVE : "native" > | < NEW : "new" > | < NULL : "null" > | < PACKAGE : "package" > | < PRIVATE : "private" > | < PROTECTED : "protected" > | < PUBLIC : "public" > | < RETURN : "return" > | < SHORT : "short" > | < STATIC : "static" > | < STRICTFP : "strictfp" > | < SUPER : "super" > | < SWITCH : "switch" > | < SYNCHRONIZED : "synchronized" > | < THIS : "this" > | < THROW : "throw" > | < THROWS : "throws" > | < TRANSIENT : "transient" > | < TRUE : "true" > | < TRY : "try" > | < VOID : "void" > | < VOLATILE : "volatile" > | < WHILE : "while" > } /* JAVA LITERALS */ TOKEN : { < INTEGER_LITERAL : < DECIMAL_LITERAL > ([ "l", "L" ])? | < HEX_LITERAL > ([ "l", "L" ])? | < OCTAL_LITERAL > ([ "l", "L" ])? > | < #DECIMAL_LITERAL : [ "1"-"9" ] ([ "0"-"9" ])* > | < #HEX_LITERAL : "0" [ "x", "X" ] ([ "0"-"9", "a"-"f", "A"-"F" ])+ > | < #OCTAL_LITERAL : "0" ([ "0"-"7" ])* > | < FLOATING_POINT_LITERAL : < DECIMAL_FLOATING_POINT_LITERAL > | < HEXADECIMAL_FLOATING_POINT_LITERAL > > | < #DECIMAL_FLOATING_POINT_LITERAL : ([ "0"-"9" ])+ "." ([ "0"-"9" ])* (< DECIMAL_EXPONENT >)? ([ "f", "F", "d", "D" ])? | "." ([ "0"-"9" ])+ (< DECIMAL_EXPONENT >)? ([ "f", "F", "d", "D" ])? | ([ "0"-"9" ])+ < DECIMAL_EXPONENT > ([ "f", "F", "d", "D" ])? | ([ "0"-"9" ])+ (< DECIMAL_EXPONENT >)? [ "f", "F", "d", "D" ] > | < #DECIMAL_EXPONENT : [ "e", "E" ] ([ "+", "-" ])? ([ "0"-"9" ])+ > | < #HEXADECIMAL_FLOATING_POINT_LITERAL : "0" [ "x", "X" ] ([ "0"-"9", "a"-"f", "A"-"F" ])+ (".")? < HEXADECIMAL_EXPONENT > ([ "f", "F", "d", "D" ])? | "0" [ "x", "X" ] ([ "0"-"9", "a"-"f", "A"-"F" ])* "." ([ "0"-"9", "a"-"f", "A"-"F" ])+ < HEXADECIMAL_EXPONENT > ([ "f", "F", "d", "D" ])? > | < #HEXADECIMAL_EXPONENT : [ "p", "P" ] ([ "+", "-" ])? ([ "0"-"9" ])+ > | < CHARACTER_LITERAL : "'" ( (~[ "'", "\\", "\n", "\r" ]) | ( "\\" ( [ "n", "t", "b", "r", "f", "\\", "'", "\"" ] | [ "0"-"7" ] ([ "0"-"7" ])? | [ "0"-"3" ] [ "0"-"7" ] [ "0"-"7" ] ) ) ) "'" > | < STRING_LITERAL : "\"" ( (~[ "\"", "\\", "\n", "\r" ]) | ( "\\" ( [ "n", "t", "b", "r", "f", "\\", "'", "\"" ] | [ "0"-"7" ] ([ "0"-"7" ])? | [ "0"-"3" ] [ "0"-"7" ] [ "0"-"7" ] ) ) )* "\"" > } /* SEPARATORS */ TOKEN : { < LPAREN : "(" > | < RPAREN : ")" > | < LBRACE : "{" > | < RBRACE : "}" > | < LBRACKET : "[" > | < RBRACKET : "]" > | < SEMICOLON : ";" > | < COMMA : "," > | < DOT : "." > } /* OPERATORS */ TOKEN : { < ASSIGN : "=" > //| < GT: ">" > | < LT : "<" > | < BANG : "!" > | < TILDE : "~" > | < HOOK : "?" > | < COLON : ":" > | < EQ : "==" > | < LE : "<=" > | < GE : ">=" > | < NE : "!=" > | < SC_OR : "||" > | < SC_AND : "&&" > | < INCR : "++" > | < DECR : "--" > | < PLUS : "+" > | < MINUS : "-" > | < STAR : "*" > | < SLASH : "/" > | < BIT_AND : "&" > | < BIT_OR : "|" > | < XOR : "^" > | < REM : "%" > // | < LSHIFT: "<<" > // | < RSIGNEDSHIFT: ">>" > // | < RUNSIGNEDSHIFT: ">>>" > | < PLUSASSIGN : "+=" > | < MINUSASSIGN : "-=" > | < STARASSIGN : "*=" > | < SLASHASSIGN : "/=" > | < ANDASSIGN : "&=" > | < ORASSIGN : "|=" > | < XORASSIGN : "^=" > | < REMASSIGN : "%=" > // | < LSHIFTASSIGN: "<<=" > // | < RSIGNEDSHIFTASSIGN: ">>=" > // | < RUNSIGNEDSHIFTASSIGN: ">>>=" > } /* >'s need special attention due to generics syntax. */ TOKEN : { < RUNSIGNEDSHIFT : ">>>" > { matchedToken.kind = GT; ((Token.GTToken) matchedToken).realKind = RUNSIGNEDSHIFT; input_stream.backup(2); matchedToken.image = ">"; } | < RSIGNEDSHIFT : ">>" > { matchedToken.kind = GT; ((Token.GTToken) matchedToken).realKind = RSIGNEDSHIFT; input_stream.backup(1); matchedToken.image = ">"; } | < GT : ">" > } /************************************************ * THE JAVACC GRAMMAR SPECIFICATION STARTS HERE * ************************************************/ // ModMMa: added to test try-expansion_choices-catch-finally syntax void AFancyProduction() : { // INode ls = null; } { try { ( ( Annotation() )* ( LOOKAHEAD(2) // ls = LabeledStatement() LabeledStatement() | AssertStatement() | Block(null) | EmptyStatement() | StatementExpression() ";" | SwitchStatement() | TryStatement() ) [ MarkerAnnotation() ] ) } catch (Exception fancy_e) { fancy_e = null; } catch (Throwable fancy_t) { fancy_t = null; } finally { String fancy_s = ""; if (fancy_s == " ") fancy_s = null; // if (ls != null) // ls = null; } } // MMa : changed all javacc_input into JavaCCInput to conform to class name convention void JavaCCInput() : { String id1, id2; initialize(); // MMa : added to JavaCC as called in parser.Main in Javacc 4.2 Options.init(); } { JavaCCOptions() "PARSER_BEGIN" "(" id1 = Identifier() { addcuname(id1); } ")" { processing_cu = true; parser_class_name = id1; } CompilationUnit() { processing_cu = false; } "PARSER_END" "(" id2 = Identifier() { compare(getToken(0), id1, id2); } ")" ( Production() )+ } // MMa : changed all javacc_options into JavaCCOptions to conform to class name convention void JavaCCOptions() : {} { [ LOOKAHEAD({ getToken(1).image.equals("options") }) "options" "{" ( OptionBinding() )* "}" ] { Options.normalize(); } } // MMa : changed all option_binding into OptionBinding to conform to class name convention void OptionBinding() : { String option_name; int int_val; boolean bool_val; String string_val; Token t = getToken(1); } { ( < IDENTIFIER > | "LOOKAHEAD" | "IGNORE_CASE" | "static" ) { option_name = t.image; } "=" ( int_val = IntegerLiteral() { Options.setInputFileOption(t, getToken(0), option_name, new Integer(int_val)); } | bool_val = BooleanLiteral() { Options.setInputFileOption(t, getToken(0), option_name, new Boolean(bool_val)); } | string_val = StringLiteral() { Options.setInputFileOption(t, getToken(0), option_name, string_val); } ) ";" } // MMa : changed all production into Production to conform to class name convention void Production() : {} { LOOKAHEAD(1) /* * Since JAVACODE is both a JavaCC reserved word and a Java identifier, * we need to give preference to "JavaCodeProduction" over * "BNFProduction". */ JavaCodeProduction() | LOOKAHEAD(1) /* * Since SKIP, TOKEN, etc. are both JavaCC reserved words and Java * identifiers, we need to give preference to "RegularExprProduction" * over "BNFProduction". */ RegularExprProduction() | LOOKAHEAD(1) /* * Since TOKEN_MGR_DECLS is both a JavaCC reserved word and a Java identifier, * we need to give preference to "TokenManagerDecls" over * "BNFProduction". */ TokenManagerDecls() | BNFProduction() } // MMa : changed all JavaCodeProduction into JavaCodeProduction_ (JavaCC specific class) // MMa : changed all javacode_production into JavaCodeProduction to conform to class name convention void JavaCodeProduction() : { JavaCodeProduction_ p = new JavaCodeProduction_(); String lhs; Token t = getToken(1); p.setFirstToken(t); List excName; p.setThrowsList(new ArrayList>()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); } { "JAVACODE" AccessModifier(p) ResultType(p.getReturnTypeTokens()) lhs = Identifier() { p.setLhs(lhs); } FormalParameters(p.getParameterListTokens()) [ "throws" { excName = new ArrayList(); } Name(excName) { p.getThrowsList().add(excName); } ( { excName = new ArrayList(); } "," Name(excName) { p.getThrowsList().add(excName); } )* ] Block ( p.getCodeTokens() ) { p.setLastToken(getToken(0)); addproduction(p); } } // MMa : changed all BNFProduction into BNFProduction_ (JavaCC specific class) // MMa : changed all bnf_production into BNFProduction to conform to class name convention void BNFProduction() : { BNFProduction_ p = new BNFProduction_(); Container c = new Container(); Token t = getToken(1); p.setFirstToken(t); List excName; String lhs; p.setThrowsList(new ArrayList >()); p.setLine(t.beginLine); p.setColumn(t.beginColumn); jumpPatched = false; } { AccessModifier(p) ResultType(p.getReturnTypeTokens()) lhs = Identifier() { p.setLhs(lhs); } FormalParameters(p.getParameterListTokens()) [ "throws" { excName = new ArrayList(); } Name(excName) { p.getThrowsList().add(excName); } ( { excName = new ArrayList(); } "," Name(excName) { p.getThrowsList().add(excName); } )* ] ":" Block ( p.getDeclarationTokens() ) "{" ExpansionChoices(c) t = "}" { p.setLastToken(t); p.setJumpPatched(jumpPatched); production_addexpansion(p, (Expansion_) (c.member)); addproduction(p); } } void AccessModifier(NormalProduction p) : { Token t = null; } { ( t = "public" | t = "protected" | t = "private" )? { if (t != null) { p.setAccessMod(t.image); } } } // MMa : changed all regular_expr_production into RegularExprProduction to conform to class name convention void RegularExprProduction() : { TokenProduction p = new TokenProduction(); List states; Token t = p.firstToken = getToken(1); p.setLine(t.beginLine); p.setColumn(t.beginColumn); } { { // set p.lexStates assuming there is no state spec. // and then override if necessary. p.lexStates = new String [ ] { "DEFAULT" }; } [ LOOKAHEAD(2) "<" "*" ">" { p.lexStates = null; } | "<" { states = new ArrayList(); } t = < IDENTIFIER > { states.add(t.image); } ( "," t = < IDENTIFIER > { states.add(t.image); } )* ">" { p.lexStates = new String [ states.size() ]; for (int i = 0; // ModMMa : workaround for sf plugin color syntaxing problem // i < states.size(); i != states.size(); i++) { p.lexStates [ i ] = states.get(i); } } ] RegExprKind(p) { if (p.kind != TokenProduction.TOKEN && Options.getUserTokenManager()) { JavaCCErrors.warning(getToken(0), "Regular expression is being treated as if it were a TOKEN since option USER_TOKEN_MANAGER has been set to true."); } } [ "[" t = "IGNORE_CASE" "]" { p.ignoreCase = true; if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring \"IGNORE_CASE\" specification since option USER_TOKEN_MANAGER has been set to true."); } } ] ":" "{" RegExprSpec(p) ( "|" RegExprSpec(p) )* t = "}" { p.lastToken = t; addregexpr(p); } } // MMa : changed all token_manager_decls into TokenManagerDecls to conform to class name convention void TokenManagerDecls() : { List decls = new ArrayList(); Token t; } { t = "TOKEN_MGR_DECLS" ":" ClassOrInterfaceBody(false, decls) { add_token_manager_decls(t, decls); } } // MMa : changed all regexpr_kind into RegExprKind to conform to class name convention void RegExprKind(TokenProduction p) : {} { "TOKEN" { p.kind = TokenProduction.TOKEN; } | "SPECIAL_TOKEN" { p.kind = TokenProduction.SPECIAL; } | "SKIP" { p.kind = TokenProduction.SKIP; } | "MORE" { p.kind = TokenProduction.MORE; } } // MMa : changed all RegExprSpec into RegExprSpec_ (JavaCC specific class) // MMa : changed all regexpr_spec into RegExprSpec to conform to class name convention void RegExprSpec(TokenProduction p) : { Container c = new Container(); Action act = new Action(); Token t = null; RegExprSpec_ res = new RegExprSpec_(); } { RegularExpression(c) { res.rexp = (RegularExpression_) c.member; res.rexp.tpContext = p; } [ { t = getToken(1); } Block ( act.getActionTokens() ) { if (Options.getUserTokenManager()) { JavaCCErrors.warning(t, "Ignoring action in regular expression specification since option USER_TOKEN_MANAGER has been set to true."); } if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Actions are not permitted on private (#) regular expressions."); } } ] [ ":" t = < IDENTIFIER > { res.nextState = t.image; if (res.rexp.private_rexp) { JavaCCErrors.parse_error(t, "Lexical state changes are not permitted after private (#) regular expressions."); } } ] { res.act = act; res.nsTok = t; p.respecs.add(res); } } // MMa : changed all expansion_choices into ExpansionChoices to conform to class name convention void ExpansionChoices(Container c1) : { boolean morethanone = false; Choice ch = new Choice(); Container c2 = new Container(); } { Expansion(c1) ( "|" Expansion(c2) { if (morethanone) { ch.getChoices().add((Expansion_) c2.member); ((Expansion_) c2.member).parent = ch; } else { morethanone = true; ch = new Choice((Expansion_) c1.member); ((Expansion_) c1.member).parent = ch; ch.getChoices().add((Expansion_) c2.member); ((Expansion_) c2.member).parent = ch; } } )* { if (morethanone) { c1.member = ch; } } } // MMa : changed all Expansion into Expansion_ (JavaCC specific class) // MMa : changed all expansion into Expansion to conform to class name convention void Expansion(Container c1) : { Sequence seq = new Sequence(); Container c2 = new Container(); Lookahead la = new Lookahead(); Token t = getToken(1); seq.setLine(t.beginLine); seq.setColumn(t.beginColumn); la.setLine(t.beginLine); la.setColumn(t.beginColumn); } { { la.setAmount(Options.getLookahead()); la.setLaExpansion(null); la.setExplicit(false); } ( LOOKAHEAD(1) t = "LOOKAHEAD" "(" la = LocalLookahead() ")" { if (inLocalLA != 0 && la.getAmount() != 0) { JavaCCErrors.warning(t, "Only semantic lookahead specifications within other lookahead specifications is considered. Syntactic lookahead is ignored."); } } )? { seq.units.add(la); } ( LOOKAHEAD(0, { notTailOfExpansionUnit() }) ExpansionUnit(c2) { seq.units.add((Expansion_)c2.member); ((Expansion_) c2.member).parent = seq; ((Expansion_) c2.member).ordinal = seq.units.size() - 1; } )+ { if (la.getLaExpansion() == null) { la.setLaExpansion(seq); } c1.member = seq; } } // MMa : changed all local_lookahead into LocalLookahead to conform to class name convention Lookahead LocalLookahead() : { Lookahead la = new Lookahead(); la.setExplicit(true); Token t = getToken(1); la.setLine(t.beginLine); la.setColumn(t.beginColumn); la.setLaExpansion(null); Container c = new Container(); boolean commaAtEnd = false, emptyLA = true; int laAmount; inLocalLA++; } { [ /* * The lookahead of 1 is to turn off the warning message that lets * us know that an expansion choice can also start with an integer * literal because a primary expression can do the same. But we * know that this is what we want. */ LOOKAHEAD(1) laAmount = IntegerLiteral() { emptyLA = false; la.setAmount(laAmount); } ] [ LOOKAHEAD(0, { !emptyLA && (getToken(1).kind != RPAREN) }) "," { commaAtEnd = true; } ] [ LOOKAHEAD(0, { getToken(1).kind != RPAREN && getToken(1).kind != LBRACE }) ExpansionChoices(c) { emptyLA = false; commaAtEnd = false; la.setLaExpansion((Expansion_) c.member); } ] [ LOOKAHEAD(0, { !emptyLA && !commaAtEnd && (getToken(1).kind != RPAREN) }) "," { commaAtEnd = true; } ] [ LOOKAHEAD(0, { emptyLA || commaAtEnd }) "{" Expression ( la.getActionTokens() ) "}" { if (emptyLA) { la.setAmount(0); } } ] { inLocalLA--; return la; } } // MMa : changed all expansion_unit into ExpansionUnit to conform to class name convention void ExpansionUnit(Container c) : { String name; List lhsTokens = new ArrayList(); NonTerminal nt; Action act; Token t; Lookahead la; } { LOOKAHEAD(1) /* * We give this priority over primary expressions which use LOOKAHEAD as the * name of its identifier. */ t = "LOOKAHEAD" "(" la = LocalLookahead() ")" { // Now set the la_expansion field of la with a dummy expansion (we use EOF). la.setLaExpansion(new REndOfFile()); // Create a singleton choice with an empty action. Choice ch = new Choice(t); Sequence seq = new Sequence(t, la); la.parent = seq; la.ordinal = 0; act = new Action(); act.setLine(t.beginLine); act.setColumn(t.beginColumn); seq.units.add(act); act.parent = seq; act.ordinal = 1; ch.getChoices().add(seq); seq.parent = ch; seq.ordinal = 0; if (la.getAmount() != 0) { if (la.getActionTokens().size() != 0) { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. Only semantic lookahead will be considered here."); } else { JavaCCErrors.warning(t, "Encountered LOOKAHEAD(...) at a non-choice location. This will be ignored."); } } c.member = ch; } | { act = new Action(); t = getToken(1); act.setLine(t.beginLine); act.setColumn(t.beginColumn); inAction = true; } Block ( act.getActionTokens() ) { inAction = false; if (inLocalLA != 0) { JavaCCErrors.warning(t, "Action within lookahead specification will be ignored."); } c.member = act; } | t = "[" ExpansionChoices(c) "]" { c.member = new ZeroOrOne(t, (Expansion_) c.member); } // MMa : replaced by new production ExpansionUnitInTCF // | // { // Container expch = new Container(); // List> types = new ArrayList>(); // List ids = new ArrayList(); // List> catchblks = new ArrayList>(); // List finallyblk = null; // List vec = new ArrayList(); // Token t0; // } // t0 = "try" "{" ExpansionChoices(expch) "}" // ( // "catch" "(" Name(vec) t = < IDENTIFIER > ")" // { // types.add(vec); // ids.add(t); // vec = new ArrayList(); // inAction = true; // } // Block(vec) // { // inAction = false; // catchblks.add(vec); // vec = new ArrayList(); // } // )* // [ // { // inAction = true; // } // "finally" Block(vec) // { // inAction = false; // finallyblk = vec; // } // ] // { // makeTryBlock(t0, c, expch, types, ids, catchblks, finallyblk); // } | ExpansionUnitInTCF(c) | LOOKAHEAD(Identifier() | StringLiteral() | "<" | PrimaryExpression() "=") [ LOOKAHEAD(PrimaryExpression() "=") { Token first = getToken(1); } PrimaryExpression() { Token last = getToken(0); } "=" { t = first; while (true) { lhsTokens.add(t); if (t == last) break; t = t.next; } } ] ( LOOKAHEAD(Identifier() "(") { nt = new NonTerminal(); t = getToken(1); nt.setLine(t.beginLine); nt.setColumn(t.beginColumn); nt.setLhsTokens(lhsTokens); } name = Identifier() Arguments(nt.getArgumentTokens()) { nt.setName(name); c.member = nt; } | RegularExpression(c) { ((RegularExpression_) (c.member)).lhsTokens = lhsTokens; add_inline_regexpr((RegularExpression_) (c.member)); } [ "." t = < IDENTIFIER > { ((RegularExpression_) (c.member)).rhsToken = t; } ] ) | t = "(" ExpansionChoices(c) ")" ( "+" { c.member = new OneOrMore(t, (Expansion_) c.member); } | "*" { c.member = new ZeroOrMore(t, (Expansion_) c.member); } | "?" { c.member = new ZeroOrOne(t, (Expansion_) c.member); } )? } // MMa : added to create a node void ExpansionUnitInTCF(Container c) : { Token t; } { { Container expch = new Container(); List> types = new ArrayList>(); List ids = new ArrayList(); List> catchblks = new ArrayList>(); List finallyblk = null; List vec = new ArrayList(); Token t0; } t0 = "try" "{" ExpansionChoices(expch) "}" ( "catch" "(" Name(vec) t = < IDENTIFIER > ")" { types.add(vec); ids.add(t); vec = new ArrayList(); inAction = true; } Block(vec) { inAction = false; catchblks.add(vec); vec = new ArrayList(); } )* [ { inAction = true; } "finally" Block(vec) { inAction = false; finallyblk = vec; } ] { makeTryBlock(t0, c, expch, types, ids, catchblks, finallyblk); } } // MMa : changed all RegularExpression into RegularExpression_ (JavaCC specific class) // MMa : changed all regular_expression into RegularExpression to conform to class name convention void RegularExpression(Container c) : { REndOfFile ef; String image; boolean private_rexp = false; Token t = getToken(1); } { image = StringLiteral() { c.member = new RStringLiteral(t, image); } | LOOKAHEAD(3) { image = ""; } < LANGLE : "<" > [ [ "#" { private_rexp = true; } ] image = Identifier() ":" ] ComplexRegularExpressionChoices(c) < RANGLE : ">" > { RegularExpression_ re; if (c.member instanceof RJustName) { RSequence seq = new RSequence(); seq.units.add((RegularExpression_) c.member); re = seq; } else { re = (RegularExpression_) c.member; } re.label = image; re.private_rexp = private_rexp; re.setLine(t.beginLine); re.setColumn(t.beginColumn); c.member = re; } | LOOKAHEAD(2) "<" image = Identifier() ">" { c.member = new RJustName(t, image); } | "<" "EOF" ">" { ef = new REndOfFile(); ef.setLine(t.beginLine); ef.setColumn(t.beginColumn); ef.ordinal = 0; c.member = ef; } } // MMa : changed all complex_regular_expression_choices into ComplexRegularExpressionChoices to conform to class name convention void ComplexRegularExpressionChoices(Container c1) : { boolean morethanone = false; RChoice ch = new RChoice(); Container c2 = new Container(); } { ComplexRegularExpression(c1) ( "|" ComplexRegularExpression(c2) { if (morethanone) { ch.getChoices().add((RegularExpression_) c2.member); } else { morethanone = true; ch = new RChoice(); ch.setLine(((RegularExpression_) c1.member).getLine()); ch.setColumn(((RegularExpression_) c1.member).getColumn()); ch.getChoices().add((RegularExpression_) c1.member); ch.getChoices().add((RegularExpression_) c2.member); } } )* { if (morethanone) { c1.member = ch; } } } // MMa : changed all complex_regular_expression into ComplexRegularExpression to conform to class name convention void ComplexRegularExpression(Container c1) : { int count = 0; RSequence seq = new RSequence(); Container c2 = new Container(); } { ( ComplexRegularExpressionUnit(c2) { count++; if (count == 1) { c1.member = c2.member; // if count does not go beyond 1, we are done. } else if (count == 2) { // more than 1, so create a sequence. seq = new RSequence(); seq.setLine(((RegularExpression_) c1.member).getLine()); seq.setColumn(((RegularExpression_) c1.member).getColumn()); seq.units.add((RegularExpression_) c1.member); seq.units.add((RegularExpression_) c2.member); } else { seq.units.add((RegularExpression_) c2.member); } } )+ { if (count > 1) { c1.member = seq; } } } // MMa : changed all complex_regular_expression_unit into ComplexRegularExpressionUnit to conform to class name convention void ComplexRegularExpressionUnit(Container c) : { String image; Token t = getToken(1); int r1 = 0, r2 =-1; boolean hasMax = false; } { image = StringLiteral() { c.member = new RStringLiteral(t, image); } | "<" image = Identifier() ">" { c.member = new RJustName(t, image); } | CharacterList(c) | "(" ComplexRegularExpressionChoices(c) ")" ( "+" { c.member = new ROneOrMore(t, (RegularExpression_) c.member); } | "*" { c.member = new RZeroOrMore(t, (RegularExpression_) c.member); } | "?" { RZeroOrOne zorexp = new RZeroOrOne(); zorexp.setLine(t.beginLine); zorexp.setColumn(t.beginColumn); zorexp.regexpr = (RegularExpression_) c.member; c.member = zorexp; } | "{" r1 = IntegerLiteral() [ "," { hasMax = true; } [ r2 = IntegerLiteral() ] ] "}" { RRepetitionRange rrrexp = new RRepetitionRange(); rrrexp.setLine(t.beginLine); rrrexp.setColumn(t.beginColumn); rrrexp.min = r1; rrrexp.max = r2; rrrexp.hasMax = hasMax; rrrexp.regexpr = (RegularExpression_) c.member; c.member = rrrexp; } )? } // MMa : changed all character_list into CharacterList to conform to class name convention void CharacterList(Container c1) : { RCharacterList chlist = new RCharacterList(); Token t = getToken(1); chlist.setLine(t.beginLine); chlist.setColumn(t.beginColumn); Container c2 = new Container(); } { [ "~" { chlist.negated_list = true; } ] "[" [ CharacterDescriptor(c2) { chlist.descriptors.add(c2.member); } ( "," CharacterDescriptor(c2) { chlist.descriptors.add(c2.member); } )* ] "]" { c1.member = chlist; } } // MMa : changed all character_descriptor into CharacterDescriptor to conform to class name convention void CharacterDescriptor(Container c) : { char c1, c2 = ' '; // unnecessary initialization to make Java compiler happy! boolean isrange = false; String imageL, imageR; Token t = getToken(1); } { imageL = StringLiteral() { c1 = character_descriptor_assign(getToken(0), imageL); } [ "-" imageR = StringLiteral() { isrange = true; c2 = character_descriptor_assign(getToken(0), imageR, imageL); } ] { if (isrange) { CharacterRange cr = new CharacterRange(); cr.setLine(t.beginLine); cr.setColumn(t.beginColumn); cr.setLeft(c1); cr.setRight(c2); c.member = cr; } else { SingleCharacter sc = new SingleCharacter(); sc.setLine(t.beginLine); sc.setColumn(t.beginColumn); sc.ch = c1; c.member = sc; } } } // MMa : changed all identifier into Identifier to conform to class name convention String Identifier() : { Token t = null; } { t = < IDENTIFIER > { return t.image; } } /********************************************** * THE JAVA GRAMMAR SPECIFICATION STARTS HERE * **********************************************/ /* * The Java grammar is modified to use sequences of tokens * for the missing tokens - those that include "<<" and ">>". */ /* * The following production defines Java identifiers - it * includes the reserved words of JavaCC also. */ Token JavaIdentifier() : {} { ( < IDENTIFIER > | "LOOKAHEAD" | "IGNORE_CASE" | "PARSER_BEGIN" | "PARSER_END" | "JAVACODE" | "TOKEN" | "SPECIAL_TOKEN" | "MORE" | "SKIP" | "TOKEN_MGR_DECLS" | "EOF" ) { Token retval = getToken(0); retval.kind = IDENTIFIER; return retval; } } /* * Program structuring syntax follows. */ void CompilationUnit() : /* * The is deleted since the compilation unit is embedded * within grammar code. */ { set_initial_cu_token ( getToken(1) ) ; } { [ LOOKAHEAD((Annotation())* "package") PackageDeclaration() ] ( ImportDeclaration() )* ( TypeDeclaration() )* { insertionpointerrors(getToken(1)); } } void PackageDeclaration() : {} { // MMa : fixed grammar // Modifiers() "package" Name(null) ";" ( Annotation() )* "package" Name(null) ";" } void ImportDeclaration() : {} { "import" [ "static" ] Name(null) [ "." "*" ] ";" } /* * Modifiers. We match all modifiers in a single rule to reduce the chances of * syntax errors for simple modifier mistakes. It will also enable us to give * better error messages. */ int Modifiers() : { int modifiers = 0; } { ( LOOKAHEAD(2) ( "public" { modifiers |= ModifierSet.M_PUBLIC; } | "static" { modifiers |= ModifierSet.M_STATIC; } | "protected" { modifiers |= ModifierSet.M_PROTECTED; } | "private" { modifiers |= ModifierSet.M_PRIVATE; } | "final" { modifiers |= ModifierSet.M_FINAL; } | "abstract" { modifiers |= ModifierSet.M_ABSTRACT; } | "synchronized" { modifiers |= ModifierSet.M_SYNCHRONIZED; } | "native" { modifiers |= ModifierSet.M_NATIVE; } | "transient" { modifiers |= ModifierSet.M_TRANSIENT; } | "volatile" { modifiers |= ModifierSet.M_VOLATILE; } | "strictfp" { modifiers |= ModifierSet.M_STRICTFP; } | Annotation() ) )* { return modifiers; } } /* * Declaration syntax follows. */ void TypeDeclaration() : {} { ";" | Modifiers() ( ClassOrInterfaceDeclaration() | EnumDeclaration() | AnnotationTypeDeclaration() ) } void ClassOrInterfaceDeclaration() : { boolean isInterface = false; class_nesting++; Token t; boolean is_parser_class = false; } { ( "class" | "interface" { isInterface = true; } ) t = < IDENTIFIER > [ TypeParameters() ] [ ExtendsList(isInterface) ] [ ImplementsList(isInterface) ] { if (t.image.equals(parser_class_name) && class_nesting == 1 && processing_cu) { is_parser_class = true; setinsertionpoint(getToken(1), 1); } } ClassOrInterfaceBody(isInterface, null) { if (is_parser_class) { setinsertionpoint(getToken(0), 2); } class_nesting--; } } void ExtendsList(boolean isInterface) : { boolean extendsMoreThanOne = false; } { "extends" ClassOrInterfaceType() ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )* { if (extendsMoreThanOne && !isInterface) throw new ParseException("A class cannot extend more than one other class"); } } void ImplementsList(boolean isInterface) : {} { "implements" ClassOrInterfaceType() ( "," ClassOrInterfaceType() )* { if (isInterface) throw new ParseException("An interface cannot implement other interfaces"); } } void EnumDeclaration() : {} { "enum" < IDENTIFIER > [ ImplementsList(false) ] EnumBody() } void EnumBody() : {} { "{" [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ] [ "," ] [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ] "}" } void EnumConstant() : {} { Modifiers() < IDENTIFIER > [ Arguments(null) ] [ ClassOrInterfaceBody(false, null) ] } void TypeParameters() : {} { "<" TypeParameter() ( "," TypeParameter() )* ">" } void TypeParameter() : {} { < IDENTIFIER > [ TypeBound() ] } void TypeBound() : {} { "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )* } void ClassOrInterfaceBody(boolean isInterface, List tokens) : /* * Parsing this fills "tokens" with all tokens of the block * excluding the braces at each end. */ { Token first, last; if (tokens == null) tokens = new ArrayList(); } { "{" { first = getToken(1); } ( ClassOrInterfaceBodyDeclaration(isInterface) )* { last = getToken(0); } "}" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } } void ClassOrInterfaceBodyDeclaration(boolean isInterface) : {} { LOOKAHEAD(2) Initializer() { if (isInterface) throw new ParseException("An interface cannot have initializers"); } | Modifiers() // Just get all the modifiers out of the way. If you want to do // more checks, pass the modifiers down to the member ( ClassOrInterfaceDeclaration() | EnumDeclaration() | LOOKAHEAD([ TypeParameters() ] < IDENTIFIER > "(") ConstructorDeclaration() | LOOKAHEAD(Type() < IDENTIFIER > ("[" "]")* ("," | "=" | ";")) FieldDeclaration() | MethodDeclaration() ) | ";" } void FieldDeclaration() : {} { // Modifiers are already matched in the caller Type() VariableDeclarator() ( "," VariableDeclarator() )* ";" } void VariableDeclarator() : {} { VariableDeclaratorId() [ "=" VariableInitializer() ] } void VariableDeclaratorId() : {} { < IDENTIFIER > ("[" "]")* } void VariableInitializer() : {} { ArrayInitializer() | Expression(null) } void ArrayInitializer() : {} { "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}" } void MethodDeclaration() : {} { // Modifiers already matched in the caller! [ TypeParameters() ] ResultType(null) MethodDeclarator() [ "throws" NameList() ] ( Block(null) | ";" ) } void MethodDeclarator() : {} { < IDENTIFIER > FormalParameters(null) ("[" "]")* } void FormalParameters(List tokens) : /* * Parsing this fills "tokens" with all tokens of the formal * parameters excluding the parentheses at each end. */ { Token first, last; if (tokens == null) tokens = new ArrayList(); } { "(" { first = getToken(1); } [ FormalParameter() ( "," FormalParameter() )* ] { last = getToken(0); } ")" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } } void FormalParameter() : {} { Modifiers() Type() [ "..." ] VariableDeclaratorId() } void ConstructorDeclaration() : {} { [ TypeParameters() ] // Modifiers matched in the caller < IDENTIFIER > FormalParameters(null) [ "throws" NameList() ] "{" [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}" } void ExplicitConstructorInvocation() : {} { LOOKAHEAD("this" Arguments(null) ";") "this" Arguments(null) ";" | [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments(null) ";" } void Initializer() : {} { [ "static" ] Block(null) } /* * Type, name and expression syntax follows. */ void Type() : {} { LOOKAHEAD(2) ReferenceType() | PrimitiveType() } void ReferenceType() : {} { PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+ | ClassOrInterfaceType() ( LOOKAHEAD(2) "[" "]" )* } void ClassOrInterfaceType() : {} { < IDENTIFIER > [ LOOKAHEAD(2) TypeArguments() ] ( LOOKAHEAD(2) "." < IDENTIFIER > [ LOOKAHEAD(2) TypeArguments() ] )* } void TypeArguments() : {} { "<" TypeArgument() ( "," TypeArgument() )* ">" } void TypeArgument() : {} { ReferenceType() | "?" [ WildcardBounds() ] } void WildcardBounds() : {} { "extends" ReferenceType() | "super" ReferenceType() } void PrimitiveType() : {} { "boolean" | "char" | "byte" | "short" | "int" | "long" | "float" | "double" } void ResultType(List tokens) : { Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); } { ( "void" | Type() ) { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } void Name(List tokens) : /* * A lookahead of 2 is required below since "Name" can be followed * by a ".*" when used in the context of an "ImportDeclaration". */ { if (tokens == null) tokens = new ArrayList(); Token first = getToken(1); } { JavaIdentifier() ( LOOKAHEAD(2) "." JavaIdentifier() )* { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } void NameList() : {} { Name(null) ( "," Name(null) )* } /* * Expression syntax follows. */ void Expression(List tokens) : /* * This expansion has been written this way instead of: * Assignment() | ConditionalExpression() * for performance reasons. * However, it is a weakening of the grammar for it allows the LHS of * assignments to be any conditional expression whereas it can only be * a primary expression. Consider adding a semantic predicate to work * around this. */ { Token first = getToken(1); if (tokens == null) tokens = new ArrayList(); } { ConditionalExpression() [ LOOKAHEAD(2) AssignmentOperator() Expression(null) ] { Token last = getToken(0); Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } void AssignmentOperator() : {} { "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" } void ConditionalExpression() : {} { ConditionalOrExpression() [ "?" Expression(null) ":" Expression(null) ] } void ConditionalOrExpression() : {} { ConditionalAndExpression() ( "||" ConditionalAndExpression() )* } void ConditionalAndExpression() : {} { InclusiveOrExpression() ( "&&" InclusiveOrExpression() )* } void InclusiveOrExpression() : {} { ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )* } void ExclusiveOrExpression() : {} { AndExpression() ( "^" AndExpression() )* } void AndExpression() : {} { EqualityExpression() ( "&" EqualityExpression() )* } void EqualityExpression() : {} { InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )* } void InstanceOfExpression() : {} { RelationalExpression() [ "instanceof" Type() ] } void RelationalExpression() : {} { ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )* } void ShiftExpression() : {} { AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )* } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { ( "+" | "-" ) UnaryExpression() | PreIncrementExpression() | PreDecrementExpression() | UnaryExpressionNotPlusMinus() } void PreIncrementExpression() : {} { "++" PrimaryExpression() } void PreDecrementExpression() : {} { "--" PrimaryExpression() } void UnaryExpressionNotPlusMinus() : {} { ( "~" | "!" ) UnaryExpression() | LOOKAHEAD(CastLookahead()) CastExpression() | PostfixExpression() } // This production is to determine lookahead only. The LOOKAHEAD specifications // below are not used, but they are there just to indicate that we know about // this. void CastLookahead() : {} { LOOKAHEAD(2) "(" PrimitiveType() | LOOKAHEAD("(" Type() "[") "(" Type() "[" "]" | "(" Type() ")" ( "~" | "!" | "(" | < IDENTIFIER > | "this" | "super" | "new" | Literal() ) } void PostfixExpression() : {} { PrimaryExpression() [ "++" | "--" ] } void CastExpression() : {} { LOOKAHEAD("(" PrimitiveType()) "(" Type() ")" UnaryExpression() | "(" Type() ")" UnaryExpressionNotPlusMinus() } void PrimaryExpression() : {} { PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )* } void MemberSelector() : {} { "." TypeArguments() < IDENTIFIER > } void PrimaryPrefix() : {} { Literal() | "this" | "super" "." < IDENTIFIER > | "(" Expression(null) ")" | AllocationExpression() | LOOKAHEAD(ResultType(null) "." "class") ResultType(null) "." "class" | Name(null) } void PrimarySuffix() : {} { LOOKAHEAD(2) "." "this" | LOOKAHEAD(2) "." AllocationExpression() | LOOKAHEAD(3) MemberSelector() | "[" Expression(null) "]" | "." < IDENTIFIER > | Arguments(null) } void Literal() : {} { < INTEGER_LITERAL > | < FLOATING_POINT_LITERAL > | < CHARACTER_LITERAL > | < STRING_LITERAL > | BooleanLiteral() | NullLiteral() } int IntegerLiteral() : {} { < INTEGER_LITERAL > { try { return Integer.parseInt(token.image); } catch (NumberFormatException e) { throw new Error(); } } } boolean BooleanLiteral() : {} { "true" { return true; } | "false" { return false; } } String StringLiteral() : { Token t; } { t = < STRING_LITERAL > { return remove_escapes_and_quotes(t, t.image); } } void NullLiteral() : {} { "null" } void Arguments(List tokens) : /* * Parsing this fills "tokens" with all tokens of the arguments * excluding the parentheses at each end. */ { Token first, last; if (tokens == null) tokens = new ArrayList(); } { "(" { first = getToken(1); } [ ArgumentList() ] { last = getToken(0); } ")" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } } void ArgumentList() : {} { Expression(null) ( "," Expression(null) )* } void AllocationExpression() : {} { LOOKAHEAD(2) "new" PrimitiveType() ArrayDimsAndInits() | "new" ClassOrInterfaceType() [ TypeArguments() ] ( ArrayDimsAndInits() | Arguments(null) [ ClassOrInterfaceBody(false, null) ] ) } /* * The third LOOKAHEAD specification below is to parse to PrimarySuffix * if there is an expression between the "[...]". */ void ArrayDimsAndInits() : {} { LOOKAHEAD(2) ( LOOKAHEAD(2) "[" Expression(null) "]" )+ ( LOOKAHEAD(2) "[" "]" )* | ("[" "]")+ ArrayInitializer() } /* * Statement syntax follows. */ void Statement() : {} { LOOKAHEAD(2) LabeledStatement() | AssertStatement() | Block(null) | EmptyStatement() | StatementExpression() ";" | SwitchStatement() | IfStatement() | WhileStatement() | DoStatement() | ForStatement() | BreakStatement() | ContinueStatement() | ReturnStatement() | ThrowStatement() | SynchronizedStatement() | TryStatement() } void AssertStatement() : {} { "assert" Expression(null) [ ":" Expression(null) ] ";" } void LabeledStatement() : {} { < IDENTIFIER > ":" Statement() } void Block(List tokens) : /* * Parsing this fills "tokens" with all tokens of the block * excluding the braces at each end. */ { Token first, last; if (tokens == null) tokens = new ArrayList(); } { "{" { first = getToken(1); } ( BlockStatement() )* { last = getToken(0); } "}" { if (last.next != first) { // i.e., this is not an empty sequence Token t = first; while (true) { tokens.add(t); if (t == last) break; t = t.next; } } } } void BlockStatement() : {} { LOOKAHEAD(Modifiers() Type() < IDENTIFIER >) LocalVariableDeclaration() ";" | Statement() | ClassOrInterfaceDeclaration() } void LocalVariableDeclaration() : {} { Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )* } void EmptyStatement() : {} { ";" } void StatementExpression() : /* * The last expansion of this production accepts more than the legal * Java expansions for StatementExpression. This expansion does not * use PostfixExpression for performance reasons. */ {} { PreIncrementExpression() | PreDecrementExpression() | PrimaryExpression() [ "++" | "--" | AssignmentOperator() Expression(null) ] } void SwitchStatement() : {} { "switch" "(" Expression(null) ")" "{" ( SwitchLabel() ( BlockStatement() )* )* "}" } void SwitchLabel() : {} { "case" Expression(null) ":" | "default" ":" } void IfStatement() : /* * The disambiguating algorithm of JavaCC automatically binds dangling * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */ {} { "if" "(" Expression(null) ")" Statement() [ LOOKAHEAD(1) "else" Statement() ] } void WhileStatement() : {} { "while" "(" Expression(null) ")" Statement() } void DoStatement() : {} { "do" Statement() "while" "(" Expression(null) ")" ";" } void ForStatement() : {} { "for" "(" ( LOOKAHEAD(Modifiers() Type() < IDENTIFIER > ":") Modifiers() Type() < IDENTIFIER > ":" Expression(null) | [ ForInit() ] ";" [ Expression(null) ] ";" [ ForUpdate() ] ) ")" Statement() } void ForInit() : {} { LOOKAHEAD(Modifiers() Type() < IDENTIFIER >) LocalVariableDeclaration() | StatementExpressionList() } void StatementExpressionList() : {} { StatementExpression() ( "," StatementExpression() )* } void ForUpdate() : {} { StatementExpressionList() } void BreakStatement() : {} { "break" [ < IDENTIFIER > ] ";" } void ContinueStatement() : {} { "continue" [ < IDENTIFIER > ] ";" } void ReturnStatement() : { Token t; } { t = "return" { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) return"; jumpPatched = true; } } [ Expression(null) ] t = ";" { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } } } void ThrowStatement() : { Token t; } { t = "throw" { // Add if statement to prevent subsequent code generated // from being dead code. if (inAction) { t.image = "{if (true) throw"; jumpPatched = true; } } Expression(null) t = ";" { // Add closing brace for above if statement. if (inAction) { t.image = ";}"; } } } void SynchronizedStatement() : {} { "synchronized" "(" Expression(null) ")" Block(null) } void TryStatement() : /* * Semantic check required here to make sure that at least one * finally/catch is present. */ {} { "try" Block(null) ( "catch" "(" FormalParameter() ")" Block(null) )* [ "finally" Block(null) ] } /* We use productions to match >>>, >> and > so that we can keep the * type declaration syntax with generics clean */ void RUNSIGNEDSHIFT() : {} { LOOKAHEAD({ getToken(1).kind == GT && ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT }) ">" ">" ">" } void RSIGNEDSHIFT() : {} { LOOKAHEAD({ getToken(1).kind == GT && ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT }) ">" ">" } /* Annotation syntax follows. */ void Annotation() : {} { LOOKAHEAD("@" Name(null) "(" < IDENTIFIER > "=" | ")") NormalAnnotation() | LOOKAHEAD("@" Name(null) "(") SingleMemberAnnotation() | MarkerAnnotation() } void NormalAnnotation() : {} { "@" Name(null) "(" [ MemberValuePairs() ] ")" } void MarkerAnnotation() : {} { "@" Name(null) } void SingleMemberAnnotation() : {} { "@" Name(null) "(" MemberValue() ")" } void MemberValuePairs() : {} { MemberValuePair() ( "," MemberValuePair() )* } void MemberValuePair() : {} { < IDENTIFIER > "=" MemberValue() } void MemberValue() : {} { Annotation() | MemberValueArrayInitializer() | ConditionalExpression() } void MemberValueArrayInitializer() : {} { "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}" } /* Annotation Types. */ void AnnotationTypeDeclaration() : {} { "@" "interface" < IDENTIFIER > AnnotationTypeBody() } void AnnotationTypeBody() : {} { "{" ( AnnotationTypeMemberDeclaration() )* "}" } void AnnotationTypeMemberDeclaration() : {} { Modifiers() ( LOOKAHEAD(Type() < IDENTIFIER > "(") Type() < IDENTIFIER > "(" ")" [ DefaultValue() ] ";" | ClassOrInterfaceDeclaration() | EnumDeclaration() | AnnotationTypeDeclaration() | FieldDeclaration() ) | ";" } void DefaultValue() : {} { "default" MemberValue() } /* IDENTIFIERS */ TOKEN : { < IDENTIFIER: ()* > | < #LETTER: [ // all chars for which Character.isIdentifierStart is true "$", "A"-"Z", "_", "a"-"z", "\u00a2"-"\u00a5", "\u00aa", "\u00b5", "\u00ba", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u021f", "\u0222"-"\u0233", "\u0250"-"\u02ad", "\u02b0"-"\u02b8", "\u02bb"-"\u02c1", "\u02d0"-"\u02d1", "\u02e0"-"\u02e4", "\u02ee", "\u037a", "\u0386", "\u0388"-"\u038a", "\u038c", "\u038e"-"\u03a1", "\u03a3"-"\u03ce", "\u03d0"-"\u03d7", "\u03da"-"\u03f3", "\u0400"-"\u0481", "\u048c"-"\u04c4", "\u04c7"-"\u04c8", "\u04cb"-"\u04cc", "\u04d0"-"\u04f5", "\u04f8"-"\u04f9", "\u0531"-"\u0556", "\u0559", "\u0561"-"\u0587", "\u05d0"-"\u05ea", "\u05f0"-"\u05f2", "\u0621"-"\u063a", "\u0640"-"\u064a", "\u0671"-"\u06d3", "\u06d5", "\u06e5"-"\u06e6", "\u06fa"-"\u06fc", "\u0710", "\u0712"-"\u072c", "\u0780"-"\u07a5", "\u0905"-"\u0939", "\u093d", "\u0950", "\u0958"-"\u0961", "\u0985"-"\u098c", "\u098f"-"\u0990", "\u0993"-"\u09a8", "\u09aa"-"\u09b0", "\u09b2", "\u09b6"-"\u09b9", "\u09dc"-"\u09dd", "\u09df"-"\u09e1", "\u09f0"-"\u09f3", "\u0a05"-"\u0a0a", "\u0a0f"-"\u0a10", "\u0a13"-"\u0a28", "\u0a2a"-"\u0a30", "\u0a32"-"\u0a33", "\u0a35"-"\u0a36", "\u0a38"-"\u0a39", "\u0a59"-"\u0a5c", "\u0a5e", "\u0a72"-"\u0a74", "\u0a85"-"\u0a8b", "\u0a8d", "\u0a8f"-"\u0a91", "\u0a93"-"\u0aa8", "\u0aaa"-"\u0ab0", "\u0ab2"-"\u0ab3", "\u0ab5"-"\u0ab9", "\u0abd", "\u0ad0", "\u0ae0", "\u0b05"-"\u0b0c", "\u0b0f"-"\u0b10", "\u0b13"-"\u0b28", "\u0b2a"-"\u0b30", "\u0b32"-"\u0b33", "\u0b36"-"\u0b39", "\u0b3d", "\u0b5c"-"\u0b5d", "\u0b5f"-"\u0b61", "\u0b85"-"\u0b8a", "\u0b8e"-"\u0b90", "\u0b92"-"\u0b95", "\u0b99"-"\u0b9a", "\u0b9c", "\u0b9e"-"\u0b9f", "\u0ba3"-"\u0ba4", "\u0ba8"-"\u0baa", "\u0bae"-"\u0bb5", "\u0bb7"-"\u0bb9", "\u0c05"-"\u0c0c", "\u0c0e"-"\u0c10", "\u0c12"-"\u0c28", "\u0c2a"-"\u0c33", "\u0c35"-"\u0c39", "\u0c60"-"\u0c61", "\u0c85"-"\u0c8c", "\u0c8e"-"\u0c90", "\u0c92"-"\u0ca8", "\u0caa"-"\u0cb3", "\u0cb5"-"\u0cb9", "\u0cde", "\u0ce0"-"\u0ce1", "\u0d05"-"\u0d0c", "\u0d0e"-"\u0d10", "\u0d12"-"\u0d28", "\u0d2a"-"\u0d39", "\u0d60"-"\u0d61", "\u0d85"-"\u0d96", "\u0d9a"-"\u0db1", "\u0db3"-"\u0dbb", "\u0dbd", "\u0dc0"-"\u0dc6", "\u0e01"-"\u0e30", "\u0e32"-"\u0e33", "\u0e3f"-"\u0e46", "\u0e81"-"\u0e82", "\u0e84", "\u0e87"-"\u0e88", "\u0e8a", "\u0e8d", "\u0e94"-"\u0e97", "\u0e99"-"\u0e9f", "\u0ea1"-"\u0ea3", "\u0ea5", "\u0ea7", "\u0eaa"-"\u0eab", "\u0ead"-"\u0eb0", "\u0eb2"-"\u0eb3", "\u0ebd", "\u0ec0"-"\u0ec4", "\u0ec6", "\u0edc"-"\u0edd", "\u0f00", "\u0f40"-"\u0f47", "\u0f49"-"\u0f6a", "\u0f88"-"\u0f8b", "\u1000"-"\u1021", "\u1023"-"\u1027", "\u1029"-"\u102a", "\u1050"-"\u1055", "\u10a0"-"\u10c5", "\u10d0"-"\u10f6", "\u1100"-"\u1159", "\u115f"-"\u11a2", "\u11a8"-"\u11f9", "\u1200"-"\u1206", "\u1208"-"\u1246", "\u1248", "\u124a"-"\u124d", "\u1250"-"\u1256", "\u1258", "\u125a"-"\u125d", "\u1260"-"\u1286", "\u1288", "\u128a"-"\u128d", "\u1290"-"\u12ae", "\u12b0", "\u12b2"-"\u12b5", "\u12b8"-"\u12be", "\u12c0", "\u12c2"-"\u12c5", "\u12c8"-"\u12ce", "\u12d0"-"\u12d6", "\u12d8"-"\u12ee", "\u12f0"-"\u130e", "\u1310", "\u1312"-"\u1315", "\u1318"-"\u131e", "\u1320"-"\u1346", "\u1348"-"\u135a", "\u13a0"-"\u13f4", "\u1401"-"\u166c", "\u166f"-"\u1676", "\u1681"-"\u169a", "\u16a0"-"\u16ea", "\u1780"-"\u17b3", "\u17db", "\u1820"-"\u1877", "\u1880"-"\u18a8", "\u1e00"-"\u1e9b", "\u1ea0"-"\u1ef9", "\u1f00"-"\u1f15", "\u1f18"-"\u1f1d", "\u1f20"-"\u1f45", "\u1f48"-"\u1f4d", "\u1f50"-"\u1f57", "\u1f59", "\u1f5b", "\u1f5d", "\u1f5f"-"\u1f7d", "\u1f80"-"\u1fb4", "\u1fb6"-"\u1fbc", "\u1fbe", "\u1fc2"-"\u1fc4", "\u1fc6"-"\u1fcc", "\u1fd0"-"\u1fd3", "\u1fd6"-"\u1fdb", "\u1fe0"-"\u1fec", "\u1ff2"-"\u1ff4", "\u1ff6"-"\u1ffc", "\u203f"-"\u2040", "\u207f", "\u20a0"-"\u20af", "\u2102", "\u2107", "\u210a"-"\u2113", "\u2115", "\u2119"-"\u211d", "\u2124", "\u2126", "\u2128", "\u212a"-"\u212d", "\u212f"-"\u2131", "\u2133"-"\u2139", "\u2160"-"\u2183", "\u3005"-"\u3007", "\u3021"-"\u3029", "\u3031"-"\u3035", "\u3038"-"\u303a", "\u3041"-"\u3094", "\u309d"-"\u309e", "\u30a1"-"\u30fe", "\u3105"-"\u312c", "\u3131"-"\u318e", "\u31a0"-"\u31b7", "\u3400"-"\u4db5", "\u4e00"-"\u9fa5", "\ua000"-"\ua48c", "\uac00"-"\ud7a3", "\uf900"-"\ufa2d", "\ufb00"-"\ufb06", "\ufb13"-"\ufb17", "\ufb1d", "\ufb1f"-"\ufb28", "\ufb2a"-"\ufb36", "\ufb38"-"\ufb3c", "\ufb3e", "\ufb40"-"\ufb41", "\ufb43"-"\ufb44", "\ufb46"-"\ufbb1", "\ufbd3"-"\ufd3d", "\ufd50"-"\ufd8f", "\ufd92"-"\ufdc7", "\ufdf0"-"\ufdfb", "\ufe33"-"\ufe34", "\ufe4d"-"\ufe4f", "\ufe69", "\ufe70"-"\ufe72", "\ufe74", "\ufe76"-"\ufefc", "\uff04", "\uff21"-"\uff3a", "\uff3f", "\uff41"-"\uff5a", "\uff65"-"\uffbe", "\uffc2"-"\uffc7", "\uffca"-"\uffcf", "\uffd2"-"\uffd7", "\uffda"-"\uffdc", "\uffe0"-"\uffe1", "\uffe5"-"\uffe6" ] > | < #PART_LETTER: [ // all chars for which Character.isIdentifierPart is true "\u0000"-"\u0008", "\u000e"-"\u001b", "$", "0"-"9", "A"-"Z", "_", "a"-"z", "\u007f"-"\u009f", "\u00a2"-"\u00a5", "\u00aa", "\u00b5", "\u00ba", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u021f", "\u0222"-"\u0233", "\u0250"-"\u02ad", "\u02b0"-"\u02b8", "\u02bb"-"\u02c1", "\u02d0"-"\u02d1", "\u02e0"-"\u02e4", "\u02ee", "\u0300"-"\u034e", "\u0360"-"\u0362", "\u037a", "\u0386", "\u0388"-"\u038a", "\u038c", "\u038e"-"\u03a1", "\u03a3"-"\u03ce", "\u03d0"-"\u03d7", "\u03da"-"\u03f3", "\u0400"-"\u0481", "\u0483"-"\u0486", "\u048c"-"\u04c4", "\u04c7"-"\u04c8", "\u04cb"-"\u04cc", "\u04d0"-"\u04f5", "\u04f8"-"\u04f9", "\u0531"-"\u0556", "\u0559", "\u0561"-"\u0587", "\u0591"-"\u05a1", "\u05a3"-"\u05b9", "\u05bb"-"\u05bd", "\u05bf", "\u05c1"-"\u05c2", "\u05c4", "\u05d0"-"\u05ea", "\u05f0"-"\u05f2", "\u0621"-"\u063a", "\u0640"-"\u0655", "\u0660"-"\u0669", "\u0670"-"\u06d3", "\u06d5"-"\u06dc", "\u06df"-"\u06e8", "\u06ea"-"\u06ed", "\u06f0"-"\u06fc", "\u070f"-"\u072c", "\u0730"-"\u074a", "\u0780"-"\u07b0", "\u0901"-"\u0903", "\u0905"-"\u0939", "\u093c"-"\u094d", "\u0950"-"\u0954", "\u0958"-"\u0963", "\u0966"-"\u096f", "\u0981"-"\u0983", "\u0985"-"\u098c", "\u098f"-"\u0990", "\u0993"-"\u09a8", "\u09aa"-"\u09b0", "\u09b2", "\u09b6"-"\u09b9", "\u09bc", "\u09be"-"\u09c4", "\u09c7"-"\u09c8", "\u09cb"-"\u09cd", "\u09d7", "\u09dc"-"\u09dd", "\u09df"-"\u09e3", "\u09e6"-"\u09f3", "\u0a02", "\u0a05"-"\u0a0a", "\u0a0f"-"\u0a10", "\u0a13"-"\u0a28", "\u0a2a"-"\u0a30", "\u0a32"-"\u0a33", "\u0a35"-"\u0a36", "\u0a38"-"\u0a39", "\u0a3c", "\u0a3e"-"\u0a42", "\u0a47"-"\u0a48", "\u0a4b"-"\u0a4d", "\u0a59"-"\u0a5c", "\u0a5e", "\u0a66"-"\u0a74", "\u0a81"-"\u0a83", "\u0a85"-"\u0a8b", "\u0a8d", "\u0a8f"-"\u0a91", "\u0a93"-"\u0aa8", "\u0aaa"-"\u0ab0", "\u0ab2"-"\u0ab3", "\u0ab5"-"\u0ab9", "\u0abc"-"\u0ac5", "\u0ac7"-"\u0ac9", "\u0acb"-"\u0acd", "\u0ad0", "\u0ae0", "\u0ae6"-"\u0aef", "\u0b01"-"\u0b03", "\u0b05"-"\u0b0c", "\u0b0f"-"\u0b10", "\u0b13"-"\u0b28", "\u0b2a"-"\u0b30", "\u0b32"-"\u0b33", "\u0b36"-"\u0b39", "\u0b3c"-"\u0b43", "\u0b47"-"\u0b48", "\u0b4b"-"\u0b4d", "\u0b56"-"\u0b57", "\u0b5c"-"\u0b5d", "\u0b5f"-"\u0b61", "\u0b66"-"\u0b6f", "\u0b82"-"\u0b83", "\u0b85"-"\u0b8a", "\u0b8e"-"\u0b90", "\u0b92"-"\u0b95", "\u0b99"-"\u0b9a", "\u0b9c", "\u0b9e"-"\u0b9f", "\u0ba3"-"\u0ba4", "\u0ba8"-"\u0baa", "\u0bae"-"\u0bb5", "\u0bb7"-"\u0bb9", "\u0bbe"-"\u0bc2", "\u0bc6"-"\u0bc8", "\u0bca"-"\u0bcd", "\u0bd7", "\u0be7"-"\u0bef", "\u0c01"-"\u0c03", "\u0c05"-"\u0c0c", "\u0c0e"-"\u0c10", "\u0c12"-"\u0c28", "\u0c2a"-"\u0c33", "\u0c35"-"\u0c39", "\u0c3e"-"\u0c44", "\u0c46"-"\u0c48", "\u0c4a"-"\u0c4d", "\u0c55"-"\u0c56", "\u0c60"-"\u0c61", "\u0c66"-"\u0c6f", "\u0c82"-"\u0c83", "\u0c85"-"\u0c8c", "\u0c8e"-"\u0c90", "\u0c92"-"\u0ca8", "\u0caa"-"\u0cb3", "\u0cb5"-"\u0cb9", "\u0cbe"-"\u0cc4", "\u0cc6"-"\u0cc8", "\u0cca"-"\u0ccd", "\u0cd5"-"\u0cd6", "\u0cde", "\u0ce0"-"\u0ce1", "\u0ce6"-"\u0cef", "\u0d02"-"\u0d03", "\u0d05"-"\u0d0c", "\u0d0e"-"\u0d10", "\u0d12"-"\u0d28", "\u0d2a"-"\u0d39", "\u0d3e"-"\u0d43", "\u0d46"-"\u0d48", "\u0d4a"-"\u0d4d", "\u0d57", "\u0d60"-"\u0d61", "\u0d66"-"\u0d6f", "\u0d82"-"\u0d83", "\u0d85"-"\u0d96", "\u0d9a"-"\u0db1", "\u0db3"-"\u0dbb", "\u0dbd", "\u0dc0"-"\u0dc6", "\u0dca", "\u0dcf"-"\u0dd4", "\u0dd6", "\u0dd8"-"\u0ddf", "\u0df2"-"\u0df3", "\u0e01"-"\u0e3a", "\u0e3f"-"\u0e4e", "\u0e50"-"\u0e59", "\u0e81"-"\u0e82", "\u0e84", "\u0e87"-"\u0e88", "\u0e8a", "\u0e8d", "\u0e94"-"\u0e97", "\u0e99"-"\u0e9f", "\u0ea1"-"\u0ea3", "\u0ea5", "\u0ea7", "\u0eaa"-"\u0eab", "\u0ead"-"\u0eb9", "\u0ebb"-"\u0ebd", "\u0ec0"-"\u0ec4", "\u0ec6", "\u0ec8"-"\u0ecd", "\u0ed0"-"\u0ed9", "\u0edc"-"\u0edd", "\u0f00", "\u0f18"-"\u0f19", "\u0f20"-"\u0f29", "\u0f35", "\u0f37", "\u0f39", "\u0f3e"-"\u0f47", "\u0f49"-"\u0f6a", "\u0f71"-"\u0f84", "\u0f86"-"\u0f8b", "\u0f90"-"\u0f97", "\u0f99"-"\u0fbc", "\u0fc6", "\u1000"-"\u1021", "\u1023"-"\u1027", "\u1029"-"\u102a", "\u102c"-"\u1032", "\u1036"-"\u1039", "\u1040"-"\u1049", "\u1050"-"\u1059", "\u10a0"-"\u10c5", "\u10d0"-"\u10f6", "\u1100"-"\u1159", "\u115f"-"\u11a2", "\u11a8"-"\u11f9", "\u1200"-"\u1206", "\u1208"-"\u1246", "\u1248", "\u124a"-"\u124d", "\u1250"-"\u1256", "\u1258", "\u125a"-"\u125d", "\u1260"-"\u1286", "\u1288", "\u128a"-"\u128d", "\u1290"-"\u12ae", "\u12b0", "\u12b2"-"\u12b5", "\u12b8"-"\u12be", "\u12c0", "\u12c2"-"\u12c5", "\u12c8"-"\u12ce", "\u12d0"-"\u12d6", "\u12d8"-"\u12ee", "\u12f0"-"\u130e", "\u1310", "\u1312"-"\u1315", "\u1318"-"\u131e", "\u1320"-"\u1346", "\u1348"-"\u135a", "\u1369"-"\u1371", "\u13a0"-"\u13f4", "\u1401"-"\u166c", "\u166f"-"\u1676", "\u1681"-"\u169a", "\u16a0"-"\u16ea", "\u1780"-"\u17d3", "\u17db", "\u17e0"-"\u17e9", "\u180b"-"\u180e", "\u1810"-"\u1819", "\u1820"-"\u1877", "\u1880"-"\u18a9", "\u1e00"-"\u1e9b", "\u1ea0"-"\u1ef9", "\u1f00"-"\u1f15", "\u1f18"-"\u1f1d", "\u1f20"-"\u1f45", "\u1f48"-"\u1f4d", "\u1f50"-"\u1f57", "\u1f59", "\u1f5b", "\u1f5d", "\u1f5f"-"\u1f7d", "\u1f80"-"\u1fb4", "\u1fb6"-"\u1fbc", "\u1fbe", "\u1fc2"-"\u1fc4", "\u1fc6"-"\u1fcc", "\u1fd0"-"\u1fd3", "\u1fd6"-"\u1fdb", "\u1fe0"-"\u1fec", "\u1ff2"-"\u1ff4", "\u1ff6"-"\u1ffc", "\u200c"-"\u200f", "\u202a"-"\u202e", "\u203f"-"\u2040", "\u206a"-"\u206f", "\u207f", "\u20a0"-"\u20af", "\u20d0"-"\u20dc", "\u20e1", "\u2102", "\u2107", "\u210a"-"\u2113", "\u2115", "\u2119"-"\u211d", "\u2124", "\u2126", "\u2128", "\u212a"-"\u212d", "\u212f"-"\u2131", "\u2133"-"\u2139", "\u2160"-"\u2183", "\u3005"-"\u3007", "\u3021"-"\u302f", "\u3031"-"\u3035", "\u3038"-"\u303a", "\u3041"-"\u3094", "\u3099"-"\u309a", "\u309d"-"\u309e", "\u30a1"-"\u30fe", "\u3105"-"\u312c", "\u3131"-"\u318e", "\u31a0"-"\u31b7", "\u3400"-"\u4db5", "\u4e00"-"\u9fa5", "\ua000"-"\ua48c", "\uac00"-"\ud7a3", "\uf900"-"\ufa2d", "\ufb00"-"\ufb06", "\ufb13"-"\ufb17", "\ufb1d"-"\ufb28", "\ufb2a"-"\ufb36", "\ufb38"-"\ufb3c", "\ufb3e", "\ufb40"-"\ufb41", "\ufb43"-"\ufb44", "\ufb46"-"\ufbb1", "\ufbd3"-"\ufd3d", "\ufd50"-"\ufd8f", "\ufd92"-"\ufdc7", "\ufdf0"-"\ufdfb", "\ufe20"-"\ufe23", "\ufe33"-"\ufe34", "\ufe4d"-"\ufe4f", "\ufe69", "\ufe70"-"\ufe72", "\ufe74", "\ufe76"-"\ufefc", "\ufeff", "\uff04", "\uff10"-"\uff19", "\uff21"-"\uff3a", "\uff3f", "\uff41"-"\uff5a", "\uff65"-"\uffbe", "\uffc2"-"\uffc7", "\uffca"-"\uffcf", "\uffd2"-"\uffd7", "\uffda"-"\uffdc", "\uffe0"-"\uffe1", "\uffe5"-"\uffe6", "\ufff9"-"\ufffb" ] > } jtb-1.4.4/EDU/purdue/jtb/JTB.java0000644000175000017500000006101111360636752016111 0ustar cavedoncavedon/** * Copyright (c) 2004,2005 UCLA Compilers Group. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither UCLA nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ /* * All files in the distribution of JTB, The Java Tree Builder are * Copyright 1997, 1998, 1999 by the Purdue Research Foundation of Purdue * University. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all * such copies, and that any documentation, announcements, and * other materials related to such distribution and use acknowledge * that the software was developed at Purdue University, West Lafayette, * Indiana by Kevin Tao, Wanjun Wang and Jens Palsberg. No charge may * be made for copies, derivations, or distributions of this material * without the express written consent of the copyright holder. * Neither the name of the University nor the name of the author * may be used to endorse or promote products derived from this * material without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE. */ package EDU.purdue.jtb; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Map; import EDU.purdue.jtb.misc.ClassInfo; import EDU.purdue.jtb.misc.DepthFirstVisitorsGenerator; import EDU.purdue.jtb.misc.FileExistsException; import EDU.purdue.jtb.misc.FilesGenerator; import EDU.purdue.jtb.misc.Globals; import EDU.purdue.jtb.misc.Messages; import EDU.purdue.jtb.misc.TreeDumperGenerator; import EDU.purdue.jtb.misc.TreeFormatterGenerator; import EDU.purdue.jtb.parser.JTBParser; import EDU.purdue.jtb.parser.Options; import EDU.purdue.jtb.parser.ParseException; import EDU.purdue.jtb.syntaxtree.INode; import EDU.purdue.jtb.visitor.Annotator; import EDU.purdue.jtb.visitor.ClassGenerator; import EDU.purdue.jtb.visitor.SemanticChecker; /** * Java Tree Builder (JTB) Driver. *

* Class JTB contains the main() method of the program as well as related methods. * * @author Kevin Tao * @author Wanjun Wang, wanjun@purdue.edu * @author Marc Mazas, mmazas@sopragroup.com * @version 1.4.0 : 05/2009 : MMa : adapted to JavaCC v4.2 grammar and JDK 1.5
* 1.4.0 : 11/2009 : MMa : added input file options management * @version 1.4.0.3 : 02/2010 : MMa : added static flag */ public class JTB { /** the input file as an InputStream */ private static InputStream in; /** the program name (for display purposes) */ private static String progName = Globals.PROG_NAME; /** the program version (for display purposes) */ private static String version = Globals.VERSION; /** the script name */ private static String scriptName = Globals.SCRIPT_NAME; /** the input file options */ private static Map jtbOpt = null; /** * Standard main method. * * @param args the command line arguments */ public static void main(final String args[]) { try { // Get the command line arguments jtbOpt = Options.getOptions(); if (!processCommandLine(args)) return; // parse the input file System.err.println(progName + " version " + version); System.err .println(progName + ": Reading jtb input file " + Globals.jtbInputFileName + "..."); final JTBParser jtbParser = new JTBParser(in); final INode root = jtbParser.JavaCCInput(); System.err.println(progName + ": jtb input file parsed successfully."); // Get the input file options and overwrite command line options getFileOptionsAndOverwrite(); // // Perform actions based on input file or command-line options // final ClassGenerator vcg = new ClassGenerator(); ArrayList classes; FilesGenerator fg = null; Messages.resetCounts(); if (!Globals.noSemanticCheck) { root.accept(new SemanticChecker()); if (Messages.errorCount() > 0) { Messages.printSummary(); return; } } root.accept(vcg); // create the class list classes = vcg.getClassList(); if (Messages.errorCount() > 0) { Messages.printSummary(); return; } if (Globals.printClassList) { fg = new FilesGenerator(classes); System.out.println("\nThe classes generated and the fields each " + "contains are as follows:\n"); fg.outputFormattedNodesClassesList(new PrintWriter(System.out, true)); } try { final Annotator an = new Annotator(); root.accept(an); an.saveToFile(Globals.jtbOutputFileName); if (Messages.errorCount() > 0) { Messages.printSummary(); return; } if ((Globals.jtbOutputFileName.indexOf('/') >= 0) || (Globals.jtbOutputFileName.indexOf('\\') >= 0)) System.err.println(progName + ": jj output file \"" + Globals.jtbOutputFileName + "\" generated."); else System.err.println(progName + ": jj file \"" + Globals.jtbOutputFileName + "\" generated to current directory."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.jtbOutputFileName + "\" already exists. Won't overwrite."); } if (fg == null) { fg = new FilesGenerator(classes); if (Messages.errorCount() > 0) { Messages.printSummary(); return; } } try { fg.genBaseNodesFiles(); System.err.println(progName + ": base node class files " + "generated into directory \"" + Globals.nodesDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": One or more of the base " + "node class files already exists. Won't overwrite."); } try { fg.genNodesFiles(); System.err.println(progName + ": " + classes.size() + " syntax tree node class files " + "generated into directory \"" + Globals.nodesDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": One or more of the generated " + "node class files already exists. Won't overwrite."); } System.err.println(); try { fg.genRetArguIVisitorFile(); System.err.println(progName + ": Visitor interface \"" + Globals.iRetArguVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.iRetArguVisitorName + "\" already exists. Won't overwrite."); } try { fg.genVoidIVisitorFile(); System.err.println(progName + ": Visitor interface \"" + Globals.iVoidVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.iVoidVisitorName + "\" already exists. Won't overwrite."); } try { fg.genRetIVisitorFile(); System.err.println(progName + ": Visitor interface \"" + Globals.iRetVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.iRetVisitorName + "\" already exists. Won't overwrite."); } try { fg.genVoidArguIVisitorFile(); System.err.println(progName + ": Visitor interface \"" + Globals.iVoidArguVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.iVoidArguVisitorName + "\" already exists. Won't overwrite."); } final DepthFirstVisitorsGenerator dfvg = new DepthFirstVisitorsGenerator(classes); try { dfvg.genDepthFirstRetArguVisitorFile(); System.err.println(progName + ": Visitor class \"" + Globals.dFRetArguVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.dFRetArguVisitorName + ".java\" already exists. Won't overwrite."); } try { dfvg.genDepthFirstRetVisitorFile(); System.err.println(progName + ": Visitor class \"" + Globals.dFRetVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.dFRetVisitorName + ".java\" already exists. Won't overwrite."); } try { dfvg.genDepthFirstVoidArguVisitorFile(); System.err.println(progName + ": Visitor class \"" + Globals.dFVoidArguVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.dFVoidArguVisitorName + ".java\" already exists. Won't overwrite."); } try { dfvg.genDepthFirstVoidVisitorFile(); System.err.println(progName + ": Visitor class \"" + Globals.dFVoidVisitorName + ".java\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + Globals.dFVoidVisitorName + ".java\" already exists. Won't overwrite."); } System.err.println(); if (Globals.printerToolkit) { try { final TreeDumperGenerator tdg = new TreeDumperGenerator(); tdg.generateTreeDumper(); tdg.saveToFile(); System.err.println(progName + ": Visitor class \"" + TreeDumperGenerator.outFilename + "\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + TreeDumperGenerator.outFilename + "\" already exists. Won't overwrite."); } try { final TreeFormatterGenerator tfg = new TreeFormatterGenerator(classes); tfg.generateTreeFormatter(); tfg.saveToFile(); System.err.println(progName + ": Visitor class \"" + TreeFormatterGenerator.outFilename + "\" generated into directory \"" + Globals.visitorsDirName + "\"."); } catch (final FileExistsException e) { System.err.println(progName + ": \"" + TreeFormatterGenerator.outFilename + "\" already exists. Won't overwrite."); } System.err.println(); } if (Messages.errorCount() > 0 || Messages.warningCount() > 0) Messages.printSummary(); } catch (final InvalCmdLineException e) { System.err.println(progName + ": " + e.getMessage()); return; } catch (final ParseException e) { System.err.println("\n" + e.getMessage() + "\n"); System.err.println(progName + ": Encountered error(s) during parsing."); } catch (final Exception e) { e.printStackTrace(System.err); Messages.hardErr(e); } } /** * Gets the input file options and overwrite command line ones if they are different. */ private static void getFileOptionsAndOverwrite() { String str = null; Globals.printClassList = ((Boolean) jtbOpt.get("JTB_CL")).booleanValue(); Globals.depthLevel = ((Boolean) jtbOpt.get("JTB_DL")).booleanValue(); Globals.noSemanticCheck = ((Boolean) jtbOpt.get("JTB_E")).booleanValue(); Globals.descriptiveFieldNames = ((Boolean) jtbOpt.get("JTB_F")).booleanValue(); Globals.inlineAcceptMethods = ((Boolean) jtbOpt.get("JTB_IA")).booleanValue(); Globals.javaDocComments = ((Boolean) jtbOpt.get("JTB_JD")).booleanValue(); Globals.nodesDirName = (String) jtbOpt.get("JTB_ND"); Globals.nodesPackageName = (String) jtbOpt.get("JTB_NP"); str = (String) jtbOpt.get("JTB_NS"); Globals.nodesSuperclass = "".equals(str) ? null : str; Globals.jtbOutputFileName = (String) jtbOpt.get("JTB_O"); Globals.parentPointer = ((Boolean) jtbOpt.get("JTB_PP")).booleanValue(); Globals.printerToolkit = ((Boolean) jtbOpt.get("JTB_PRINTER")).booleanValue(); Globals.schemeToolkit = ((Boolean) jtbOpt.get("JTB_SCHEME")).booleanValue(); Globals.keepSpecialTokens = ((Boolean) jtbOpt.get("JTB_TK")).booleanValue(); Globals.visitorsDirName = (String) jtbOpt.get("JTB_VD"); Globals.visitorsPackageName = (String) jtbOpt.get("JTB_VP"); Globals.noOverwrite = ((Boolean) jtbOpt.get("JTB_W")).booleanValue(); str = (String) jtbOpt.get("JTB_D"); if (!"".equals(str)) { Globals.nodesDirName = str + "/" + Globals.DEF_ND_DIR_NAME; Globals.visitorsDirName = str + "/" + Globals.DEF_VIS_DIR_NAME; } str = (String) jtbOpt.get("JTB_P"); if (!"".equals(str)) { Globals.nodesPackageName = str + "." + Globals.DEF_ND_PKG_NAME; Globals.visitorsPackageName = str + "." + Globals.DEF_VIS_PKG_NAME; } Globals.staticFlag = ((Boolean) jtbOpt.get("STATIC")).booleanValue(); } /** * Processes command line arguments, putting options in the options object (to be overwritten by * input file options). * * @param args the command line arguments * @return true if successful, false otherwise * @throws InvalCmdLineException if any problem with command line arguments */ private static boolean processCommandLine(final String[] args) throws InvalCmdLineException { boolean returnVal = false; for (int i = 0; i < args.length; ++i) { if (args[i].charAt(0) != '-') { if (returnVal) { returnVal = false; // 2 filenames passed as arguments? break; } else { try { in = new java.io.FileInputStream(args[i]); } catch (final java.io.FileNotFoundException e) { System.err.println(progName + ": File \"" + args[i] + "\" not found."); return false; } Globals.jtbInputFileName = args[i]; returnVal = true; } } else { if (args[i].length() <= 1) throw new InvalCmdLineException("Unknown option \"" + args[i] + "\". Try \"" + scriptName + " -h\" for more " + "information."); if (args[i].equals("-h")) { returnVal = false; break; } else if (args[i].equals("-cl")) { Globals.printClassList = true; jtbOpt.put("JTB_CL", Boolean.TRUE); } else if (args[i].equals("-d")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-d\" must be followed by a directory name."); else { Globals.nodesDirName = args[i] + "/" + Globals.DEF_ND_DIR_NAME; Globals.visitorsDirName = args[i] + "/" + Globals.DEF_VIS_DIR_NAME; jtbOpt.put("JTB_D", args[i]); jtbOpt.put("JTB_ND", Globals.nodesDirName); jtbOpt.put("JTB_VD", Globals.visitorsDirName); } } else if (args[i].equals("-dl")) { Globals.depthLevel = true; jtbOpt.put("JTB_DL", Boolean.TRUE); } else if (args[i].equals("-e")) { Globals.noSemanticCheck = true; jtbOpt.put("JTB_E", Boolean.TRUE); } else if (args[i].equals("-f")) { Globals.descriptiveFieldNames = true; jtbOpt.put("JTB_F", Boolean.TRUE); } else if (args[i].equals("-ia")) { Globals.inlineAcceptMethods = true; jtbOpt.put("JTB_IA", Boolean.TRUE); } else if (args[i].equals("-jd")) { Globals.javaDocComments = true; jtbOpt.put("JTB_JD", Boolean.TRUE); } else if (args[i].equals("-nd")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-nd\" must be followed by a directory name."); else { Globals.nodesDirName = args[i]; jtbOpt.put("JTB_ND", Globals.nodesDirName); } } else if (args[i].equals("-np")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-np\" must be followed by a package name."); else { Globals.nodesPackageName = args[i]; jtbOpt.put("JTB_NP", Globals.nodesPackageName); } } else if (args[i].equals("-ns")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-ns\" must be followed by a class name."); else { Globals.nodesSuperclass = args[i]; jtbOpt.put("JTB_NS", Globals.nodesSuperclass); } } else if (args[i].equals("-o")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-o\" must be followed by a filename."); else { Globals.jtbOutputFileName = args[i]; jtbOpt.put("JTB_O", Globals.jtbOutputFileName); } } else if (args[i].equals("-p")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-p\" must be followed by a package name."); else { Globals.nodesPackageName = args[i] + "." + Globals.DEF_ND_PKG_NAME; Globals.visitorsPackageName = args[i] + "." + Globals.DEF_VIS_PKG_NAME; jtbOpt.put("JTB_P", args[i]); jtbOpt.put("JTB_NP", Globals.nodesPackageName); jtbOpt.put("JTB_VP", Globals.visitorsPackageName); } } else if (args[i].equals("-pp")) { Globals.parentPointer = true; jtbOpt.put("JTB_PP", Boolean.TRUE); } else if (args[i].equals("-printer")) { Globals.printerToolkit = true; jtbOpt.put("JTB_PRINTER", Boolean.TRUE); } else if (args[i].equals("-scheme")) { Globals.schemeToolkit = true; jtbOpt.put("JTB_SCHEME", Boolean.TRUE); } else if (args[i].equals("-si")) { in = System.in; Globals.jtbInputFileName = "standard input"; } else if (args[i].equals("-tk")) { Globals.keepSpecialTokens = true; jtbOpt.put("JTB_TK", Boolean.TRUE); } else if (args[i].equals("-vd")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-vd\" must be followed by a directory name."); else { Globals.visitorsDirName = args[i]; jtbOpt.put("JTB_VD", Globals.visitorsDirName); } } else if (args[i].equals("-vp")) { ++i; if (i >= args.length || args[i].charAt(0) == '-') throw new InvalCmdLineException("Option \"-vp\" must be followed by a package name."); else { Globals.visitorsPackageName = args[i]; jtbOpt.put("JTB_VP", Globals.visitorsPackageName); } } else if (args[i].equals("-w")) { Globals.noOverwrite = true; jtbOpt.put("JTB_W", Boolean.TRUE); } else throw new InvalCmdLineException("Unknown option \"" + args[i] + "\". Try \"" + scriptName + " -h\" for more information."); } } if (returnVal) return true; else { printHelp(); return false; } } /** * Displays program usage. */ private static void printHelp() { System.out .print(progName + " version " + version + "\n" + "\n" + "Usage: " + scriptName + " [OPTIONS] " + "[inputfile]\n" + "\n" + "Standard options:\n" + " -cl Print a list of the classes generated to standard out.\n" + " -d dir \"-d dir\" is short for (and overwrites) \"-nd dir/syntaxtree -vd dir/visitor\".\n" + " -dl Generate depth level info.\n" + " -e Suppress JTB semantic error checking.\n" + " -f Use descriptive node class field names.\n" + " -h Display this help message and quit.\n" + " -ia Inline visitors accept methods on base classes.\n" + " -jd Generate JavaDoc-friendly comments in the nodes and visitor.\n" + " -nd dir Use dir as the package for the syntax tree nodes.\n" + " -np pkg Use pkg as the package for the syntax tree nodes.\n" + " -ns class Use class as the class which all node classes will extend.\n" + " -o file Use file as the filename for the annotated output grammar.\n" + " -p pkg \"-p pkg\" is short for (and overwrites) \"-np pkg.syntaxtree -vp pkg.visitor\".\n" + " -pp Generate parent pointers in all node classes.\n" + " -printer Generate a syntax tree dumping visitor.\n" + " -si Read from standard input rather than a file.\n" + " -scheme Generate Scheme records representing the grammar and a Scheme tree building visitor.\n" + " -tk Generate special tokens into the tree.\n" + " -vd dir Use dir as the package for the default visitor classes.\n" + " -vp pkg Use pkg as the package for the default visitor classes.\n" + " -w Do not overwrite existing files.\n" + "\n"); } } /** * Inner class for managing command line errors. */ class InvalCmdLineException extends Exception { /** default serialVersionUID */ private static final long serialVersionUID = 1L; /** * Standard constructor with no argument. */ InvalCmdLineException() { super(); } /** * Standard constructor with a message. * * @param s the exception message */ InvalCmdLineException(final String s) { super(s); } } jtb-1.4.4/EDU/purdue/jtb/jtb.out.jj-1320000644000175000017500000026463011360636752017060 0ustar cavedoncavedon// // Generated by JTB 1.3.1 // options { JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(JTBParser) package EDU.purdue.jtb.parser; import EDU.purdue.jtb.misc.UnicodeConverter; import EDU.purdue.jtb.syntaxtree.*; import java.util.Vector; public class JTBParser { } class JTBToolkit { static NodeToken makeNodeToken(Token t) { return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn); } } PARSER_END(JTBParser) SKIP : { " " | "\t" | "\n" | "\r" | "\f" } SPECIAL_TOKEN : { | | } TOKEN : { | | | | | | | | | | <_DEFAULT: "default"> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | } TOKEN : { (["l", "L"])? | (["l", "L"])? | (["l", "L"])?> | <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])*> | <#HEX_LITERAL: "0" ["x", "X"] (["0"-"9", "a"-"f", "A"-"F"])+> | <#OCTAL_LITERAL: "0" (["0"-"7"])*> | )? (["f", "F", "d", "D"])? | "." (["0"-"9"])+ ()? (["f", "F", "d", "D"])? | (["0"-"9"])+ (["f", "F", "d", "D"])? | (["0"-"9"])+ ()? ["f", "F", "d", "D"]> | <#EXPONENT: ["e", "E"] (["+", "-"])? (["0"-"9"])+> | { matchedToken.image = UnicodeConverter.convertString(image.toString()); } | { matchedToken.image = UnicodeConverter.convertString(image.toString()); } } TOKEN : { <#LETTER: ["$", "A"-"Z", "_", "a"-"z", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff"]> | <#DIGIT: ["0"-"9", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049"]> } TOKEN : { | | | | | | | | } TOKEN : { "> | | | | | | | ="> | | | | | | | | | | | | | | >"> | >>"> | | >="> | >>="> } CompilationUnit CompilationUnit() : { NodeOptional n0 = new NodeOptional(); PackageDeclaration n1; NodeListOptional n2 = new NodeListOptional(); ImportDeclaration n3; NodeListOptional n4 = new NodeListOptional(); TypeDeclaration n5; { } } { ( n1=PackageDeclaration() { n0.addNode(n1); } )? ( n3=ImportDeclaration() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } ( n5=TypeDeclaration() { n4.addNode(n5); } )* { n4.nodes.trimToSize(); } { return new CompilationUnit(n0,n2,n4); } } PackageDeclaration PackageDeclaration() : { NodeToken n0; Token n1; Name n2; NodeToken n3; Token n4; { } } { n1="package" { n0 = JTBToolkit.makeNodeToken(n1); } n2=Name() n4=";" { n3 = JTBToolkit.makeNodeToken(n4); } { return new PackageDeclaration(n0,n2,n3); } } ImportDeclaration ImportDeclaration() : { NodeToken n0; Token n1; Name n2; NodeOptional n3 = new NodeOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeToken n9; Token n10; { } } { n1="import" { n0 = JTBToolkit.makeNodeToken(n1); } n2=Name() ( { n4 = new NodeSequence(2); } n6="." { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8="*" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )? n10=";" { n9 = JTBToolkit.makeNodeToken(n10); } { return new ImportDeclaration(n0,n2,n3,n9); } } TypeDeclaration TypeDeclaration() : { NodeChoice n0; ClassDeclaration n1; InterfaceDeclaration n2; NodeToken n3; Token n4; { } } { ( LOOKAHEAD(( "abstract" | "final" | "public" )* "class") n1=ClassDeclaration() { n0 = new NodeChoice(n1, 0); } | n2=InterfaceDeclaration() { n0 = new NodeChoice(n2, 1); } | n4=";" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 2); } ) { return new TypeDeclaration(n0); } } ClassDeclaration ClassDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; UnmodifiedClassDeclaration n8; { } } { ( ( n3="abstract" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="final" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="public" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n8=UnmodifiedClassDeclaration() { return new ClassDeclaration(n0,n8); } } UnmodifiedClassDeclaration UnmodifiedClassDeclaration() : { NodeToken n0; Token n1; NodeToken n2; Token n3; NodeOptional n4 = new NodeOptional(); NodeSequence n5; NodeToken n6; Token n7; Name n8; NodeOptional n9 = new NodeOptional(); NodeSequence n10; NodeToken n11; Token n12; NameList n13; ClassBody n14; { } } { n1="class" { n0 = JTBToolkit.makeNodeToken(n1); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } ( { n5 = new NodeSequence(2); } n7="extends" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8=Name() { n5.addNode(n8); } { n4.addNode(n5); } )? ( { n10 = new NodeSequence(2); } n12="implements" { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } n13=NameList() { n10.addNode(n13); } { n9.addNode(n10); } )? n14=ClassBody() { return new UnmodifiedClassDeclaration(n0,n2,n4,n9,n14); } } ClassBody ClassBody() : { NodeToken n0; Token n1; NodeListOptional n2 = new NodeListOptional(); ClassBodyDeclaration n3; NodeToken n4; Token n5; { } } { n1="{" { n0 = JTBToolkit.makeNodeToken(n1); } ( n3=ClassBodyDeclaration() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } n5="}" { n4 = JTBToolkit.makeNodeToken(n5); } { return new ClassBody(n0,n2,n4); } } NestedClassDeclaration NestedClassDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeToken n12; Token n13; UnmodifiedClassDeclaration n14; { } } { ( ( n3="static" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="abstract" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="final" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } | n9="public" { n8 = JTBToolkit.makeNodeToken(n9); } { n1 = new NodeChoice(n8, 3); } | n11="protected" { n10 = JTBToolkit.makeNodeToken(n11); } { n1 = new NodeChoice(n10, 4); } | n13="private" { n12 = JTBToolkit.makeNodeToken(n13); } { n1 = new NodeChoice(n12, 5); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n14=UnmodifiedClassDeclaration() { return new NestedClassDeclaration(n0,n14); } } ClassBodyDeclaration ClassBodyDeclaration() : { NodeChoice n0; Initializer n1; NestedClassDeclaration n2; NestedInterfaceDeclaration n3; ConstructorDeclaration n4; MethodDeclaration n5; FieldDeclaration n6; { } } { ( LOOKAHEAD(2) n1=Initializer() { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD(( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class") n2=NestedClassDeclaration() { n0 = new NodeChoice(n2, 1); } | LOOKAHEAD(( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface") n3=NestedInterfaceDeclaration() { n0 = new NodeChoice(n3, 2); } | LOOKAHEAD([ "public" | "protected" | "private" ] Name() "(") n4=ConstructorDeclaration() { n0 = new NodeChoice(n4, 3); } | LOOKAHEAD(MethodDeclarationLookahead()) n5=MethodDeclaration() { n0 = new NodeChoice(n5, 4); } | n6=FieldDeclaration() { n0 = new NodeChoice(n6, 5); } ) { return new ClassBodyDeclaration(n0); } } MethodDeclarationLookahead MethodDeclarationLookahead() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeToken n12; Token n13; NodeToken n14; Token n15; NodeToken n16; Token n17; ResultType n18; NodeToken n19; Token n20; NodeToken n21; Token n22; { } } { ( ( n3="public" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="protected" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="private" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } | n9="static" { n8 = JTBToolkit.makeNodeToken(n9); } { n1 = new NodeChoice(n8, 3); } | n11="abstract" { n10 = JTBToolkit.makeNodeToken(n11); } { n1 = new NodeChoice(n10, 4); } | n13="final" { n12 = JTBToolkit.makeNodeToken(n13); } { n1 = new NodeChoice(n12, 5); } | n15="native" { n14 = JTBToolkit.makeNodeToken(n15); } { n1 = new NodeChoice(n14, 6); } | n17="synchronized" { n16 = JTBToolkit.makeNodeToken(n17); } { n1 = new NodeChoice(n16, 7); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n18=ResultType() n20= { n19 = JTBToolkit.makeNodeToken(n20); } n22="(" { n21 = JTBToolkit.makeNodeToken(n22); } { return new MethodDeclarationLookahead(n0,n18,n19,n21); } } InterfaceDeclaration InterfaceDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; UnmodifiedInterfaceDeclaration n6; { } } { ( ( n3="abstract" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="public" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n6=UnmodifiedInterfaceDeclaration() { return new InterfaceDeclaration(n0,n6); } } NestedInterfaceDeclaration NestedInterfaceDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeToken n12; Token n13; UnmodifiedInterfaceDeclaration n14; { } } { ( ( n3="static" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="abstract" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="final" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } | n9="public" { n8 = JTBToolkit.makeNodeToken(n9); } { n1 = new NodeChoice(n8, 3); } | n11="protected" { n10 = JTBToolkit.makeNodeToken(n11); } { n1 = new NodeChoice(n10, 4); } | n13="private" { n12 = JTBToolkit.makeNodeToken(n13); } { n1 = new NodeChoice(n12, 5); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n14=UnmodifiedInterfaceDeclaration() { return new NestedInterfaceDeclaration(n0,n14); } } UnmodifiedInterfaceDeclaration UnmodifiedInterfaceDeclaration() : { NodeToken n0; Token n1; NodeToken n2; Token n3; NodeOptional n4 = new NodeOptional(); NodeSequence n5; NodeToken n6; Token n7; NameList n8; NodeToken n9; Token n10; NodeListOptional n11 = new NodeListOptional(); InterfaceMemberDeclaration n12; NodeToken n13; Token n14; { } } { n1="interface" { n0 = JTBToolkit.makeNodeToken(n1); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } ( { n5 = new NodeSequence(2); } n7="extends" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8=NameList() { n5.addNode(n8); } { n4.addNode(n5); } )? n10="{" { n9 = JTBToolkit.makeNodeToken(n10); } ( n12=InterfaceMemberDeclaration() { n11.addNode(n12); } )* { n11.nodes.trimToSize(); } n14="}" { n13 = JTBToolkit.makeNodeToken(n14); } { return new UnmodifiedInterfaceDeclaration(n0,n2,n4,n9,n11,n13); } } InterfaceMemberDeclaration InterfaceMemberDeclaration() : { NodeChoice n0; NestedClassDeclaration n1; NestedInterfaceDeclaration n2; MethodDeclaration n3; FieldDeclaration n4; { } } { ( LOOKAHEAD(( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class") n1=NestedClassDeclaration() { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD(( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface") n2=NestedInterfaceDeclaration() { n0 = new NodeChoice(n2, 1); } | LOOKAHEAD(MethodDeclarationLookahead()) n3=MethodDeclaration() { n0 = new NodeChoice(n3, 2); } | n4=FieldDeclaration() { n0 = new NodeChoice(n4, 3); } ) { return new InterfaceMemberDeclaration(n0); } } FieldDeclaration FieldDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeToken n12; Token n13; NodeToken n14; Token n15; Type n16; VariableDeclarator n17; NodeListOptional n18 = new NodeListOptional(); NodeSequence n19; NodeToken n20; Token n21; VariableDeclarator n22; NodeToken n23; Token n24; { } } { ( ( n3="public" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="protected" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="private" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } | n9="static" { n8 = JTBToolkit.makeNodeToken(n9); } { n1 = new NodeChoice(n8, 3); } | n11="final" { n10 = JTBToolkit.makeNodeToken(n11); } { n1 = new NodeChoice(n10, 4); } | n13="transient" { n12 = JTBToolkit.makeNodeToken(n13); } { n1 = new NodeChoice(n12, 5); } | n15="volatile" { n14 = JTBToolkit.makeNodeToken(n15); } { n1 = new NodeChoice(n14, 6); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n16=Type() n17=VariableDeclarator() ( { n19 = new NodeSequence(2); } n21="," { n20 = JTBToolkit.makeNodeToken(n21); } { n19.addNode(n20); } n22=VariableDeclarator() { n19.addNode(n22); } { n18.addNode(n19); } )* { n18.nodes.trimToSize(); } n24=";" { n23 = JTBToolkit.makeNodeToken(n24); } { return new FieldDeclaration(n0,n16,n17,n18,n23); } } VariableDeclarator VariableDeclarator() : { VariableDeclaratorId n0; NodeOptional n1 = new NodeOptional(); NodeSequence n2; NodeToken n3; Token n4; VariableInitializer n5; { } } { n0=VariableDeclaratorId() ( { n2 = new NodeSequence(2); } n4="=" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=VariableInitializer() { n2.addNode(n5); } { n1.addNode(n2); } )? { return new VariableDeclarator(n0,n1); } } VariableDeclaratorId VariableDeclaratorId() : { NodeToken n0; Token n1; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3; NodeToken n4; Token n5; NodeToken n6; Token n7; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } ( { n3 = new NodeSequence(2); } n5="[" { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n7="]" { n6 = JTBToolkit.makeNodeToken(n7); } { n3.addNode(n6); } { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } { return new VariableDeclaratorId(n0,n2); } } VariableInitializer VariableInitializer() : { NodeChoice n0; ArrayInitializer n1; Expression n2; { } } { ( n1=ArrayInitializer() { n0 = new NodeChoice(n1, 0); } | n2=Expression() { n0 = new NodeChoice(n2, 1); } ) { return new VariableInitializer(n0); } } ArrayInitializer ArrayInitializer() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); NodeSequence n3; VariableInitializer n4; NodeListOptional n5; NodeSequence n6; NodeToken n7; Token n8; VariableInitializer n9; NodeOptional n10 = new NodeOptional(); NodeToken n11; Token n12; NodeToken n13; Token n14; { } } { n1="{" { n0 = JTBToolkit.makeNodeToken(n1); } ( { n5 = new NodeListOptional(); } { n3 = new NodeSequence(2); } n4=VariableInitializer() { n3.addNode(n4); } ( LOOKAHEAD(2) { n6 = new NodeSequence(2); } n8="," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9=VariableInitializer() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { n3.addNode(n5); } { n2.addNode(n3); } )? ( n12="," { n11 = JTBToolkit.makeNodeToken(n12); } { n10.addNode(n11); } )? n14="}" { n13 = JTBToolkit.makeNodeToken(n14); } { return new ArrayInitializer(n0,n2,n10,n13); } } MethodDeclaration MethodDeclaration() : { NodeListOptional n0 = new NodeListOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeToken n12; Token n13; NodeToken n14; Token n15; NodeToken n16; Token n17; ResultType n18; MethodDeclarator n19; NodeOptional n20 = new NodeOptional(); NodeSequence n21; NodeToken n22; Token n23; NameList n24; NodeChoice n25; Block n26; NodeToken n27; Token n28; { } } { ( ( n3="public" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="protected" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="private" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } | n9="static" { n8 = JTBToolkit.makeNodeToken(n9); } { n1 = new NodeChoice(n8, 3); } | n11="abstract" { n10 = JTBToolkit.makeNodeToken(n11); } { n1 = new NodeChoice(n10, 4); } | n13="final" { n12 = JTBToolkit.makeNodeToken(n13); } { n1 = new NodeChoice(n12, 5); } | n15="native" { n14 = JTBToolkit.makeNodeToken(n15); } { n1 = new NodeChoice(n14, 6); } | n17="synchronized" { n16 = JTBToolkit.makeNodeToken(n17); } { n1 = new NodeChoice(n16, 7); } ) { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } n18=ResultType() n19=MethodDeclarator() ( { n21 = new NodeSequence(2); } n23="throws" { n22 = JTBToolkit.makeNodeToken(n23); } { n21.addNode(n22); } n24=NameList() { n21.addNode(n24); } { n20.addNode(n21); } )? ( ( n26=Block() { n25 = new NodeChoice(n26, 0); } | n28=";" { n27 = JTBToolkit.makeNodeToken(n28); } { n25 = new NodeChoice(n27, 1); } ) ) { return new MethodDeclaration(n0,n18,n19,n20,n25); } } MethodDeclarator MethodDeclarator() : { NodeToken n0; Token n1; FormalParameters n2; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } n2=FormalParameters() ( { n4 = new NodeSequence(2); } n6="[" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8="]" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { return new MethodDeclarator(n0,n2,n3); } } FormalParameters FormalParameters() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); NodeSequence n3; FormalParameter n4; NodeListOptional n5; NodeSequence n6; NodeToken n7; Token n8; FormalParameter n9; NodeToken n10; Token n11; { } } { n1="(" { n0 = JTBToolkit.makeNodeToken(n1); } ( { n5 = new NodeListOptional(); } { n3 = new NodeSequence(2); } n4=FormalParameter() { n3.addNode(n4); } ( { n6 = new NodeSequence(2); } n8="," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9=FormalParameter() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { n3.addNode(n5); } { n2.addNode(n3); } )? n11=")" { n10 = JTBToolkit.makeNodeToken(n11); } { return new FormalParameters(n0,n2,n10); } } FormalParameter FormalParameter() : { NodeOptional n0 = new NodeOptional(); NodeToken n1; Token n2; Type n3; VariableDeclaratorId n4; { } } { ( n2="final" { n1 = JTBToolkit.makeNodeToken(n2); } { n0.addNode(n1); } )? n3=Type() n4=VariableDeclaratorId() { return new FormalParameter(n0,n3,n4); } } ConstructorDeclaration ConstructorDeclaration() : { NodeOptional n0 = new NodeOptional(); NodeChoice n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; FormalParameters n10; NodeOptional n11 = new NodeOptional(); NodeSequence n12; NodeToken n13; Token n14; NameList n15; NodeToken n16; Token n17; NodeOptional n18 = new NodeOptional(); ExplicitConstructorInvocation n19; NodeListOptional n20 = new NodeListOptional(); BlockStatement n21; NodeToken n22; Token n23; { } } { ( ( n3="public" { n2 = JTBToolkit.makeNodeToken(n3); } { n1 = new NodeChoice(n2, 0); } | n5="protected" { n4 = JTBToolkit.makeNodeToken(n5); } { n1 = new NodeChoice(n4, 1); } | n7="private" { n6 = JTBToolkit.makeNodeToken(n7); } { n1 = new NodeChoice(n6, 2); } ) { n0.addNode(n1); } )? n9= { n8 = JTBToolkit.makeNodeToken(n9); } n10=FormalParameters() ( { n12 = new NodeSequence(2); } n14="throws" { n13 = JTBToolkit.makeNodeToken(n14); } { n12.addNode(n13); } n15=NameList() { n12.addNode(n15); } { n11.addNode(n12); } )? n17="{" { n16 = JTBToolkit.makeNodeToken(n17); } ( LOOKAHEAD(ExplicitConstructorInvocation()) n19=ExplicitConstructorInvocation() { n18.addNode(n19); } )? ( n21=BlockStatement() { n20.addNode(n21); } )* { n20.nodes.trimToSize(); } n23="}" { n22 = JTBToolkit.makeNodeToken(n23); } { return new ConstructorDeclaration(n0,n8,n10,n11,n16,n18,n20,n22); } } ExplicitConstructorInvocation ExplicitConstructorInvocation() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; Arguments n4; NodeToken n5; Token n6; NodeSequence n7; NodeOptional n8 = new NodeOptional(); NodeSequence n9; PrimaryExpression n10; NodeToken n11; Token n12; NodeToken n13; Token n14; Arguments n15; NodeToken n16; Token n17; { } } { ( LOOKAHEAD("this" Arguments() ";") { n1 = new NodeSequence(4); } n3="this" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=Arguments() { n1.addNode(n4); } n6=";" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } { n0 = new NodeChoice(n1, 0); } | { n7 = new NodeSequence(4); } ( LOOKAHEAD(2) { n9 = new NodeSequence(2); } n10=PrimaryExpression() { n9.addNode(n10); } n12="." { n11 = JTBToolkit.makeNodeToken(n12); } { n9.addNode(n11); } { n8.addNode(n9); } )? { n7.addNode(n8); } n14="super" { n13 = JTBToolkit.makeNodeToken(n14); } { n7.addNode(n13); } n15=Arguments() { n7.addNode(n15); } n17=";" { n16 = JTBToolkit.makeNodeToken(n17); } { n7.addNode(n16); } { n0 = new NodeChoice(n7, 1); } ) { return new ExplicitConstructorInvocation(n0); } } Initializer Initializer() : { NodeOptional n0 = new NodeOptional(); NodeToken n1; Token n2; Block n3; { } } { ( n2="static" { n1 = JTBToolkit.makeNodeToken(n2); } { n0.addNode(n1); } )? n3=Block() { return new Initializer(n0,n3); } } Type Type() : { NodeChoice n0; PrimitiveType n1; Name n2; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; { } } { ( ( n1=PrimitiveType() { n0 = new NodeChoice(n1, 0); } | n2=Name() { n0 = new NodeChoice(n2, 1); } ) ) ( { n4 = new NodeSequence(2); } n6="[" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8="]" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } { return new Type(n0,n3); } } PrimitiveType PrimitiveType() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeToken n13; Token n14; NodeToken n15; Token n16; { } } { ( n2="boolean" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4="char" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } | n6="byte" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2); } | n8="short" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3); } | n10="int" { n9 = JTBToolkit.makeNodeToken(n10); } { n0 = new NodeChoice(n9, 4); } | n12="long" { n11 = JTBToolkit.makeNodeToken(n12); } { n0 = new NodeChoice(n11, 5); } | n14="float" { n13 = JTBToolkit.makeNodeToken(n14); } { n0 = new NodeChoice(n13, 6); } | n16="double" { n15 = JTBToolkit.makeNodeToken(n16); } { n0 = new NodeChoice(n15, 7); } ) { return new PrimitiveType(n0); } } ResultType ResultType() : { NodeChoice n0; NodeToken n1; Token n2; Type n3; { } } { ( n2="void" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n3=Type() { n0 = new NodeChoice(n3, 1); } ) { return new ResultType(n0); } } Name Name() : { NodeToken n0; Token n1; NodeListOptional n2 = new NodeListOptional(); NodeSequence n3; NodeToken n4; Token n5; NodeToken n6; Token n7; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } ( LOOKAHEAD(2) { n3 = new NodeSequence(2); } n5="." { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n7= { n6 = JTBToolkit.makeNodeToken(n7); } { n3.addNode(n6); } { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } { return new Name(n0,n2); } } NameList NameList() : { Name n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; Name n5; { } } { n0=Name() ( { n2 = new NodeSequence(2); } n4="," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Name() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new NameList(n0,n1); } } Expression Expression() : { NodeChoice n0; Assignment n1; ConditionalExpression n2; { } } { ( LOOKAHEAD(PrimaryExpression() AssignmentOperator()) n1=Assignment() { n0 = new NodeChoice(n1, 0); } | n2=ConditionalExpression() { n0 = new NodeChoice(n2, 1); } ) { return new Expression(n0); } } Assignment Assignment() : { PrimaryExpression n0; AssignmentOperator n1; Expression n2; { } } { n0=PrimaryExpression() n1=AssignmentOperator() n2=Expression() { return new Assignment(n0,n1,n2); } } AssignmentOperator AssignmentOperator() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeToken n13; Token n14; NodeToken n15; Token n16; NodeToken n17; Token n18; NodeToken n19; Token n20; NodeToken n21; Token n22; NodeToken n23; Token n24; { } } { ( n2="=" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4="*=" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } | n6="/=" { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2); } | n8="%=" { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3); } | n10="+=" { n9 = JTBToolkit.makeNodeToken(n10); } { n0 = new NodeChoice(n9, 4); } | n12="-=" { n11 = JTBToolkit.makeNodeToken(n12); } { n0 = new NodeChoice(n11, 5); } | n14="<<=" { n13 = JTBToolkit.makeNodeToken(n14); } { n0 = new NodeChoice(n13, 6); } | n16=">>=" { n15 = JTBToolkit.makeNodeToken(n16); } { n0 = new NodeChoice(n15, 7); } | n18=">>>=" { n17 = JTBToolkit.makeNodeToken(n18); } { n0 = new NodeChoice(n17, 8); } | n20="&=" { n19 = JTBToolkit.makeNodeToken(n20); } { n0 = new NodeChoice(n19, 9); } | n22="^=" { n21 = JTBToolkit.makeNodeToken(n22); } { n0 = new NodeChoice(n21, 10); } | n24="|=" { n23 = JTBToolkit.makeNodeToken(n24); } { n0 = new NodeChoice(n23, 11); } ) { return new AssignmentOperator(n0); } } ConditionalExpression ConditionalExpression() : { ConditionalOrExpression n0; NodeOptional n1 = new NodeOptional(); NodeSequence n2; NodeToken n3; Token n4; Expression n5; NodeToken n6; Token n7; ConditionalExpression n8; { } } { n0=ConditionalOrExpression() ( { n2 = new NodeSequence(4); } n4="?" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Expression() { n2.addNode(n5); } n7=":" { n6 = JTBToolkit.makeNodeToken(n7); } { n2.addNode(n6); } n8=ConditionalExpression() { n2.addNode(n8); } { n1.addNode(n2); } )? { return new ConditionalExpression(n0,n1); } } ConditionalOrExpression ConditionalOrExpression() : { ConditionalAndExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; ConditionalAndExpression n5; { } } { n0=ConditionalAndExpression() ( { n2 = new NodeSequence(2); } n4="||" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=ConditionalAndExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ConditionalOrExpression(n0,n1); } } ConditionalAndExpression ConditionalAndExpression() : { InclusiveOrExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; InclusiveOrExpression n5; { } } { n0=InclusiveOrExpression() ( { n2 = new NodeSequence(2); } n4="&&" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=InclusiveOrExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ConditionalAndExpression(n0,n1); } } InclusiveOrExpression InclusiveOrExpression() : { ExclusiveOrExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; ExclusiveOrExpression n5; { } } { n0=ExclusiveOrExpression() ( { n2 = new NodeSequence(2); } n4="|" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=ExclusiveOrExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new InclusiveOrExpression(n0,n1); } } ExclusiveOrExpression ExclusiveOrExpression() : { AndExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; AndExpression n5; { } } { n0=AndExpression() ( { n2 = new NodeSequence(2); } n4="^" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=AndExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ExclusiveOrExpression(n0,n1); } } AndExpression AndExpression() : { EqualityExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; EqualityExpression n5; { } } { n0=EqualityExpression() ( { n2 = new NodeSequence(2); } n4="&" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=EqualityExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new AndExpression(n0,n1); } } EqualityExpression EqualityExpression() : { InstanceOfExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeChoice n3; NodeToken n4; Token n5; NodeToken n6; Token n7; InstanceOfExpression n8; { } } { n0=InstanceOfExpression() ( { n2 = new NodeSequence(2); } ( ( n5="==" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0); } | n7="!=" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1); } ) ) { n2.addNode(n3); } n8=InstanceOfExpression() { n2.addNode(n8); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new EqualityExpression(n0,n1); } } InstanceOfExpression InstanceOfExpression() : { RelationalExpression n0; NodeOptional n1 = new NodeOptional(); NodeSequence n2; NodeToken n3; Token n4; Type n5; { } } { n0=RelationalExpression() ( { n2 = new NodeSequence(2); } n4="instanceof" { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Type() { n2.addNode(n5); } { n1.addNode(n2); } )? { return new InstanceOfExpression(n0,n1); } } RelationalExpression RelationalExpression() : { ShiftExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeChoice n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; ShiftExpression n12; { } } { n0=ShiftExpression() ( { n2 = new NodeSequence(2); } ( ( n5="<" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0); } | n7=">" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1); } | n9="<=" { n8 = JTBToolkit.makeNodeToken(n9); } { n3 = new NodeChoice(n8, 2); } | n11=">=" { n10 = JTBToolkit.makeNodeToken(n11); } { n3 = new NodeChoice(n10, 3); } ) ) { n2.addNode(n3); } n12=ShiftExpression() { n2.addNode(n12); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new RelationalExpression(n0,n1); } } ShiftExpression ShiftExpression() : { AdditiveExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeChoice n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; AdditiveExpression n10; { } } { n0=AdditiveExpression() ( { n2 = new NodeSequence(2); } ( ( n5="<<" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0); } | n7=">>" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1); } | n9=">>>" { n8 = JTBToolkit.makeNodeToken(n9); } { n3 = new NodeChoice(n8, 2); } ) ) { n2.addNode(n3); } n10=AdditiveExpression() { n2.addNode(n10); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ShiftExpression(n0,n1); } } AdditiveExpression AdditiveExpression() : { MultiplicativeExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeChoice n3; NodeToken n4; Token n5; NodeToken n6; Token n7; MultiplicativeExpression n8; { } } { n0=MultiplicativeExpression() ( { n2 = new NodeSequence(2); } ( ( n5="+" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0); } | n7="-" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1); } ) ) { n2.addNode(n3); } n8=MultiplicativeExpression() { n2.addNode(n8); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new AdditiveExpression(n0,n1); } } MultiplicativeExpression MultiplicativeExpression() : { UnaryExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeChoice n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; UnaryExpression n10; { } } { n0=UnaryExpression() ( { n2 = new NodeSequence(2); } ( ( n5="*" { n4 = JTBToolkit.makeNodeToken(n5); } { n3 = new NodeChoice(n4, 0); } | n7="/" { n6 = JTBToolkit.makeNodeToken(n7); } { n3 = new NodeChoice(n6, 1); } | n9="%" { n8 = JTBToolkit.makeNodeToken(n9); } { n3 = new NodeChoice(n8, 2); } ) ) { n2.addNode(n3); } n10=UnaryExpression() { n2.addNode(n10); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new MultiplicativeExpression(n0,n1); } } UnaryExpression UnaryExpression() : { NodeChoice n0; NodeSequence n1; NodeChoice n2; NodeToken n3; Token n4; NodeToken n5; Token n6; UnaryExpression n7; PreIncrementExpression n8; PreDecrementExpression n9; UnaryExpressionNotPlusMinus n10; { } } { ( { n1 = new NodeSequence(2); } ( ( n4="+" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0); } | n6="-" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1); } ) ) { n1.addNode(n2); } n7=UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0); } | n8=PreIncrementExpression() { n0 = new NodeChoice(n8, 1); } | n9=PreDecrementExpression() { n0 = new NodeChoice(n9, 2); } | n10=UnaryExpressionNotPlusMinus() { n0 = new NodeChoice(n10, 3); } ) { return new UnaryExpression(n0); } } PreIncrementExpression PreIncrementExpression() : { NodeToken n0; Token n1; PrimaryExpression n2; { } } { n1="++" { n0 = JTBToolkit.makeNodeToken(n1); } n2=PrimaryExpression() { return new PreIncrementExpression(n0,n2); } } PreDecrementExpression PreDecrementExpression() : { NodeToken n0; Token n1; PrimaryExpression n2; { } } { n1="--" { n0 = JTBToolkit.makeNodeToken(n1); } n2=PrimaryExpression() { return new PreDecrementExpression(n0,n2); } } UnaryExpressionNotPlusMinus UnaryExpressionNotPlusMinus() : { NodeChoice n0; NodeSequence n1; NodeChoice n2; NodeToken n3; Token n4; NodeToken n5; Token n6; UnaryExpression n7; CastExpression n8; PostfixExpression n9; { } } { ( { n1 = new NodeSequence(2); } ( ( n4="~" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0); } | n6="!" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1); } ) ) { n1.addNode(n2); } n7=UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD(CastLookahead()) n8=CastExpression() { n0 = new NodeChoice(n8, 1); } | n9=PostfixExpression() { n0 = new NodeChoice(n9, 2); } ) { return new UnaryExpressionNotPlusMinus(n0); } } CastLookahead CastLookahead() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; PrimitiveType n4; NodeSequence n5; NodeToken n6; Token n7; Name n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeSequence n13; NodeToken n14; Token n15; Name n16; NodeToken n17; Token n18; NodeChoice n19; NodeToken n20; Token n21; NodeToken n22; Token n23; NodeToken n24; Token n25; NodeToken n26; Token n27; NodeToken n28; Token n29; NodeToken n30; Token n31; NodeToken n32; Token n33; Literal n34; { } } { ( LOOKAHEAD(2) { n1 = new NodeSequence(3); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=PrimitiveType() { n1.addNode(n4); } { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD("(" Name() "[") { n5 = new NodeSequence(5); } n7="(" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n8=Name() { n5.addNode(n8); } n10="[" { n9 = JTBToolkit.makeNodeToken(n10); } { n5.addNode(n9); } n12="]" { n11 = JTBToolkit.makeNodeToken(n12); } { n5.addNode(n11); } { n0 = new NodeChoice(n5, 1); } | { n13 = new NodeSequence(4); } n15="(" { n14 = JTBToolkit.makeNodeToken(n15); } { n13.addNode(n14); } n16=Name() { n13.addNode(n16); } n18=")" { n17 = JTBToolkit.makeNodeToken(n18); } { n13.addNode(n17); } ( ( n21="~" { n20 = JTBToolkit.makeNodeToken(n21); } { n19 = new NodeChoice(n20, 0); } | n23="!" { n22 = JTBToolkit.makeNodeToken(n23); } { n19 = new NodeChoice(n22, 1); } | n25="(" { n24 = JTBToolkit.makeNodeToken(n25); } { n19 = new NodeChoice(n24, 2); } | n27= { n26 = JTBToolkit.makeNodeToken(n27); } { n19 = new NodeChoice(n26, 3); } | n29="this" { n28 = JTBToolkit.makeNodeToken(n29); } { n19 = new NodeChoice(n28, 4); } | n31="super" { n30 = JTBToolkit.makeNodeToken(n31); } { n19 = new NodeChoice(n30, 5); } | n33="new" { n32 = JTBToolkit.makeNodeToken(n33); } { n19 = new NodeChoice(n32, 6); } | n34=Literal() { n19 = new NodeChoice(n34, 7); } ) ) { n13.addNode(n19); } { n0 = new NodeChoice(n13, 2); } ) { return new CastLookahead(n0); } } PostfixExpression PostfixExpression() : { PrimaryExpression n0; NodeOptional n1 = new NodeOptional(); NodeChoice n2; NodeToken n3; Token n4; NodeToken n5; Token n6; { } } { n0=PrimaryExpression() ( ( n4="++" { n3 = JTBToolkit.makeNodeToken(n4); } { n2 = new NodeChoice(n3, 0); } | n6="--" { n5 = JTBToolkit.makeNodeToken(n6); } { n2 = new NodeChoice(n5, 1); } ) { n1.addNode(n2); } )? { return new PostfixExpression(n0,n1); } } CastExpression CastExpression() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; Type n4; NodeToken n5; Token n6; UnaryExpression n7; NodeSequence n8; NodeToken n9; Token n10; Type n11; NodeToken n12; Token n13; UnaryExpressionNotPlusMinus n14; { } } { ( LOOKAHEAD("(" PrimitiveType()) { n1 = new NodeSequence(5); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=Type() { n1.addNode(n4); } n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } n7=UnaryExpression() { n1.addNode(n7); } { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD("(" Name()) { n8 = new NodeSequence(5); } n10="(" { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n11=Type() { n8.addNode(n11); } n13=")" { n12 = JTBToolkit.makeNodeToken(n13); } { n8.addNode(n12); } n14=UnaryExpressionNotPlusMinus() { n8.addNode(n14); } { n0 = new NodeChoice(n8, 1); } ) { return new CastExpression(n0); } } PrimaryExpression PrimaryExpression() : { PrimaryPrefix n0; NodeListOptional n1 = new NodeListOptional(); PrimarySuffix n2; { } } { n0=PrimaryPrefix() ( LOOKAHEAD(2) n2=PrimarySuffix() { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new PrimaryExpression(n0,n1); } } PrimaryPrefix PrimaryPrefix() : { NodeChoice n0; Literal n1; Name n2; NodeToken n3; Token n4; NodeSequence n5; NodeToken n6; Token n7; NodeToken n8; Token n9; NodeToken n10; Token n11; NodeSequence n12; NodeToken n13; Token n14; Expression n15; NodeToken n16; Token n17; AllocationExpression n18; { } } { ( n1=Literal() { n0 = new NodeChoice(n1, 0); } | n2=Name() { n0 = new NodeChoice(n2, 1); } | n4="this" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 2); } | { n5 = new NodeSequence(3); } n7="super" { n6 = JTBToolkit.makeNodeToken(n7); } { n5.addNode(n6); } n9="." { n8 = JTBToolkit.makeNodeToken(n9); } { n5.addNode(n8); } n11= { n10 = JTBToolkit.makeNodeToken(n11); } { n5.addNode(n10); } { n0 = new NodeChoice(n5, 3); } | { n12 = new NodeSequence(3); } n14="(" { n13 = JTBToolkit.makeNodeToken(n14); } { n12.addNode(n13); } n15=Expression() { n12.addNode(n15); } n17=")" { n16 = JTBToolkit.makeNodeToken(n17); } { n12.addNode(n16); } { n0 = new NodeChoice(n12, 4); } | n18=AllocationExpression() { n0 = new NodeChoice(n18, 5); } ) { return new PrimaryPrefix(n0); } } PrimarySuffix PrimarySuffix() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeSequence n6; NodeToken n7; Token n8; NodeToken n9; Token n10; NodeSequence n11; NodeToken n12; Token n13; AllocationExpression n14; NodeSequence n15; NodeToken n16; Token n17; Expression n18; NodeToken n19; Token n20; NodeSequence n21; NodeToken n22; Token n23; NodeToken n24; Token n25; Arguments n26; { } } { ( LOOKAHEAD(2) { n1 = new NodeSequence(3); } n3="." { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n5="this" { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD(2) { n6 = new NodeSequence(3); } n8="." { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n10="class" { n9 = JTBToolkit.makeNodeToken(n10); } { n6.addNode(n9); } { n0 = new NodeChoice(n6, 1); } | LOOKAHEAD(2) { n11 = new NodeSequence(3); } n13="." { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } n14=AllocationExpression() { n11.addNode(n14); } { n0 = new NodeChoice(n11, 2); } | { n15 = new NodeSequence(3); } n17="[" { n16 = JTBToolkit.makeNodeToken(n17); } { n15.addNode(n16); } n18=Expression() { n15.addNode(n18); } n20="]" { n19 = JTBToolkit.makeNodeToken(n20); } { n15.addNode(n19); } { n0 = new NodeChoice(n15, 3); } | { n21 = new NodeSequence(2); } n23="." { n22 = JTBToolkit.makeNodeToken(n23); } { n21.addNode(n22); } n25= { n24 = JTBToolkit.makeNodeToken(n25); } { n21.addNode(n24); } { n0 = new NodeChoice(n21, 4); } | n26=Arguments() { n0 = new NodeChoice(n26, 5); } ) { return new PrimarySuffix(n0); } } Literal Literal() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; BooleanLiteral n9; NullLiteral n10; { } } { ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } | n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2); } | n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3); } | n9=BooleanLiteral() { n0 = new NodeChoice(n9, 4); } | n10=NullLiteral() { n0 = new NodeChoice(n10, 5); } ) { return new Literal(n0); } } BooleanLiteral BooleanLiteral() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; { } } { ( n2="true" { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4="false" { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } ) { return new BooleanLiteral(n0); } } NullLiteral NullLiteral() : { NodeToken n0; Token n1; { } } { n1="null" { n0 = JTBToolkit.makeNodeToken(n1); } { return new NullLiteral(n0); } } Arguments Arguments() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); ArgumentList n3; NodeToken n4; Token n5; { } } { n1="(" { n0 = JTBToolkit.makeNodeToken(n1); } ( n3=ArgumentList() { n2.addNode(n3); } )? n5=")" { n4 = JTBToolkit.makeNodeToken(n5); } { return new Arguments(n0,n2,n4); } } ArgumentList ArgumentList() : { Expression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; Expression n5; { } } { n0=Expression() ( { n2 = new NodeSequence(2); } n4="," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Expression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ArgumentList(n0,n1); } } AllocationExpression AllocationExpression() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; PrimitiveType n4; ArrayDimensions n5; NodeOptional n6 = new NodeOptional(); ArrayInitializer n7; NodeSequence n8; NodeToken n9; Token n10; Name n11; NodeChoice n12; NodeSequence n13; ArrayDimensions n14; NodeOptional n15 = new NodeOptional(); ArrayInitializer n16; NodeSequence n17; Arguments n18; NodeOptional n19 = new NodeOptional(); ClassBody n20; { } } { ( LOOKAHEAD(2) { n1 = new NodeSequence(5); } n3="new" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=PrimitiveType() { n1.addNode(n4); } n5=ArrayDimensions() { n1.addNode(n5); } ( n7=ArrayInitializer() { n6.addNode(n7); } )? { n1.addNode(n6); } { n0 = new NodeChoice(n1, 0); } | { n8 = new NodeSequence(3); } n10="new" { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n11=Name() { n8.addNode(n11); } ( ( { n13 = new NodeSequence(2); } n14=ArrayDimensions() { n13.addNode(n14); } ( n16=ArrayInitializer() { n15.addNode(n16); } )? { n13.addNode(n15); } { n12 = new NodeChoice(n13, 0); } | { n17 = new NodeSequence(2); } n18=Arguments() { n17.addNode(n18); } ( n20=ClassBody() { n19.addNode(n20); } )? { n17.addNode(n19); } { n12 = new NodeChoice(n17, 1); } ) ) { n8.addNode(n12); } { n0 = new NodeChoice(n8, 1); } ) { return new AllocationExpression(n0); } } ArrayDimensions ArrayDimensions() : { NodeList n0 = new NodeList(); NodeSequence n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; NodeListOptional n7 = new NodeListOptional(); NodeSequence n8; NodeToken n9; Token n10; NodeToken n11; Token n12; { } } { ( LOOKAHEAD(2) { n1 = new NodeSequence(3); } n3="[" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=Expression() { n1.addNode(n4); } n6="]" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } { n0.addNode(n1); } )+ { n0.nodes.trimToSize(); } ( LOOKAHEAD(2) { n8 = new NodeSequence(2); } n10="[" { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n12="]" { n11 = JTBToolkit.makeNodeToken(n12); } { n8.addNode(n11); } { n7.addNode(n8); } )* { n7.nodes.trimToSize(); } { return new ArrayDimensions(n0,n7); } } Statement Statement() : { NodeChoice n0; LabeledStatement n1; Block n2; EmptyStatement n3; NodeSequence n4; StatementExpression n5; NodeToken n6; Token n7; SwitchStatement n8; IfStatement n9; WhileStatement n10; DoStatement n11; ForStatement n12; BreakStatement n13; ContinueStatement n14; ReturnStatement n15; ThrowStatement n16; SynchronizedStatement n17; TryStatement n18; { } } { ( LOOKAHEAD(2) n1=LabeledStatement() { n0 = new NodeChoice(n1, 0); } | n2=Block() { n0 = new NodeChoice(n2, 1); } | n3=EmptyStatement() { n0 = new NodeChoice(n3, 2); } | { n4 = new NodeSequence(2); } n5=StatementExpression() { n4.addNode(n5); } n7=";" { n6 = JTBToolkit.makeNodeToken(n7); } { n4.addNode(n6); } { n0 = new NodeChoice(n4, 3); } | n8=SwitchStatement() { n0 = new NodeChoice(n8, 4); } | n9=IfStatement() { n0 = new NodeChoice(n9, 5); } | n10=WhileStatement() { n0 = new NodeChoice(n10, 6); } | n11=DoStatement() { n0 = new NodeChoice(n11, 7); } | n12=ForStatement() { n0 = new NodeChoice(n12, 8); } | n13=BreakStatement() { n0 = new NodeChoice(n13, 9); } | n14=ContinueStatement() { n0 = new NodeChoice(n14, 10); } | n15=ReturnStatement() { n0 = new NodeChoice(n15, 11); } | n16=ThrowStatement() { n0 = new NodeChoice(n16, 12); } | n17=SynchronizedStatement() { n0 = new NodeChoice(n17, 13); } | n18=TryStatement() { n0 = new NodeChoice(n18, 14); } ) { return new Statement(n0); } } LabeledStatement LabeledStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; Statement n4; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } n3=":" { n2 = JTBToolkit.makeNodeToken(n3); } n4=Statement() { return new LabeledStatement(n0,n2,n4); } } Block Block() : { NodeToken n0; Token n1; NodeListOptional n2 = new NodeListOptional(); BlockStatement n3; NodeToken n4; Token n5; { } } { n1="{" { n0 = JTBToolkit.makeNodeToken(n1); } ( n3=BlockStatement() { n2.addNode(n3); } )* { n2.nodes.trimToSize(); } n5="}" { n4 = JTBToolkit.makeNodeToken(n5); } { return new Block(n0,n2,n4); } } BlockStatement BlockStatement() : { NodeChoice n0; NodeSequence n1; LocalVariableDeclaration n2; NodeToken n3; Token n4; Statement n5; UnmodifiedClassDeclaration n6; { } } { ( LOOKAHEAD([ "final" ] Type() ) { n1 = new NodeSequence(3); } n2=LocalVariableDeclaration() { n1.addNode(n2); } n4=";" { n3 = JTBToolkit.makeNodeToken(n4); } { n1.addNode(n3); } { n0 = new NodeChoice(n1, 0); } | n5=Statement() { n0 = new NodeChoice(n5, 1); } | n6=UnmodifiedClassDeclaration() { n0 = new NodeChoice(n6, 2); } ) { return new BlockStatement(n0); } } LocalVariableDeclaration LocalVariableDeclaration() : { NodeOptional n0 = new NodeOptional(); NodeToken n1; Token n2; Type n3; VariableDeclarator n4; NodeListOptional n5 = new NodeListOptional(); NodeSequence n6; NodeToken n7; Token n8; VariableDeclarator n9; { } } { ( n2="final" { n1 = JTBToolkit.makeNodeToken(n2); } { n0.addNode(n1); } )? n3=Type() n4=VariableDeclarator() ( { n6 = new NodeSequence(2); } n8="," { n7 = JTBToolkit.makeNodeToken(n8); } { n6.addNode(n7); } n9=VariableDeclarator() { n6.addNode(n9); } { n5.addNode(n6); } )* { n5.nodes.trimToSize(); } { return new LocalVariableDeclaration(n0,n3,n4,n5); } } EmptyStatement EmptyStatement() : { NodeToken n0; Token n1; { } } { n1=";" { n0 = JTBToolkit.makeNodeToken(n1); } { return new EmptyStatement(n0); } } StatementExpression StatementExpression() : { NodeChoice n0; PreIncrementExpression n1; PreDecrementExpression n2; Assignment n3; PostfixExpression n4; { } } { ( n1=PreIncrementExpression() { n0 = new NodeChoice(n1, 0); } | n2=PreDecrementExpression() { n0 = new NodeChoice(n2, 1); } | LOOKAHEAD(PrimaryExpression() AssignmentOperator()) n3=Assignment() { n0 = new NodeChoice(n3, 2); } | n4=PostfixExpression() { n0 = new NodeChoice(n4, 3); } ) { return new StatementExpression(n0); } } SwitchStatement SwitchStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeListOptional n9 = new NodeListOptional(); NodeSequence n10; SwitchLabel n11; NodeListOptional n12; BlockStatement n13; NodeToken n14; Token n15; { } } { n1="switch" { n0 = JTBToolkit.makeNodeToken(n1); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } n4=Expression() n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } n8="{" { n7 = JTBToolkit.makeNodeToken(n8); } ( { n12 = new NodeListOptional(); } { n10 = new NodeSequence(2); } n11=SwitchLabel() { n10.addNode(n11); } ( n13=BlockStatement() { n12.addNode(n13); } )* { n12.nodes.trimToSize(); } { n10.addNode(n12); } { n9.addNode(n10); } )* { n9.nodes.trimToSize(); } n15="}" { n14 = JTBToolkit.makeNodeToken(n15); } { return new SwitchStatement(n0,n2,n4,n5,n7,n9,n14); } } SwitchLabel SwitchLabel() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; NodeSequence n7; NodeToken n8; Token n9; NodeToken n10; Token n11; { } } { ( { n1 = new NodeSequence(3); } n3="case" { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n4=Expression() { n1.addNode(n4); } n6=":" { n5 = JTBToolkit.makeNodeToken(n6); } { n1.addNode(n5); } { n0 = new NodeChoice(n1, 0); } | { n7 = new NodeSequence(2); } n9="default" { n8 = JTBToolkit.makeNodeToken(n9); } { n7.addNode(n8); } n11=":" { n10 = JTBToolkit.makeNodeToken(n11); } { n7.addNode(n10); } { n0 = new NodeChoice(n7, 1); } ) { return new SwitchLabel(n0); } } IfStatement IfStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; Statement n7; NodeOptional n8 = new NodeOptional(); NodeSequence n9; NodeToken n10; Token n11; Statement n12; { } } { n1="if" { n0 = JTBToolkit.makeNodeToken(n1); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } n4=Expression() n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } n7=Statement() ( LOOKAHEAD(1) { n9 = new NodeSequence(2); } n11="else" { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } n12=Statement() { n9.addNode(n12); } { n8.addNode(n9); } )? { return new IfStatement(n0,n2,n4,n5,n7,n8); } } WhileStatement WhileStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; Statement n7; { } } { n1="while" { n0 = JTBToolkit.makeNodeToken(n1); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } n4=Expression() n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } n7=Statement() { return new WhileStatement(n0,n2,n4,n5,n7); } } DoStatement DoStatement() : { NodeToken n0; Token n1; Statement n2; NodeToken n3; Token n4; NodeToken n5; Token n6; Expression n7; NodeToken n8; Token n9; NodeToken n10; Token n11; { } } { n1="do" { n0 = JTBToolkit.makeNodeToken(n1); } n2=Statement() n4="while" { n3 = JTBToolkit.makeNodeToken(n4); } n6="(" { n5 = JTBToolkit.makeNodeToken(n6); } n7=Expression() n9=")" { n8 = JTBToolkit.makeNodeToken(n9); } n11=";" { n10 = JTBToolkit.makeNodeToken(n11); } { return new DoStatement(n0,n2,n3,n5,n7,n8,n10); } } ForStatement ForStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; NodeOptional n4 = new NodeOptional(); ForInit n5; NodeToken n6; Token n7; NodeOptional n8 = new NodeOptional(); Expression n9; NodeToken n10; Token n11; NodeOptional n12 = new NodeOptional(); ForUpdate n13; NodeToken n14; Token n15; Statement n16; { } } { n1="for" { n0 = JTBToolkit.makeNodeToken(n1); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } ( n5=ForInit() { n4.addNode(n5); } )? n7=";" { n6 = JTBToolkit.makeNodeToken(n7); } ( n9=Expression() { n8.addNode(n9); } )? n11=";" { n10 = JTBToolkit.makeNodeToken(n11); } ( n13=ForUpdate() { n12.addNode(n13); } )? n15=")" { n14 = JTBToolkit.makeNodeToken(n15); } n16=Statement() { return new ForStatement(n0,n2,n4,n6,n8,n10,n12,n14,n16); } } ForInit ForInit() : { NodeChoice n0; LocalVariableDeclaration n1; StatementExpressionList n2; { } } { ( LOOKAHEAD([ "final" ] Type() ) n1=LocalVariableDeclaration() { n0 = new NodeChoice(n1, 0); } | n2=StatementExpressionList() { n0 = new NodeChoice(n2, 1); } ) { return new ForInit(n0); } } StatementExpressionList StatementExpressionList() : { StatementExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; StatementExpression n5; { } } { n0=StatementExpression() ( { n2 = new NodeSequence(2); } n4="," { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=StatementExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new StatementExpressionList(n0,n1); } } ForUpdate ForUpdate() : { StatementExpressionList n0; { } } { n0=StatementExpressionList() { return new ForUpdate(n0); } } BreakStatement BreakStatement() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); NodeToken n3; Token n4; NodeToken n5; Token n6; { } } { n1="break" { n0 = JTBToolkit.makeNodeToken(n1); } ( n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } )? n6=";" { n5 = JTBToolkit.makeNodeToken(n6); } { return new BreakStatement(n0,n2,n5); } } ContinueStatement ContinueStatement() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); NodeToken n3; Token n4; NodeToken n5; Token n6; { } } { n1="continue" { n0 = JTBToolkit.makeNodeToken(n1); } ( n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } )? n6=";" { n5 = JTBToolkit.makeNodeToken(n6); } { return new ContinueStatement(n0,n2,n5); } } ReturnStatement ReturnStatement() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); Expression n3; NodeToken n4; Token n5; { } } { n1="return" { n0 = JTBToolkit.makeNodeToken(n1); } ( n3=Expression() { n2.addNode(n3); } )? n5=";" { n4 = JTBToolkit.makeNodeToken(n5); } { return new ReturnStatement(n0,n2,n4); } } ThrowStatement ThrowStatement() : { NodeToken n0; Token n1; Expression n2; NodeToken n3; Token n4; { } } { n1="throw" { n0 = JTBToolkit.makeNodeToken(n1); } n2=Expression() n4=";" { n3 = JTBToolkit.makeNodeToken(n4); } { return new ThrowStatement(n0,n2,n3); } } SynchronizedStatement SynchronizedStatement() : { NodeToken n0; Token n1; NodeToken n2; Token n3; Expression n4; NodeToken n5; Token n6; Block n7; { } } { n1="synchronized" { n0 = JTBToolkit.makeNodeToken(n1); } n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } n4=Expression() n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } n7=Block() { return new SynchronizedStatement(n0,n2,n4,n5,n7); } } TryStatement TryStatement() : { NodeToken n0; Token n1; Block n2; NodeListOptional n3 = new NodeListOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; FormalParameter n9; NodeToken n10; Token n11; Block n12; NodeOptional n13 = new NodeOptional(); NodeSequence n14; NodeToken n15; Token n16; Block n17; { } } { n1="try" { n0 = JTBToolkit.makeNodeToken(n1); } n2=Block() ( { n4 = new NodeSequence(5); } n6="catch" { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8="(" { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } n9=FormalParameter() { n4.addNode(n9); } n11=")" { n10 = JTBToolkit.makeNodeToken(n11); } { n4.addNode(n10); } n12=Block() { n4.addNode(n12); } { n3.addNode(n4); } )* { n3.nodes.trimToSize(); } ( { n14 = new NodeSequence(2); } n16="finally" { n15 = JTBToolkit.makeNodeToken(n16); } { n14.addNode(n15); } n17=Block() { n14.addNode(n17); } { n13.addNode(n14); } )? { return new TryStatement(n0,n2,n3,n13); } } TOKEN : { | | | | | | | | | | | } TOKEN : { ( | )*> } TOKEN : { } JavaCCInput JavaCCInput() : { JavaCCOptions n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; CompilationUnit n9; NodeToken n10; Token n11; NodeToken n12; Token n13; NodeToken n14; Token n15; NodeToken n16; Token n17; NodeListOptional n18 = new NodeListOptional(); Production n19; NodeToken n20; Token n21; { } } { n0=JavaCCOptions() n2= { n1 = JTBToolkit.makeNodeToken(n2); } n4= { n3 = JTBToolkit.makeNodeToken(n4); } n6= { n5 = JTBToolkit.makeNodeToken(n6); } n8= { n7 = JTBToolkit.makeNodeToken(n8); } n9=CompilationUnit() n11= { n10 = JTBToolkit.makeNodeToken(n11); } n13= { n12 = JTBToolkit.makeNodeToken(n13); } n15= { n14 = JTBToolkit.makeNodeToken(n15); } n17= { n16 = JTBToolkit.makeNodeToken(n17); } ( n19=Production() { n18.addNode(n19); } )* { n18.nodes.trimToSize(); } n21= { n21.beginColumn++; n21.endColumn++; n20 = JTBToolkit.makeNodeToken(n21); } { return new JavaCCInput(n0,n1,n3,n5,n7,n9,n10,n12,n14,n16,n18,n20); } } JavaCCOptions JavaCCOptions() : { NodeOptional n0 = new NodeOptional(); NodeSequence n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeListOptional n6; OptionBinding n7; NodeToken n8; Token n9; { } } { ( { n6 = new NodeListOptional(); } { n1 = new NodeSequence(4); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } ( n7=OptionBinding() { n6.addNode(n7); } )* { n6.nodes.trimToSize(); } { n1.addNode(n6); } n9= { n8 = JTBToolkit.makeNodeToken(n9); } { n1.addNode(n8); } { n0.addNode(n1); } )? { return new JavaCCOptions(n0); } } OptionBinding OptionBinding() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeToken n9; Token n10; NodeChoice n11; NodeToken n12; Token n13; BooleanLiteral n14; NodeToken n15; Token n16; NodeToken n17; Token n18; { } } { ( ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } | n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2); } | n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3); } ) ) n10= { n9 = JTBToolkit.makeNodeToken(n10); } ( ( n13= { n12 = JTBToolkit.makeNodeToken(n13); } { n11 = new NodeChoice(n12, 0); } | n14=BooleanLiteral() { n11 = new NodeChoice(n14, 1); } | n16= { n15 = JTBToolkit.makeNodeToken(n16); } { n11 = new NodeChoice(n15, 2); } ) ) n18= { n17 = JTBToolkit.makeNodeToken(n18); } { return new OptionBinding(n0,n9,n11,n17); } } Production Production() : { NodeChoice n0; JavaCodeProduction n1; RegularExprProduction n2; BNFProduction n3; TokenManagerDecls n4; { } } { ( n1=JavaCodeProduction() { n0 = new NodeChoice(n1, 0); } | n2=RegularExprProduction() { n0 = new NodeChoice(n2, 1); } | n3=BNFProduction() { n0 = new NodeChoice(n3, 2); } | n4=TokenManagerDecls() { n0 = new NodeChoice(n4, 3); } ) { return new Production(n0); } } JavaCodeProduction JavaCodeProduction() : { NodeToken n0; Token n1; ResultType n2; NodeToken n3; Token n4; FormalParameters n5; Block n6; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } n2=ResultType() n4= { n3 = JTBToolkit.makeNodeToken(n4); } n5=FormalParameters() n6=Block() { return new JavaCodeProduction(n0,n2,n3,n5,n6); } } BNFProduction BNFProduction() : { ResultType n0; NodeToken n1; Token n2; FormalParameters n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeListOptional n8 = new NodeListOptional(); BlockStatement n9; NodeToken n10; Token n11; NodeToken n12; Token n13; ExpansionChoices n14; NodeToken n15; Token n16; { } } { n0=ResultType() n2= { n1 = JTBToolkit.makeNodeToken(n2); } n3=FormalParameters() n5= { n4 = JTBToolkit.makeNodeToken(n5); } n7="{" { n6 = JTBToolkit.makeNodeToken(n7); } ( n9=BlockStatement() { n8.addNode(n9); } )* { n8.nodes.trimToSize(); } n11="}" { n10 = JTBToolkit.makeNodeToken(n11); } n13= { n12 = JTBToolkit.makeNodeToken(n13); } n14=ExpansionChoices() n16= { n15 = JTBToolkit.makeNodeToken(n16); } { return new BNFProduction(n0,n1,n3,n4,n6,n8,n10,n12,n14,n15); } } RegularExprProduction RegularExprProduction() : { NodeOptional n0 = new NodeOptional(); LexicalStateList n1; RegExprKind n2; NodeOptional n3 = new NodeOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeToken n13; Token n14; RegExprSpec n15; NodeListOptional n16 = new NodeListOptional(); NodeSequence n17; NodeToken n18; Token n19; RegExprSpec n20; NodeToken n21; Token n22; { } } { ( n1=LexicalStateList() { n0.addNode(n1); } )? n2=RegExprKind() ( { n4 = new NodeSequence(3); } n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } n10= { n9 = JTBToolkit.makeNodeToken(n10); } { n4.addNode(n9); } { n3.addNode(n4); } )? n12= { n11 = JTBToolkit.makeNodeToken(n12); } n14= { n13 = JTBToolkit.makeNodeToken(n14); } n15=RegExprSpec() ( { n17 = new NodeSequence(2); } n19= { n18 = JTBToolkit.makeNodeToken(n19); } { n17.addNode(n18); } n20=RegExprSpec() { n17.addNode(n20); } { n16.addNode(n17); } )* { n16.nodes.trimToSize(); } n22= { n21 = JTBToolkit.makeNodeToken(n22); } { return new RegularExprProduction(n0,n2,n3,n11,n13,n15,n16,n21); } } TokenManagerDecls TokenManagerDecls() : { NodeToken n0; Token n1; NodeToken n2; Token n3; ClassBody n4; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } n4=ClassBody() { return new TokenManagerDecls(n0,n2,n4); } } LexicalStateList LexicalStateList() : { NodeChoice n0; NodeSequence n1; NodeToken n2; Token n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeSequence n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeListOptional n13 = new NodeListOptional(); NodeSequence n14; NodeToken n15; Token n16; NodeToken n17; Token n18; NodeToken n19; Token n20; { } } { ( LOOKAHEAD(2) { n1 = new NodeSequence(4); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } { n1.addNode(n2); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n1.addNode(n4); } n7= { n6 = JTBToolkit.makeNodeToken(n7); } { n1.addNode(n6); } { n0 = new NodeChoice(n1, 0); } | { n8 = new NodeSequence(4); } n10= { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } n12= { n11 = JTBToolkit.makeNodeToken(n12); } { n8.addNode(n11); } ( { n14 = new NodeSequence(2); } n16= { n15 = JTBToolkit.makeNodeToken(n16); } { n14.addNode(n15); } n18= { n17 = JTBToolkit.makeNodeToken(n18); } { n14.addNode(n17); } { n13.addNode(n14); } )* { n13.nodes.trimToSize(); } { n8.addNode(n13); } n20= { n19 = JTBToolkit.makeNodeToken(n20); } { n8.addNode(n19); } { n0 = new NodeChoice(n8, 1); } ) { return new LexicalStateList(n0); } } RegExprKind RegExprKind() : { NodeChoice n0; NodeToken n1; Token n2; NodeToken n3; Token n4; NodeToken n5; Token n6; NodeToken n7; Token n8; { } } { ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n0 = new NodeChoice(n3, 1); } | n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n0 = new NodeChoice(n5, 2); } | n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n0 = new NodeChoice(n7, 3); } ) { return new RegExprKind(n0); } } RegExprSpec RegExprSpec() : { RegularExpression n0; NodeOptional n1 = new NodeOptional(); Block n2; NodeOptional n3 = new NodeOptional(); NodeSequence n4; NodeToken n5; Token n6; NodeToken n7; Token n8; { } } { n0=RegularExpression() ( n2=Block() { n1.addNode(n2); } )? ( { n4 = new NodeSequence(2); } n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n4.addNode(n7); } { n3.addNode(n4); } )? { return new RegExprSpec(n0,n1,n3); } } ExpansionChoices ExpansionChoices() : { Expansion n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; Expansion n5; { } } { n0=Expansion() ( { n2 = new NodeSequence(2); } n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Expansion() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ExpansionChoices(n0,n1); } } Expansion Expansion() : { NodeListOptional n0 = new NodeListOptional(); ExpansionUnit n1; { } } { ( LOOKAHEAD(ExpansionUnit()) n1=ExpansionUnit() { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } { return new Expansion(n0); } } ExpansionUnit ExpansionUnit() : { NodeChoice n0; LocalLookahead n1; Block n2; NodeSequence n3; NodeToken n4; Token n5; ExpansionChoices n6; NodeToken n7; Token n8; NodeOptional n9 = new NodeOptional(); NodeChoice n10; NodeToken n11; Token n12; NodeToken n13; Token n14; NodeToken n15; Token n16; NodeSequence n17; NodeToken n18; Token n19; ExpansionChoices n20; NodeToken n21; Token n22; NodeSequence n23; NodeOptional n24 = new NodeOptional(); NodeSequence n25; PrimaryExpression n26; NodeToken n27; Token n28; ExpansionUnitTerm n29; { } } { ( n1=LocalLookahead() { n0 = new NodeChoice(n1, 0); } | n2=Block() { n0 = new NodeChoice(n2, 1); } | LOOKAHEAD(3) { n3 = new NodeSequence(5); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n6=ExpansionChoices() { n3.addNode(n6); } n8= { n7 = JTBToolkit.makeNodeToken(n8); } { n3.addNode(n7); } ( ( n12= { n11 = JTBToolkit.makeNodeToken(n12); } { n10 = new NodeChoice(n11, 0); } | n14= { n13 = JTBToolkit.makeNodeToken(n14); } { n10 = new NodeChoice(n13, 1); } | n16= { n15 = JTBToolkit.makeNodeToken(n16); } { n10 = new NodeChoice(n15, 2); } ) { n9.addNode(n10); } )? { n3.addNode(n9); } { n0 = new NodeChoice(n3, 2); } | { n17 = new NodeSequence(3); } n19= { n18 = JTBToolkit.makeNodeToken(n19); } { n17.addNode(n18); } n20=ExpansionChoices() { n17.addNode(n20); } n22= { n21 = JTBToolkit.makeNodeToken(n22); } { n17.addNode(n21); } { n0 = new NodeChoice(n17, 3); } | { n23 = new NodeSequence(2); } ( LOOKAHEAD(2000000000) { n25 = new NodeSequence(2); } n26=PrimaryExpression() { n25.addNode(n26); } n28= { n27 = JTBToolkit.makeNodeToken(n28); } { n25.addNode(n27); } { n24.addNode(n25); } )? { n23.addNode(n24); } n29=ExpansionUnitTerm() { n23.addNode(n29); } { n0 = new NodeChoice(n23, 4); } ) { return new ExpansionUnit(n0); } } ExpansionUnitTerm ExpansionUnitTerm() : { NodeChoice n0; RegularExpression n1; NodeSequence n2; NodeToken n3; Token n4; Arguments n5; { } } { ( n1=RegularExpression() { n0 = new NodeChoice(n1, 0); } | { n2 = new NodeSequence(2); } n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=Arguments() { n2.addNode(n5); } { n0 = new NodeChoice(n2, 1); } ) { return new ExpansionUnitTerm(n0); } } LocalLookahead LocalLookahead() : { NodeToken n0; Token n1; NodeToken n2; Token n3; NodeOptional n4 = new NodeOptional(); NodeToken n5; Token n6; NodeOptional n7 = new NodeOptional(); NodeToken n8; Token n9; ExpansionChoices n10; NodeOptional n11 = new NodeOptional(); NodeToken n12; Token n13; NodeOptional n14 = new NodeOptional(); NodeSequence n15; NodeToken n16; Token n17; Expression n18; NodeToken n19; Token n20; NodeToken n21; Token n22; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } n3= { n2 = JTBToolkit.makeNodeToken(n3); } ( LOOKAHEAD(2) n6= { n5 = JTBToolkit.makeNodeToken(n6); } { n4.addNode(n5); } )? ( LOOKAHEAD(2) n9= { n8 = JTBToolkit.makeNodeToken(n9); } { n7.addNode(n8); } )? n10=ExpansionChoices() ( n13= { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } )? ( { n15 = new NodeSequence(3); } n17= { n16 = JTBToolkit.makeNodeToken(n17); } { n15.addNode(n16); } n18=Expression() { n15.addNode(n18); } n20= { n19 = JTBToolkit.makeNodeToken(n20); } { n15.addNode(n19); } { n14.addNode(n15); } )? n22= { n21 = JTBToolkit.makeNodeToken(n22); } { return new LocalLookahead(n0,n2,n4,n7,n10,n11,n14,n21); } } RegularExpression RegularExpression() : { NodeChoice n0; NodeToken n1; Token n2; NodeSequence n3; NodeToken n4; Token n5; NodeOptional n6 = new NodeOptional(); NodeSequence n7; NodeOptional n8; NodeToken n9; Token n10; NodeToken n11; Token n12; NodeToken n13; Token n14; ComplexRegularExpressionChoices n15; NodeToken n16; Token n17; NodeSequence n18; NodeToken n19; Token n20; NodeToken n21; Token n22; NodeToken n23; Token n24; NodeSequence n25; NodeToken n26; Token n27; NodeToken n28; Token n29; NodeToken n30; Token n31; { } } { ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | LOOKAHEAD(3) { n3 = new NodeSequence(5); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } ( { n8 = new NodeOptional(); } { n7 = new NodeSequence(3); } ( n10= { n9 = JTBToolkit.makeNodeToken(n10); } { n8.addNode(n9); } )? { n7.addNode(n8); } n12= { n11 = JTBToolkit.makeNodeToken(n12); } { n7.addNode(n11); } n14= { n13 = JTBToolkit.makeNodeToken(n14); } { n7.addNode(n13); } { n6.addNode(n7); } )? { n3.addNode(n6); } n15=ComplexRegularExpressionChoices() { n3.addNode(n15); } n17= { n16 = JTBToolkit.makeNodeToken(n17); } { n3.addNode(n16); } { n0 = new NodeChoice(n3, 1); } | LOOKAHEAD(2) { n18 = new NodeSequence(4); } n20= { n19 = JTBToolkit.makeNodeToken(n20); } { n18.addNode(n19); } n22= { n21 = JTBToolkit.makeNodeToken(n22); } { n18.addNode(n21); } n24= { n23 = JTBToolkit.makeNodeToken(n24); } { n18.addNode(n23); } { n0 = new NodeChoice(n18, 2); } | { n25 = new NodeSequence(3); } n27= { n26 = JTBToolkit.makeNodeToken(n27); } { n25.addNode(n26); } n29= { n28 = JTBToolkit.makeNodeToken(n29); } { n25.addNode(n28); } n31= { n30 = JTBToolkit.makeNodeToken(n31); } { n25.addNode(n30); } { n0 = new NodeChoice(n25, 3); } ) { return new RegularExpression(n0); } } ComplexRegularExpressionChoices ComplexRegularExpressionChoices() : { ComplexRegularExpression n0; NodeListOptional n1 = new NodeListOptional(); NodeSequence n2; NodeToken n3; Token n4; ComplexRegularExpression n5; { } } { n0=ComplexRegularExpression() ( { n2 = new NodeSequence(2); } n4= { n3 = JTBToolkit.makeNodeToken(n4); } { n2.addNode(n3); } n5=ComplexRegularExpression() { n2.addNode(n5); } { n1.addNode(n2); } )* { n1.nodes.trimToSize(); } { return new ComplexRegularExpressionChoices(n0,n1); } } ComplexRegularExpression ComplexRegularExpression() : { NodeListOptional n0 = new NodeListOptional(); ComplexRegularExpressionUnit n1; { } } { ( n1=ComplexRegularExpressionUnit() { n0.addNode(n1); } )* { n0.nodes.trimToSize(); } { return new ComplexRegularExpression(n0); } } ComplexRegularExpressionUnit ComplexRegularExpressionUnit() : { NodeChoice n0; NodeToken n1; Token n2; NodeSequence n3; NodeToken n4; Token n5; NodeToken n6; Token n7; NodeToken n8; Token n9; CharacterList n10; NodeSequence n11; NodeToken n12; Token n13; ComplexRegularExpressionChoices n14; NodeToken n15; Token n16; NodeOptional n17 = new NodeOptional(); NodeChoice n18; NodeToken n19; Token n20; NodeToken n21; Token n22; NodeToken n23; Token n24; { } } { ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0 = new NodeChoice(n1, 0); } | { n3 = new NodeSequence(3); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n7= { n6 = JTBToolkit.makeNodeToken(n7); } { n3.addNode(n6); } n9= { n8 = JTBToolkit.makeNodeToken(n9); } { n3.addNode(n8); } { n0 = new NodeChoice(n3, 1); } | n10=CharacterList() { n0 = new NodeChoice(n10, 2); } | { n11 = new NodeSequence(4); } n13= { n12 = JTBToolkit.makeNodeToken(n13); } { n11.addNode(n12); } n14=ComplexRegularExpressionChoices() { n11.addNode(n14); } n16= { n15 = JTBToolkit.makeNodeToken(n16); } { n11.addNode(n15); } ( ( n20= { n19 = JTBToolkit.makeNodeToken(n20); } { n18 = new NodeChoice(n19, 0); } | n22= { n21 = JTBToolkit.makeNodeToken(n22); } { n18 = new NodeChoice(n21, 1); } | n24= { n23 = JTBToolkit.makeNodeToken(n24); } { n18 = new NodeChoice(n23, 2); } ) { n17.addNode(n18); } )? { n11.addNode(n17); } { n0 = new NodeChoice(n11, 3); } ) { return new ComplexRegularExpressionUnit(n0); } } CharacterList CharacterList() : { NodeOptional n0 = new NodeOptional(); NodeToken n1; Token n2; NodeToken n3; Token n4; NodeOptional n5 = new NodeOptional(); NodeSequence n6; CharacterDescriptor n7; NodeListOptional n8; NodeSequence n9; NodeToken n10; Token n11; CharacterDescriptor n12; NodeToken n13; Token n14; { } } { ( n2= { n1 = JTBToolkit.makeNodeToken(n2); } { n0.addNode(n1); } )? n4= { n3 = JTBToolkit.makeNodeToken(n4); } ( { n8 = new NodeListOptional(); } { n6 = new NodeSequence(2); } n7=CharacterDescriptor() { n6.addNode(n7); } ( { n9 = new NodeSequence(2); } n11= { n10 = JTBToolkit.makeNodeToken(n11); } { n9.addNode(n10); } n12=CharacterDescriptor() { n9.addNode(n12); } { n8.addNode(n9); } )* { n8.nodes.trimToSize(); } { n6.addNode(n8); } { n5.addNode(n6); } )? n14= { n13 = JTBToolkit.makeNodeToken(n14); } { return new CharacterList(n0,n3,n5,n13); } } CharacterDescriptor CharacterDescriptor() : { NodeToken n0; Token n1; NodeOptional n2 = new NodeOptional(); NodeSequence n3; NodeToken n4; Token n5; NodeToken n6; Token n7; { } } { n1= { n0 = JTBToolkit.makeNodeToken(n1); } ( { n3 = new NodeSequence(2); } n5= { n4 = JTBToolkit.makeNodeToken(n5); } { n3.addNode(n4); } n7= { n6 = JTBToolkit.makeNodeToken(n7); } { n3.addNode(n6); } { n2.addNode(n3); } )? { return new CharacterDescriptor(n0,n2); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/0000755000175000017500000000000011420623645017030 5ustar cavedoncavedonjtb-1.4.4/EDU/purdue/jtb/syntaxtree/RegularExprProduction.java0000644000175000017500000000654511416555700024215 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RegularExprProduction:
* Corresponding grammar :
* f0 -> [ %0 #0 "<" #1 "*" #2 ">"
* .. .. | %1 #0 "<" #1 < IDENTIFIER >
* .. .. . .. #2 ( $0 "," $1 < IDENTIFIER > )* #3 ">" ]
* f1 -> RegExprKind()
* f2 -> [ #0 "[" #1 "IGNORE_CASE" #2 "]" ]
* f3 -> ":"
* f4 -> "{"
* f5 -> RegExprSpec()
* f6 -> ( #0 "|" #1 RegExprSpec() )*
* f7 -> "}"
*/ public class RegularExprProduction implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public RegExprKind f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeToken f3; /** A child node */ public NodeToken f4; /** A child node */ public RegExprSpec f5; /** A child node */ public NodeListOptional f6; /** A child node */ public NodeToken f7; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node * @param n7 next child node */ public RegularExprProduction(final NodeOptional n0, final RegExprKind n1, final NodeOptional n2, final NodeToken n3, final NodeToken n4, final RegExprSpec n5, final NodeListOptional n6, final NodeToken n7) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; f7 = n7; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public RegularExprProduction(final NodeOptional n0, final RegExprKind n1, final NodeOptional n2, final RegExprSpec n3, final NodeListOptional n4) { f0 = n0; f1 = n1; f2 = n2; f3 = new NodeToken(":"); f4 = new NodeToken("{"); f5 = n3; f6 = n4; f7 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeParameter.java0000644000175000017500000000344711416555700022466 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeParameter:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> [ TypeBound() ]
*/ public class TypeParameter implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public TypeParameter(final NodeToken n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/EmptyStatement.java0000644000175000017500000000342611416555700022664 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production EmptyStatement:
* Corresponding grammar :
* f0 -> ";"
*/ public class EmptyStatement implements INode { /** A child node */ public NodeToken f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public EmptyStatement(final NodeToken n0) { f0 = n0; } /** * Constructs the node with only its non NodeToken child node. * */ public EmptyStatement() { f0 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TokenManagerDecls.java0000644000175000017500000000435011416555700023224 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TokenManagerDecls:
* Corresponding grammar :
* f0 -> "TOKEN_MGR_DECLS"
* f1 -> ":"
* f2 -> ClassOrInterfaceBody()
*/ public class TokenManagerDecls implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public ClassOrInterfaceBody f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public TokenManagerDecls(final NodeToken n0, final NodeToken n1, final ClassOrInterfaceBody n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public TokenManagerDecls(final ClassOrInterfaceBody n0) { f0 = new NodeToken("TOKEN_MGR_DECLS"); f1 = new NodeToken(":"); f2 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AssignmentOperator.java0000644000175000017500000000365111416555700023525 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AssignmentOperator:
* Corresponding grammar :
* f0 -> . %00 "="
* .. .. | %01 "*="
* .. .. | %02 "/="
* .. .. | %03 "%="
* .. .. | %04 "+="
* .. .. | %05 "-="
* .. .. | %06 "<<="
* .. .. | %07 ">>="
* .. .. | %08 ">>>="
* .. .. | %09 "&="
* .. .. | %10 "^="
* .. .. | %11 "|="
*/ public class AssignmentOperator implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public AssignmentOperator(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/INode.java0000644000175000017500000000265611416555700020703 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; /** * The interface which all syntax tree classes must implement. */ public interface INode extends java.io.Serializable { /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu); /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis); /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu); /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis); } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NameList.java0000644000175000017500000000342411416555700021413 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production NameList:
* Corresponding grammar :
* f0 -> Name()
* f1 -> ( #0 "," #1 Name() )*
*/ public class NameList implements INode { /** A child node */ public Name f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public NameList(final Name n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/OptionBinding.java0000644000175000017500000000503611416555700022443 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production OptionBinding:
* Corresponding grammar :
* f0 -> ( %0 < IDENTIFIER >
* .. .. | %1 "LOOKAHEAD"
* .. .. | %2 "IGNORE_CASE"
* .. .. | %3 "static" )
* f1 -> "="
* f2 -> ( %0 IntegerLiteral()
* .. .. | %1 BooleanLiteral()
* .. .. | %2 StringLiteral() )
* f3 -> ";"
*/ public class OptionBinding implements INode { /** A child node */ public NodeChoice f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeChoice f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public OptionBinding(final NodeChoice n0, final NodeToken n1, final NodeChoice n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public OptionBinding(final NodeChoice n0, final NodeChoice n1) { f0 = n0; f1 = new NodeToken("="); f2 = n1; f3 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/VariableDeclaratorId.java0000644000175000017500000000350711416555700023704 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production VariableDeclaratorId:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> ( #0 "[" #1 "]" )*
*/ public class VariableDeclaratorId implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public VariableDeclaratorId(final NodeToken n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeOptional.java0000644000175000017500000000461611416555700022276 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; /** * Represents a grammar optional node (? or []), e.g. ' ( A )? ' or ' [ A ] '.
* The class stores the node. */ public class NodeOptional implements INode { /** The node (if null there is no node) */ public INode node; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Initializes an empty {@link NodeOptional}. */ public NodeOptional() { node = null; } /** * Initializes a {@link NodeOptional} with a node. * * @param n the node */ public NodeOptional(final INode n) { addNode(n); } /** * Adds a node to the {@link NodeOptional}. * * @param n the node to add */ public void addNode(final INode n) { if (node != null) throw new Error("Attempt to set optional node twice"); node = n; } /** * @return true if the node exists, false otherwise */ public boolean present() { return (node != null); } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ThrowStatement.java0000644000175000017500000000424011416555700022664 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ThrowStatement:
* Corresponding grammar :
* f0 -> "throw"
* f1 -> Expression()
* f2 -> ";"
*/ public class ThrowStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Expression f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ThrowStatement(final NodeToken n0, final Expression n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public ThrowStatement(final Expression n0) { f0 = new NodeToken("throw"); f1 = n0; f2 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Statement.java0000644000175000017500000000427211416555700021645 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Statement:
* Corresponding grammar :
* f0 -> . %00 LabeledStatement()
* .. .. | %01 AssertStatement()
* .. .. | %02 Block()
* .. .. | %03 EmptyStatement()
* .. .. | %04 #0 StatementExpression() #1 ";"
* .. .. | %05 SwitchStatement()
* .. .. | %06 IfStatement()
* .. .. | %07 WhileStatement()
* .. .. | %08 DoStatement()
* .. .. | %09 ForStatement()
* .. .. | %10 BreakStatement()
* .. .. | %11 ContinueStatement()
* .. .. | %12 ReturnStatement()
* .. .. | %13 ThrowStatement()
* .. .. | %14 SynchronizedStatement()
* .. .. | %15 TryStatement()
*/ public class Statement implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Statement(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ClassOrInterfaceDeclaration.java0000644000175000017500000000475211416555700025241 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ClassOrInterfaceDeclaration:
* Corresponding grammar :
* f0 -> ( %0 "class"
* .. .. | %1 "interface" )
* f1 -> < IDENTIFIER >
* f2 -> [ TypeParameters() ]
* f3 -> [ ExtendsList() ]
* f4 -> [ ImplementsList() ]
* f5 -> ClassOrInterfaceBody()
*/ public class ClassOrInterfaceDeclaration implements INode { /** A child node */ public NodeChoice f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeOptional f4; /** A child node */ public ClassOrInterfaceBody f5; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node */ public ClassOrInterfaceDeclaration(final NodeChoice n0, final NodeToken n1, final NodeOptional n2, final NodeOptional n3, final NodeOptional n4, final ClassOrInterfaceBody n5) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/EnumConstant.java0000644000175000017500000000412311416555700022312 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production EnumConstant:
* Corresponding grammar :
* f0 -> Modifiers()
* f1 -> < IDENTIFIER >
* f2 -> [ Arguments() ]
* f3 -> [ ClassOrInterfaceBody() ]
*/ public class EnumConstant implements INode { /** A child node */ public Modifiers f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeOptional f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public EnumConstant(final Modifiers n0, final NodeToken n1, final NodeOptional n2, final NodeOptional n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PreIncrementExpression.java0000644000175000017500000000406311416555700024352 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PreIncrementExpression:
* Corresponding grammar :
* f0 -> "++"
* f1 -> PrimaryExpression()
*/ public class PreIncrementExpression implements INode { /** A child node */ public NodeToken f0; /** A child node */ public PrimaryExpression f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public PreIncrementExpression(final NodeToken n0, final PrimaryExpression n1) { f0 = n0; f1 = n1; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public PreIncrementExpression(final PrimaryExpression n0) { f0 = new NodeToken("++"); f1 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeParameters.java0000644000175000017500000000463311416555700022647 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeParameters:
* Corresponding grammar :
* f0 -> "<"
* f1 -> TypeParameter()
* f2 -> ( #0 "," #1 TypeParameter() )*
* f3 -> ">"
*/ public class TypeParameters implements INode { /** A child node */ public NodeToken f0; /** A child node */ public TypeParameter f1; /** A child node */ public NodeListOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public TypeParameters(final NodeToken n0, final TypeParameter n1, final NodeListOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public TypeParameters(final TypeParameter n0, final NodeListOptional n1) { f0 = new NodeToken("<"); f1 = n0; f2 = n1; f3 = new NodeToken(">"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ReturnStatement.java0000644000175000017500000000426011416555700023042 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ReturnStatement:
* Corresponding grammar :
* f0 -> "return"
* f1 -> [ Expression() ]
* f2 -> ";"
*/ public class ReturnStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ReturnStatement(final NodeToken n0, final NodeOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public ReturnStatement(final NodeOptional n0) { f0 = new NodeToken("return"); f1 = n0; f2 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ArgumentList.java0000644000175000017500000000347011416555700022316 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ArgumentList:
* Corresponding grammar :
* f0 -> Expression()
* f1 -> ( #0 "," #1 Expression() )*
*/ public class ArgumentList implements INode { /** A child node */ public Expression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ArgumentList(final Expression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ForInit.java0000644000175000017500000000326411416555700021253 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ForInit:
* Corresponding grammar :
* f0 -> . %0 LocalVariableDeclaration()
* .. .. | %1 StatementExpressionList()
*/ public class ForInit implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ForInit(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ReferenceType.java0000644000175000017500000000342011416555700022433 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ReferenceType:
* Corresponding grammar :
* f0 -> . %0 #0 PrimitiveType()
* .. .. . .. #1 ( $0 "[" $1 "]" )+
* .. .. | %1 #0 ClassOrInterfaceType()
* .. .. . .. #1 ( $0 "[" $1 "]" )*
*/ public class ReferenceType implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ReferenceType(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/SingleMemberAnnotation.java0000644000175000017500000000503211416555700024300 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production SingleMemberAnnotation:
* Corresponding grammar :
* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> MemberValue()
* f4 -> ")"
*/ public class SingleMemberAnnotation implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Name f1; /** A child node */ public NodeToken f2; /** A child node */ public MemberValue f3; /** A child node */ public NodeToken f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public SingleMemberAnnotation(final NodeToken n0, final Name n1, final NodeToken n2, final MemberValue n3, final NodeToken n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public SingleMemberAnnotation(final Name n0, final MemberValue n1) { f0 = new NodeToken("@"); f1 = n0; f2 = new NodeToken("("); f3 = n1; f4 = new NodeToken(")"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/INodeList.java0000644000175000017500000000357011416555700021533 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; /** * The interface which {@link NodeList}, {@link NodeListOptional} and {@link NodeSequence} must implement. */ public interface INodeList extends INode { /** * Adds a node to the list. * * @param n the node to add */ public void addNode(final INode n); /** * @param i the element index * @return the element at the given index */ public INode elementAt(int i); /** * @return the iterator on the node list */ public java.util.Iterator elements(); /** * @return the list size */ public int size(); /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu); /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis); /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu); /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis); } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Expression.java0000644000175000017500000000353311416555700022037 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Expression:
* Corresponding grammar :
* f0 -> ConditionalExpression()
* f1 -> [ #0 AssignmentOperator() #1 Expression() ]
*/ public class Expression implements INode { /** A child node */ public ConditionalExpression f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public Expression(final ConditionalExpression n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ShiftExpression.java0000644000175000017500000000367111416555700023040 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ShiftExpression:
* Corresponding grammar :
* f0 -> AdditiveExpression()
* f1 -> ( #0 ( %0 "<<"
* .. .. . .. | %1 RSIGNEDSHIFT()
* .. .. . .. | %2 RUNSIGNEDSHIFT() ) #1 AdditiveExpression() )*
*/ public class ShiftExpression implements INode { /** A child node */ public AdditiveExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ShiftExpression(final AdditiveExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AFancyProduction.java0000644000175000017500000000417611416555700023114 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AFancyProduction:
* Corresponding grammar :
* try {
* f0 -> ( #0 ( Annotation() )*
* .. .. . #1 ( %0 LabeledStatement()
* .. .. . .. | %1 AssertStatement()
* .. .. . .. | %2 Block()
* .. .. . .. | %3 EmptyStatement()
* .. .. . .. | %4 $0 StatementExpression() $1 ";"
* .. .. . .. | %5 SwitchStatement()
* .. .. . .. | %6 TryStatement() )
* .. .. . #2 [ MarkerAnnotation() ] )
* }
* catch (Name() < IDENTIFIER >) Block()
* catch (Name() < IDENTIFIER >) Block()
* finally Block()
*/ public class AFancyProduction implements INode { /** A child node */ public NodeSequence f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public AFancyProduction(final NodeSequence n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RelationalExpression.java0000644000175000017500000000370111416555700024047 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RelationalExpression:
* Corresponding grammar :
* f0 -> ShiftExpression()
* f1 -> ( #0 ( %0 "<"
* .. .. . .. | %1 ">"
* .. .. . .. | %2 "<="
* .. .. . .. | %3 ">=" ) #1 ShiftExpression() )*
*/ public class RelationalExpression implements INode { /** A child node */ public ShiftExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public RelationalExpression(final ShiftExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Initializer.java0000644000175000017500000000341711416555700022164 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Initializer:
* Corresponding grammar :
* f0 -> [ "static" ]
* f1 -> Block()
*/ public class Initializer implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public Block f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public Initializer(final NodeOptional n0, final Block n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExpansionUnit.java0000644000175000017500000000424111416555700022501 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExpansionUnit:
* Corresponding grammar :
* f0 -> . %0 #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")"
* .. .. | %1 Block()
* .. .. | %2 #0 "[" #1 ExpansionChoices() #2 "]"
* .. .. | %3 ExpansionUnitInTCF()
* .. .. | %4 #0 [ $0 PrimaryExpression() $1 "=" ]
* .. .. . .. #1 ( &0 $0 Identifier() $1 Arguments()
* .. .. . .. .. | &1 $0 RegularExpression()
* .. .. . .. .. . .. $1 [ £0 "." £1 < IDENTIFIER > ] )
* .. .. | %5 #0 "(" #1 ExpansionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?" )?
*/ public class ExpansionUnit implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ExpansionUnit(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AllocationExpression.java0000644000175000017500000000367211416555700024051 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AllocationExpression:
* Corresponding grammar :
* f0 -> . %0 #0 "new" #1 PrimitiveType() #2 ArrayDimsAndInits()
* .. .. | %1 #0 "new" #1 ClassOrInterfaceType()
* .. .. . .. #2 [ TypeArguments() ]
* .. .. . .. #3 ( &0 ArrayDimsAndInits()
* .. .. . .. .. | &1 $0 Arguments()
* .. .. . .. .. . .. $1 [ ClassOrInterfaceBody() ] )
*/ public class AllocationExpression implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public AllocationExpression(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Arguments.java0000644000175000017500000000422011416555700021637 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Arguments:
* Corresponding grammar :
* f0 -> "("
* f1 -> [ ArgumentList() ]
* f2 -> ")"
*/ public class Arguments implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public Arguments(final NodeToken n0, final NodeOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public Arguments(final NodeOptional n0) { f0 = new NodeToken("("); f1 = n0; f2 = new NodeToken(")"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/InclusiveOrExpression.java0000644000175000017500000000357711416555700024232 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production InclusiveOrExpression:
* Corresponding grammar :
* f0 -> ExclusiveOrExpression()
* f1 -> ( #0 "|" #1 ExclusiveOrExpression() )*
*/ public class InclusiveOrExpression implements INode { /** A child node */ public ExclusiveOrExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public InclusiveOrExpression(final ExclusiveOrExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Identifier.java0000644000175000017500000000317511416555700021764 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Identifier:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
*/ public class Identifier implements INode { /** A child node */ public NodeToken f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Identifier(final NodeToken n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ClassOrInterfaceBodyDeclaration.java0000644000175000017500000000376411416555700026061 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ClassOrInterfaceBodyDeclaration:
* Corresponding grammar :
* f0 -> . %0 Initializer()
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 ConstructorDeclaration()
* .. .. . .. .. | &3 FieldDeclaration()
* .. .. . .. .. | &4 MethodDeclaration() )
* .. .. | %2 ";"
*/ public class ClassOrInterfaceBodyDeclaration implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ClassOrInterfaceBodyDeclaration(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/LocalVariableDeclaration.java0000644000175000017500000000420711416555700024545 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production LocalVariableDeclaration:
* Corresponding grammar :
* f0 -> Modifiers()
* f1 -> Type()
* f2 -> VariableDeclarator()
* f3 -> ( #0 "," #1 VariableDeclarator() )*
*/ public class LocalVariableDeclaration implements INode { /** A child node */ public Modifiers f0; /** A child node */ public Type f1; /** A child node */ public VariableDeclarator f2; /** A child node */ public NodeListOptional f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public LocalVariableDeclaration(final Modifiers n0, final Type n1, final VariableDeclarator n2, final NodeListOptional n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ComplexRegularExpressionChoices.java0000644000175000017500000000365111416555700026210 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ComplexRegularExpressionChoices:
* Corresponding grammar :
* f0 -> ComplexRegularExpression()
* f1 -> ( #0 "|" #1 ComplexRegularExpression() )*
*/ public class ComplexRegularExpressionChoices implements INode { /** A child node */ public ComplexRegularExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ComplexRegularExpressionChoices(final ComplexRegularExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ConditionalExpression.java0000644000175000017500000000361011416555700024217 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ConditionalExpression:
* Corresponding grammar :
* f0 -> ConditionalOrExpression()
* f1 -> [ #0 "?" #1 Expression() #2 ":" #3 Expression() ]
*/ public class ConditionalExpression implements INode { /** A child node */ public ConditionalOrExpression f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ConditionalExpression(final ConditionalOrExpression n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MemberValueArrayInitializer.java0000644000175000017500000000523111416555700025304 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MemberValueArrayInitializer:
* Corresponding grammar :
* f0 -> "{"
* f1 -> MemberValue()
* f2 -> ( #0 "," #1 MemberValue() )*
* f3 -> [ "," ]
* f4 -> "}"
*/ public class MemberValueArrayInitializer implements INode { /** A child node */ public NodeToken f0; /** A child node */ public MemberValue f1; /** A child node */ public NodeListOptional f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeToken f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public MemberValueArrayInitializer(final NodeToken n0, final MemberValue n1, final NodeListOptional n2, final NodeOptional n3, final NodeToken n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public MemberValueArrayInitializer(final MemberValue n0, final NodeListOptional n1, final NodeOptional n2) { f0 = new NodeToken("{"); f1 = n0; f2 = n1; f3 = n2; f4 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/StringLiteral.java0000644000175000017500000000344211416555700022462 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production StringLiteral:
* Corresponding grammar :
* f0 -> < STRING_LITERAL >
*/ public class StringLiteral implements INode { /** A child node */ public NodeToken f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public StringLiteral(final NodeToken n0) { f0 = n0; } /** * Constructs the node with only its non NodeToken child node. * */ public StringLiteral() { f0 = new NodeToken("\""); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/StatementExpressionList.java0000644000175000017500000000357511416555700024566 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production StatementExpressionList:
* Corresponding grammar :
* f0 -> StatementExpression()
* f1 -> ( #0 "," #1 StatementExpression() )*
*/ public class StatementExpressionList implements INode { /** A child node */ public StatementExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public StatementExpressionList(final StatementExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/BooleanLiteral.java0000644000175000017500000000324311416555700022572 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production BooleanLiteral:
* Corresponding grammar :
* f0 -> . %0 "true"
* .. .. | %1 "false"
*/ public class BooleanLiteral implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public BooleanLiteral(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ImportDeclaration.java0000644000175000017500000000511511416555700023316 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ImportDeclaration:
* Corresponding grammar :
* f0 -> "import"
* f1 -> [ "static" ]
* f2 -> Name()
* f3 -> [ #0 "." #1 "*" ]
* f4 -> ";"
*/ public class ImportDeclaration implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public Name f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeToken f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public ImportDeclaration(final NodeToken n0, final NodeOptional n1, final Name n2, final NodeOptional n3, final NodeToken n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ImportDeclaration(final NodeOptional n0, final Name n1, final NodeOptional n2) { f0 = new NodeToken("import"); f1 = n0; f2 = n1; f3 = n2; f4 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/UnaryExpression.java0000644000175000017500000000351711416555700023060 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production UnaryExpression:
* Corresponding grammar :
* f0 -> . %0 #0 ( &0 "+"
* .. .. . .. .. | &1 "-" ) #1 UnaryExpression()
* .. .. | %1 PreIncrementExpression()
* .. .. | %2 PreDecrementExpression()
* .. .. | %3 UnaryExpressionNotPlusMinus()
*/ public class UnaryExpression implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public UnaryExpression(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NullLiteral.java0000644000175000017500000000342011416555700022122 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production NullLiteral:
* Corresponding grammar :
* f0 -> "null"
*/ public class NullLiteral implements INode { /** A child node */ public NodeToken f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public NullLiteral(final NodeToken n0) { f0 = n0; } /** * Constructs the node with only its non NodeToken child node. * */ public NullLiteral() { f0 = new NodeToken("null"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/LabeledStatement.java0000644000175000017500000000431311416555700023112 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production LabeledStatement:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> ":"
* f2 -> Statement()
*/ public class LabeledStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public Statement f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public LabeledStatement(final NodeToken n0, final NodeToken n1, final Statement n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public LabeledStatement(final NodeToken n0, final Statement n1) { f0 = n0; f1 = new NodeToken(":"); f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ResultType.java0000644000175000017500000000323011416555700022012 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ResultType:
* Corresponding grammar :
* f0 -> ( %0 "void"
* .. .. | %1 Type() )
*/ public class ResultType implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ResultType(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MemberValuePairs.java0000644000175000017500000000353011416555700023100 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MemberValuePairs:
* Corresponding grammar :
* f0 -> MemberValuePair()
* f1 -> ( #0 "," #1 MemberValuePair() )*
*/ public class MemberValuePairs implements INode { /** A child node */ public MemberValuePair f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public MemberValuePairs(final MemberValuePair n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MultiplicativeExpression.java0000644000175000017500000000365711416555700024762 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MultiplicativeExpression:
* Corresponding grammar :
* f0 -> UnaryExpression()
* f1 -> ( #0 ( %0 "*"
* .. .. . .. | %1 "/"
* .. .. . .. | %2 "%" ) #1 UnaryExpression() )*
*/ public class MultiplicativeExpression implements INode { /** A child node */ public UnaryExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public MultiplicativeExpression(final UnaryExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeListOptional.java0000644000175000017500000000770111416555700023130 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; import java.util.*; /** * Represents an optional grammar list (*), e.g. ' ( A )* '.
* The class stores the nodes list in an ArrayList. */ public class NodeListOptional implements INodeList { /** The list of nodes */ public ArrayList nodes; /** The allocation sizes table */ private static final int allocTb[] = {0, 1, 2, 3, 4, 5, 10, 20, 50}; /** The allocation number */ private int allocNb = 0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Initializes an empty list of nodes with a default first allocation. */ public NodeListOptional() { nodes = new ArrayList(allocTb[allocNb]); } /** * Initializes an empty list of nodes with a given allocation. * * @param sz the list size */ public NodeListOptional(final int sz) { nodes = new ArrayList(sz); } /** * Initializes an empty list of nodes with a default first allocation and adds a first node. * * @param firstNode the node to add */ public NodeListOptional(final INode firstNode) { nodes = new ArrayList(allocTb[allocNb]); addNode(firstNode); } /** * Initializes an empty list of nodes with a given allocation and adds a first node. * * @param sz the list size * @param firstNode the node to add */ public NodeListOptional(final int sz, final INode firstNode) { nodes = new ArrayList(sz); addNode(firstNode); } /** * Adds a node to the list of nodes, managing progressive allocation increments. * * @param n the node to add */ public void addNode(final INode n) { if (++allocNb < allocTb.length) nodes.ensureCapacity(allocTb[allocNb]); else nodes.ensureCapacity((allocNb - allocTb.length + 2) * allocTb[(allocTb.length - 1)]); nodes.add(n); } /** * Gets the node in the list at a given position. * * @param i the node's position * @return the node */ public INode elementAt(final int i) { return nodes.get(i); } /** * Returns an iterator on the nodes list. * * @return the iterator */ public Iterator elements() { return nodes.iterator(); } /** * Returns the number of nodes in the list. * * @return the list size */ public int size() { return nodes.size(); } /** * @return true if there is at least one node, false otherwise */ public boolean present() { return (nodes.size() != 0); } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/LocalLookahead.java0000644000175000017500000000440411416555700022540 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production LocalLookahead:
* Corresponding grammar :
* f0 -> [ IntegerLiteral() ]
* f1 -> [ "," ]
* f2 -> [ ExpansionChoices() ]
* f3 -> [ "," ]
* f4 -> [ #0 "{" #1 Expression() #2 "}" ]
*/ public class LocalLookahead implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeOptional f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public LocalLookahead(final NodeOptional n0, final NodeOptional n1, final NodeOptional n2, final NodeOptional n3, final NodeOptional n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/FieldDeclaration.java0000644000175000017500000000472411416555700023074 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production FieldDeclaration:
* Corresponding grammar :
* f0 -> Type()
* f1 -> VariableDeclarator()
* f2 -> ( #0 "," #1 VariableDeclarator() )*
* f3 -> ";"
*/ public class FieldDeclaration implements INode { /** A child node */ public Type f0; /** A child node */ public VariableDeclarator f1; /** A child node */ public NodeListOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public FieldDeclaration(final Type n0, final VariableDeclarator n1, final NodeListOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public FieldDeclaration(final Type n0, final VariableDeclarator n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; f3 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MemberValuePair.java0000644000175000017500000000431711416555700022721 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MemberValuePair:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> "="
* f2 -> MemberValue()
*/ public class MemberValuePair implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public MemberValue f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public MemberValuePair(final NodeToken n0, final NodeToken n1, final MemberValue n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public MemberValuePair(final NodeToken n0, final MemberValue n1) { f0 = n0; f1 = new NodeToken("="); f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeChoice.java0000644000175000017500000000503011416555700021672 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; /** * Represents a grammar choice (|), e.g. ' ( A | B ) '.
* The class stores the node and the "which" choice indicator (0, 1, ...). */ public class NodeChoice implements INode { /** The real node */ public INode choice; /** The "which" choice indicator */ public int which; /** The total number of choices */ public int total; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the {@link NodeChoice} with a given node and non standard (-1) which choice and total number of choices. * * @param node the node */ public NodeChoice(final INode node) { this(node, -1, -1); } /** * Constructs the {@link NodeChoice} with a given node, a which choice and a total (not controlled). * * @param node the node * @param whichChoice the which choice * @param totalChoices the total number of choices */ public NodeChoice(final INode node, final int whichChoice, final int totalChoices) { choice = node; which = whichChoice; total = totalChoices; } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return choice.accept(vis, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return choice.accept(vis); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { choice.accept(vis, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { choice.accept(vis); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/DefaultValue.java0000644000175000017500000000377511416555700022271 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production DefaultValue:
* Corresponding grammar :
* f0 -> "default"
* f1 -> MemberValue()
*/ public class DefaultValue implements INode { /** A child node */ public NodeToken f0; /** A child node */ public MemberValue f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public DefaultValue(final NodeToken n0, final MemberValue n1) { f0 = n0; f1 = n1; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public DefaultValue(final MemberValue n0) { f0 = new NodeToken("default"); f1 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Type.java0000644000175000017500000000322611416555700020620 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Type:
* Corresponding grammar :
* f0 -> . %0 ReferenceType()
* .. .. | %1 PrimitiveType()
*/ public class Type implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Type(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Literal.java0000644000175000017500000000350211416555700021270 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Literal:
* Corresponding grammar :
* f0 -> . %0 < INTEGER_LITERAL >
* .. .. | %1 < FLOATING_POINT_LITERAL >
* .. .. | %2 < CHARACTER_LITERAL >
* .. .. | %3 < STRING_LITERAL >
* .. .. | %4 BooleanLiteral()
* .. .. | %5 NullLiteral()
*/ public class Literal implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Literal(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MemberValue.java0000644000175000017500000000334111416555700022101 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MemberValue:
* Corresponding grammar :
* f0 -> . %0 Annotation()
* .. .. | %1 MemberValueArrayInitializer()
* .. .. | %2 ConditionalExpression()
*/ public class MemberValue implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public MemberValue(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RSIGNEDSHIFT.java0000644000175000017500000000367611416555700021601 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RSIGNEDSHIFT:
* Corresponding grammar :
* f0 -> ">"
* f1 -> ">"
*/ public class RSIGNEDSHIFT implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public RSIGNEDSHIFT(final NodeToken n0, final NodeToken n1) { f0 = n0; f1 = n1; } /** * Constructs the node with only its non NodeToken child node(s). * */ public RSIGNEDSHIFT() { f0 = new NodeToken(">"); f1 = new NodeToken(">"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/FormalParameter.java0000644000175000017500000000412011416555700022752 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production FormalParameter:
* Corresponding grammar :
* f0 -> Modifiers()
* f1 -> Type()
* f2 -> [ "..." ]
* f3 -> VariableDeclaratorId()
*/ public class FormalParameter implements INode { /** A child node */ public Modifiers f0; /** A child node */ public Type f1; /** A child node */ public NodeOptional f2; /** A child node */ public VariableDeclaratorId f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public FormalParameter(final Modifiers n0, final Type n1, final NodeOptional n2, final VariableDeclaratorId n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/DoStatement.java0000644000175000017500000000551611416555700022132 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production DoStatement:
* Corresponding grammar :
* f0 -> "do"
* f1 -> Statement()
* f2 -> "while"
* f3 -> "("
* f4 -> Expression()
* f5 -> ")"
* f6 -> ";"
*/ public class DoStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Statement f1; /** A child node */ public NodeToken f2; /** A child node */ public NodeToken f3; /** A child node */ public Expression f4; /** A child node */ public NodeToken f5; /** A child node */ public NodeToken f6; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node */ public DoStatement(final NodeToken n0, final Statement n1, final NodeToken n2, final NodeToken n3, final Expression n4, final NodeToken n5, final NodeToken n6) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public DoStatement(final Statement n0, final Expression n1) { f0 = new NodeToken("do"); f1 = n0; f2 = new NodeToken("while"); f3 = new NodeToken("("); f4 = n1; f5 = new NodeToken(")"); f6 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeDeclaration.java0000644000175000017500000000351111416555700022763 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeDeclaration:
* Corresponding grammar :
* f0 -> . %0 ";"
* .. .. | %1 #0 Modifiers()
* .. .. . .. #1 ( &0 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &1 EnumDeclaration()
* .. .. . .. .. | &2 AnnotationTypeDeclaration() )
*/ public class TypeDeclaration implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public TypeDeclaration(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/WildcardBounds.java0000644000175000017500000000332211416555700022600 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production WildcardBounds:
* Corresponding grammar :
* f0 -> . %0 #0 "extends" #1 ReferenceType()
* .. .. | %1 #0 "super" #1 ReferenceType()
*/ public class WildcardBounds implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public WildcardBounds(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/CompilationUnit.java0000644000175000017500000000376411416555700023024 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production CompilationUnit:
* Corresponding grammar :
* f0 -> [ PackageDeclaration() ]
* f1 -> ( ImportDeclaration() )*
* f2 -> ( TypeDeclaration() )*
*/ public class CompilationUnit implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public NodeListOptional f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public CompilationUnit(final NodeOptional n0, final NodeListOptional n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Annotation.java0000644000175000017500000000333211416555700022007 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Annotation:
* Corresponding grammar :
* f0 -> . %0 NormalAnnotation()
* .. .. | %1 SingleMemberAnnotation()
* .. .. | %2 MarkerAnnotation()
*/ public class Annotation implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Annotation(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/EnumBody.java0000644000175000017500000000524511416555700021424 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production EnumBody:
* Corresponding grammar :
* f0 -> "{"
* f1 -> [ #0 EnumConstant()
* .. .. . #1 ( $0 "," $1 EnumConstant() )* ]
* f2 -> [ "," ]
* f3 -> [ #0 ";"
* .. .. . #1 ( ClassOrInterfaceBodyDeclaration() )* ]
* f4 -> "}"
*/ public class EnumBody implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeToken f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public EnumBody(final NodeToken n0, final NodeOptional n1, final NodeOptional n2, final NodeOptional n3, final NodeToken n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public EnumBody(final NodeOptional n0, final NodeOptional n1, final NodeOptional n2) { f0 = new NodeToken("{"); f1 = n0; f2 = n1; f3 = n2; f4 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/CastExpression.java0000644000175000017500000000337211416555700022653 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production CastExpression:
* Corresponding grammar :
* f0 -> . %0 #0 "(" #1 Type() #2 ")" #3 UnaryExpression()
* .. .. | %1 #0 "(" #1 Type() #2 ")" #3 UnaryExpressionNotPlusMinus()
*/ public class CastExpression implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public CastExpression(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AndExpression.java0000644000175000017500000000353311416555700022462 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AndExpression:
* Corresponding grammar :
* f0 -> EqualityExpression()
* f1 -> ( #0 "&" #1 EqualityExpression() )*
*/ public class AndExpression implements INode { /** A child node */ public EqualityExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public AndExpression(final EqualityExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ComplexRegularExpression.java0000644000175000017500000000327211416555700024711 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ComplexRegularExpression:
* Corresponding grammar :
* f0 -> ( ComplexRegularExpressionUnit() )+
*/ public class ComplexRegularExpression implements INode { /** A child node */ public NodeList f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ComplexRegularExpression(final NodeList n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/CharacterDescriptor.java0000644000175000017500000000352011416555700023627 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production CharacterDescriptor:
* Corresponding grammar :
* f0 -> StringLiteral()
* f1 -> [ #0 "-" #1 StringLiteral() ]
*/ public class CharacterDescriptor implements INode { /** A child node */ public StringLiteral f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public CharacterDescriptor(final StringLiteral n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MarkerAnnotation.java0000644000175000017500000000374511416555700023161 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MarkerAnnotation:
* Corresponding grammar :
* f0 -> "@"
* f1 -> Name()
*/ public class MarkerAnnotation implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Name f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public MarkerAnnotation(final NodeToken n0, final Name n1) { f0 = n0; f1 = n1; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public MarkerAnnotation(final Name n0) { f0 = new NodeToken("@"); f1 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RegExprKind.java0000644000175000017500000000332711416555700022063 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RegExprKind:
* Corresponding grammar :
* f0 -> . %0 "TOKEN"
* .. .. | %1 "SPECIAL_TOKEN"
* .. .. | %2 "SKIP"
* .. .. | %3 "MORE"
*/ public class RegExprKind implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public RegExprKind(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/JavaIdentifier.java0000644000175000017500000000375611416555700022573 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production JavaIdentifier:
* Corresponding grammar :
* f0 -> ( %00 < IDENTIFIER >
* .. .. | %01 "LOOKAHEAD"
* .. .. | %02 "IGNORE_CASE"
* .. .. | %03 "PARSER_BEGIN"
* .. .. | %04 "PARSER_END"
* .. .. | %05 "JAVACODE"
* .. .. | %06 "TOKEN"
* .. .. | %07 "SPECIAL_TOKEN"
* .. .. | %08 "MORE"
* .. .. | %09 "SKIP"
* .. .. | %10 "TOKEN_MGR_DECLS"
* .. .. | %11 "EOF" )
*/ public class JavaIdentifier implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public JavaIdentifier(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ConditionalOrExpression.java0000644000175000017500000000362211416555700024523 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ConditionalOrExpression:
* Corresponding grammar :
* f0 -> ConditionalAndExpression()
* f1 -> ( #0 "||" #1 ConditionalAndExpression() )*
*/ public class ConditionalOrExpression implements INode { /** A child node */ public ConditionalAndExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ConditionalOrExpression(final ConditionalAndExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MethodDeclaration.java0000644000175000017500000000445011416555700023265 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MethodDeclaration:
* Corresponding grammar :
* f0 -> [ TypeParameters() ]
* f1 -> ResultType()
* f2 -> MethodDeclarator()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> ( %0 Block()
* .. .. | %1 ";" )
*/ public class MethodDeclaration implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public ResultType f1; /** A child node */ public MethodDeclarator f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeChoice f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public MethodDeclaration(final NodeOptional n0, final ResultType n1, final MethodDeclarator n2, final NodeOptional n3, final NodeChoice n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/EqualityExpression.java0000644000175000017500000000362711416555700023561 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production EqualityExpression:
* Corresponding grammar :
* f0 -> InstanceOfExpression()
* f1 -> ( #0 ( %0 "=="
* .. .. . .. | %1 "!=" ) #1 InstanceOfExpression() )*
*/ public class EqualityExpression implements INode { /** A child node */ public InstanceOfExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public EqualityExpression(final InstanceOfExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ContinueStatement.java0000644000175000017500000000427611416555700023356 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ContinueStatement:
* Corresponding grammar :
* f0 -> "continue"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
*/ public class ContinueStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ContinueStatement(final NodeToken n0, final NodeOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public ContinueStatement(final NodeOptional n0) { f0 = new NodeToken("continue"); f1 = n0; f2 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PrimitiveType.java0000644000175000017500000000350111416555700022505 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PrimitiveType:
* Corresponding grammar :
* f0 -> . %0 "boolean"
* .. .. | %1 "char"
* .. .. | %2 "byte"
* .. .. | %3 "short"
* .. .. | %4 "int"
* .. .. | %5 "long"
* .. .. | %6 "float"
* .. .. | %7 "double"
*/ public class PrimitiveType implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public PrimitiveType(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ImplementsList.java0000644000175000017500000000445511416555700022655 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ImplementsList:
* Corresponding grammar :
* f0 -> "implements"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
*/ public class ImplementsList implements INode { /** A child node */ public NodeToken f0; /** A child node */ public ClassOrInterfaceType f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ImplementsList(final NodeToken n0, final ClassOrInterfaceType n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public ImplementsList(final ClassOrInterfaceType n0, final NodeListOptional n1) { f0 = new NodeToken("implements"); f1 = n0; f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExpansionChoices.java0000644000175000017500000000350011416555700023134 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExpansionChoices:
* Corresponding grammar :
* f0 -> Expansion()
* f1 -> ( #0 "|" #1 Expansion() )*
*/ public class ExpansionChoices implements INode { /** A child node */ public Expansion f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ExpansionChoices(final Expansion n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/InstanceOfExpression.java0000644000175000017500000000355011416555700024010 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production InstanceOfExpression:
* Corresponding grammar :
* f0 -> RelationalExpression()
* f1 -> [ #0 "instanceof" #1 Type() ]
*/ public class InstanceOfExpression implements INode { /** A child node */ public RelationalExpression f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public InstanceOfExpression(final RelationalExpression n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ComplexRegularExpressionUnit.java0000644000175000017500000000412311416555700025545 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ComplexRegularExpressionUnit:
* Corresponding grammar :
* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 "<" #1 Identifier() #2 ">"
* .. .. | %2 CharacterList()
* .. .. | %3 #0 "(" #1 ComplexRegularExpressionChoices() #2 ")"
* .. .. . .. #3 ( &0 "+"
* .. .. . .. .. | &1 "*"
* .. .. . .. .. | &2 "?"
* .. .. . .. .. | &3 $0 "{" $1 IntegerLiteral()
* .. .. . .. .. . .. $2 [ £0 ","
* .. .. . .. .. . .. .. . £1 [ IntegerLiteral() ] ] $3 "}" )?
*/ public class ComplexRegularExpressionUnit implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ComplexRegularExpressionUnit(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ForStatement.java0000644000175000017500000000530111416555700022306 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ForStatement:
* Corresponding grammar :
* f0 -> "for"
* f1 -> "("
* f2 -> ( %0 #0 Modifiers() #1 Type() #2 < IDENTIFIER > #3 ":" #4 Expression()
* .. .. | %1 #0 [ ForInit() ] #1 ";"
* .. .. . .. #2 [ Expression() ] #3 ";"
* .. .. . .. #4 [ ForUpdate() ] )
* f3 -> ")"
* f4 -> Statement()
*/ public class ForStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeChoice f2; /** A child node */ public NodeToken f3; /** A child node */ public Statement f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public ForStatement(final NodeToken n0, final NodeToken n1, final NodeChoice n2, final NodeToken n3, final Statement n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public ForStatement(final NodeChoice n0, final Statement n1) { f0 = new NodeToken("for"); f1 = new NodeToken("("); f2 = n0; f3 = new NodeToken(")"); f4 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ConstructorDeclaration.java0000644000175000017500000000651311416555700024374 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ConstructorDeclaration:
* Corresponding grammar :
* f0 -> [ TypeParameters() ]
* f1 -> < IDENTIFIER >
* f2 -> FormalParameters()
* f3 -> [ #0 "throws" #1 NameList() ]
* f4 -> "{"
* f5 -> [ ExplicitConstructorInvocation() ]
* f6 -> ( BlockStatement() )*
* f7 -> "}"
*/ public class ConstructorDeclaration implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public NodeToken f1; /** A child node */ public FormalParameters f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeToken f4; /** A child node */ public NodeOptional f5; /** A child node */ public NodeListOptional f6; /** A child node */ public NodeToken f7; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node * @param n7 next child node */ public ConstructorDeclaration(final NodeOptional n0, final NodeToken n1, final FormalParameters n2, final NodeOptional n3, final NodeToken n4, final NodeOptional n5, final NodeListOptional n6, final NodeToken n7) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; f7 = n7; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node */ public ConstructorDeclaration(final NodeOptional n0, final NodeToken n1, final FormalParameters n2, final NodeOptional n3, final NodeOptional n4, final NodeListOptional n5) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = new NodeToken("{"); f5 = n4; f6 = n5; f7 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExplicitConstructorInvocation.java0000644000175000017500000000344711416555700025765 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExplicitConstructorInvocation:
* Corresponding grammar :
* f0 -> . %0 #0 "this" #1 Arguments() #2 ";"
* .. .. | %1 #0 [ $0 PrimaryExpression() $1 "." ] #1 "super" #2 Arguments() #3 ";"
*/ public class ExplicitConstructorInvocation implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ExplicitConstructorInvocation(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PrimarySuffix.java0000644000175000017500000000354311416555700022511 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PrimarySuffix:
* Corresponding grammar :
* f0 -> . %0 #0 "." #1 "this"
* .. .. | %1 #0 "." #1 AllocationExpression()
* .. .. | %2 MemberSelector()
* .. .. | %3 #0 "[" #1 Expression() #2 "]"
* .. .. | %4 #0 "." #1 < IDENTIFIER >
* .. .. | %5 Arguments()
*/ public class PrimarySuffix implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public PrimarySuffix(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeArguments.java0000644000175000017500000000462211416555700022507 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeArguments:
* Corresponding grammar :
* f0 -> "<"
* f1 -> TypeArgument()
* f2 -> ( #0 "," #1 TypeArgument() )*
* f3 -> ">"
*/ public class TypeArguments implements INode { /** A child node */ public NodeToken f0; /** A child node */ public TypeArgument f1; /** A child node */ public NodeListOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public TypeArguments(final NodeToken n0, final TypeArgument n1, final NodeListOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public TypeArguments(final TypeArgument n0, final NodeListOptional n1) { f0 = new NodeToken("<"); f1 = n0; f2 = n1; f3 = new NodeToken(">"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/JavaCCOptions.java0000644000175000017500000000330411416555700022337 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production JavaCCOptions:
* Corresponding grammar :
* f0 -> [ #0 "options" #1 "{"
* .. .. . #2 ( OptionBinding() )* #3 "}" ]
*/ public class JavaCCOptions implements INode { /** A child node */ public NodeOptional f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public JavaCCOptions(final NodeOptional n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ForUpdate.java0000644000175000017500000000324111416555700021565 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ForUpdate:
* Corresponding grammar :
* f0 -> StatementExpressionList()
*/ public class ForUpdate implements INode { /** A child node */ public StatementExpressionList f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ForUpdate(final StatementExpressionList n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AccessModifier.java0000644000175000017500000000331511416555700022556 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AccessModifier:
* Corresponding grammar :
* f0 -> ( %0 "public"
* .. .. | %1 "protected"
* .. .. | %2 "private" )?
*/ public class AccessModifier implements INode { /** A child node */ public NodeOptional f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public AccessModifier(final NodeOptional n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/SynchronizedStatement.java0000644000175000017500000000505411416555700024244 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production SynchronizedStatement:
* Corresponding grammar :
* f0 -> "synchronized"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Block()
*/ public class SynchronizedStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public Expression f2; /** A child node */ public NodeToken f3; /** A child node */ public Block f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public SynchronizedStatement(final NodeToken n0, final NodeToken n1, final Expression n2, final NodeToken n3, final Block n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public SynchronizedStatement(final Expression n0, final Block n1) { f0 = new NodeToken("synchronized"); f1 = new NodeToken("("); f2 = n0; f3 = new NodeToken(")"); f4 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeArgument.java0000644000175000017500000000332011416555700022316 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeArgument:
* Corresponding grammar :
* f0 -> . %0 ReferenceType()
* .. .. | %1 #0 "?"
* .. .. . .. #1 [ WildcardBounds() ]
*/ public class TypeArgument implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public TypeArgument(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ArrayInitializer.java0000644000175000017500000000470211416555700023161 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ArrayInitializer:
* Corresponding grammar :
* f0 -> "{"
* f1 -> [ #0 VariableInitializer()
* .. .. . #1 ( $0 "," $1 VariableInitializer() )* ]
* f2 -> [ "," ]
* f3 -> "}"
*/ public class ArrayInitializer implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public ArrayInitializer(final NodeToken n0, final NodeOptional n1, final NodeOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public ArrayInitializer(final NodeOptional n0, final NodeOptional n1) { f0 = new NodeToken("{"); f1 = n0; f2 = n1; f3 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/CastLookahead.java0000644000175000017500000000401111416555700022372 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production CastLookahead:
* Corresponding grammar :
* f0 -> . %0 #0 "(" #1 PrimitiveType()
* .. .. | %1 #0 "(" #1 Type() #2 "[" #3 "]"
* .. .. | %2 #0 "(" #1 Type() #2 ")"
* .. .. . .. #3 ( &0 "~"
* .. .. . .. .. | &1 "!"
* .. .. . .. .. | &2 "("
* .. .. . .. .. | &3 < IDENTIFIER >
* .. .. . .. .. | &4 "this"
* .. .. . .. .. | &5 "super"
* .. .. . .. .. | &6 "new"
* .. .. . .. .. | &7 Literal() )
*/ public class CastLookahead implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public CastLookahead(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/IntegerLiteral.java0000644000175000017500000000321611416555700022610 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production IntegerLiteral:
* Corresponding grammar :
* f0 -> < INTEGER_LITERAL >
*/ public class IntegerLiteral implements INode { /** A child node */ public NodeToken f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public IntegerLiteral(final NodeToken n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/CharacterList.java0000644000175000017500000000466611416555700022440 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production CharacterList:
* Corresponding grammar :
* f0 -> [ "~" ]
* f1 -> "["
* f2 -> [ #0 CharacterDescriptor()
* .. .. . #1 ( $0 "," $1 CharacterDescriptor() )* ]
* f3 -> "]"
*/ public class CharacterList implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public CharacterList(final NodeOptional n0, final NodeToken n1, final NodeOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public CharacterList(final NodeOptional n0, final NodeOptional n1) { f0 = n0; f1 = new NodeToken("["); f2 = n1; f3 = new NodeToken("]"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RegularExpression.java0000644000175000017500000000362111416555700023357 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RegularExpression:
* Corresponding grammar :
* f0 -> . %0 StringLiteral()
* .. .. | %1 #0 < LANGLE : "<" >
* .. .. . .. #1 [ $0 [ "#" ] $1 Identifier() $2 ":" ] #2 ComplexRegularExpressionChoices() #3 < RANGLE : ">" >
* .. .. | %2 #0 "<" #1 Identifier() #2 ">"
* .. .. | %3 #0 "<" #1 "EOF" #2 ">"
*/ public class RegularExpression implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public RegularExpression(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RUNSIGNEDSHIFT.java0000644000175000017500000000415111416555700022031 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RUNSIGNEDSHIFT:
* Corresponding grammar :
* f0 -> ">"
* f1 -> ">"
* f2 -> ">"
*/ public class RUNSIGNEDSHIFT implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public RUNSIGNEDSHIFT(final NodeToken n0, final NodeToken n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * */ public RUNSIGNEDSHIFT() { f0 = new NodeToken(">"); f1 = new NodeToken(">"); f2 = new NodeToken(">"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Modifiers.java0000644000175000017500000000377211416555700021626 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Modifiers:
* Corresponding grammar :
* f0 -> ( ( %00 "public"
* .. .. . | %01 "static"
* .. .. . | %02 "protected"
* .. .. . | %03 "private"
* .. .. . | %04 "final"
* .. .. . | %05 "abstract"
* .. .. . | %06 "synchronized"
* .. .. . | %07 "native"
* .. .. . | %08 "transient"
* .. .. . | %09 "volatile"
* .. .. . | %10 "strictfp"
* .. .. . | %11 Annotation() ) )*
*/ public class Modifiers implements INode { /** A child node */ public NodeListOptional f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Modifiers(final NodeListOptional n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ClassOrInterfaceType.java0000644000175000017500000000402411416555700023725 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ClassOrInterfaceType:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> [ TypeArguments() ]
* f2 -> ( #0 "." #1 < IDENTIFIER >
* .. .. . #2 [ TypeArguments() ] )*
*/ public class ClassOrInterfaceType implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ClassOrInterfaceType(final NodeToken n0, final NodeOptional n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/UnaryExpressionNotPlusMinus.java0000644000175000017500000000346511416555700025423 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production UnaryExpressionNotPlusMinus:
* Corresponding grammar :
* f0 -> . %0 #0 ( &0 "~"
* .. .. . .. .. | &1 "!" ) #1 UnaryExpression()
* .. .. | %1 CastExpression()
* .. .. | %2 PostfixExpression()
*/ public class UnaryExpressionNotPlusMinus implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public UnaryExpressionNotPlusMinus(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MethodDeclarator.java0000644000175000017500000000373511416555700023125 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MethodDeclarator:
* Corresponding grammar :
* f0 -> < IDENTIFIER >
* f1 -> FormalParameters()
* f2 -> ( #0 "[" #1 "]" )*
*/ public class MethodDeclarator implements INode { /** A child node */ public NodeToken f0; /** A child node */ public FormalParameters f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public MethodDeclarator(final NodeToken n0, final FormalParameters n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/SwitchStatement.java0000644000175000017500000000564611416555700023035 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production SwitchStatement:
* Corresponding grammar :
* f0 -> "switch"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> "{"
* f5 -> ( #0 SwitchLabel()
* .. .. . #1 ( BlockStatement() )* )*
* f6 -> "}"
*/ public class SwitchStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public Expression f2; /** A child node */ public NodeToken f3; /** A child node */ public NodeToken f4; /** A child node */ public NodeListOptional f5; /** A child node */ public NodeToken f6; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node */ public SwitchStatement(final NodeToken n0, final NodeToken n1, final Expression n2, final NodeToken n3, final NodeToken n4, final NodeListOptional n5, final NodeToken n6) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public SwitchStatement(final Expression n0, final NodeListOptional n1) { f0 = new NodeToken("switch"); f1 = new NodeToken("("); f2 = n0; f3 = new NodeToken(")"); f4 = new NodeToken("{"); f5 = n1; f6 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/FormalParameters.java0000644000175000017500000000434611416555700023147 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production FormalParameters:
* Corresponding grammar :
* f0 -> "("
* f1 -> [ #0 FormalParameter()
* .. .. . #1 ( $0 "," $1 FormalParameter() )* ]
* f2 -> ")"
*/ public class FormalParameters implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public FormalParameters(final NodeToken n0, final NodeOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public FormalParameters(final NodeOptional n0) { f0 = new NodeToken("("); f1 = n0; f2 = new NodeToken(")"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExtendsList.java0000644000175000017500000000443311416555700022146 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExtendsList:
* Corresponding grammar :
* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "," #1 ClassOrInterfaceType() )*
*/ public class ExtendsList implements INode { /** A child node */ public NodeToken f0; /** A child node */ public ClassOrInterfaceType f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ExtendsList(final NodeToken n0, final ClassOrInterfaceType n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public ExtendsList(final ClassOrInterfaceType n0, final NodeListOptional n1) { f0 = new NodeToken("extends"); f1 = n0; f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TypeBound.java0000644000175000017500000000442311416555700021610 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TypeBound:
* Corresponding grammar :
* f0 -> "extends"
* f1 -> ClassOrInterfaceType()
* f2 -> ( #0 "&" #1 ClassOrInterfaceType() )*
*/ public class TypeBound implements INode { /** A child node */ public NodeToken f0; /** A child node */ public ClassOrInterfaceType f1; /** A child node */ public NodeListOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public TypeBound(final NodeToken n0, final ClassOrInterfaceType n1, final NodeListOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public TypeBound(final ClassOrInterfaceType n0, final NodeListOptional n1) { f0 = new NodeToken("extends"); f1 = n0; f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/BreakStatement.java0000644000175000017500000000425411416555700022612 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production BreakStatement:
* Corresponding grammar :
* f0 -> "break"
* f1 -> [ < IDENTIFIER > ]
* f2 -> ";"
*/ public class BreakStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public BreakStatement(final NodeToken n0, final NodeOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public BreakStatement(final NodeOptional n0) { f0 = new NodeToken("break"); f1 = n0; f2 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeSequence.java0000644000175000017500000000675511416555700022267 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; import java.util.*; /** * Represents a sequence of nodes (x y z ...) nested within a choice (|), list (+), * optional list (*), or optional node (? or []), e.g. ' ( A B )+ ' or ' [ C D E ] '.
* The class stores the nodes list in an ArrayList. */ public class NodeSequence implements INodeList { /** The list of nodes */ public ArrayList nodes; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Initializes an empty {@link NodeSequence} with a default allocation. */ public NodeSequence() { nodes = new ArrayList(); } /** * Initializes an empty {@link NodeSequence} with a given allocation. * * @param sz the list size */ public NodeSequence(final int sz) { nodes = new ArrayList(sz); } /** * Initializes an empty {@link NodeSequence} with a default allocation and adds a first node. * * @param firstNode the node to add */ public NodeSequence(final INode firstNode) { nodes = new ArrayList(); addNode(firstNode); } /** * Initializes an empty {@link NodeSequence} with a given allocation and adds a first node. * * @param sz the list size * @param firstNode the node to add */ public NodeSequence(final int sz, final INode firstNode) { nodes = new ArrayList(sz); addNode(firstNode); } /** * Adds a node to the {@link NodeSequence}. * * @param n the node to add */ public void addNode(final INode n) { nodes.add(n); } /** * Gets the node in the list at a given position. * * @param i the node's position * @return the node */ public INode elementAt(final int i) { return nodes.get(i); } /** * Returns an iterator on the nodes list. * * @return the iterator */ public Iterator elements() { return nodes.iterator(); } /** * Returns the number of nodes in the list. * * @return the list size */ public int size() { return nodes.size(); } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/StatementExpression.java0000644000175000017500000000360411416555700023723 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production StatementExpression:
* Corresponding grammar :
* f0 -> . %0 PreIncrementExpression()
* .. .. | %1 PreDecrementExpression()
* .. .. | %2 #0 PrimaryExpression()
* .. .. . .. #1 [ &0 "++"
* .. .. . .. .. | &1 "--"
* .. .. . .. .. | &2 $0 AssignmentOperator() $1 Expression() ]
*/ public class StatementExpression implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public StatementExpression(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/WhileStatement.java0000644000175000017500000000502211416555700022630 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production WhileStatement:
* Corresponding grammar :
* f0 -> "while"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
*/ public class WhileStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public Expression f2; /** A child node */ public NodeToken f3; /** A child node */ public Statement f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public WhileStatement(final NodeToken n0, final NodeToken n1, final Expression n2, final NodeToken n3, final Statement n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public WhileStatement(final Expression n0, final Statement n1) { f0 = new NodeToken("while"); f1 = new NodeToken("("); f2 = n0; f3 = new NodeToken(")"); f4 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeToken.java0000644000175000017500000001336411416555700021571 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; import java.util.*; /** * Represents a single token in the grammar.
* If the "-tk" option is used, also contains a ArrayList of preceding special tokens.
* The class stores the token image, kind and position information, and the special tokens list.
*/ public class NodeToken implements INode { /** The token image */ public String tokenImage; /** The list of special tokens */ public ArrayList specialTokens; /** The token first line (-1 means not available) */ public int beginLine; /** The token first column (-1 means not available) */ public int beginColumn; /** The token last line (-1 means not available) */ public int endLine; /** The token last column (-1 means not available) */ public int endColumn; /** The JavaCC token "kind" integer (-1 means not available) */ public int kind; /** The serial version uid */ private static final long serialVersionUID = 144L; /** The OS line separator */ public static final String LS = System.getProperty("line.separator"); /** * Initializes a {@link NodeToken} with a given string and no position information. * * @param s the token string */ public NodeToken(String s) { this(s, -1, -1, -1, -1, -1); } /** * Initializes a {@link NodeToken} with a given string and position information. * * @param s the token string * @param kn the token kind * @param bl the first line * @param bc the first column * @param el the last line * @param ec the last column */ public NodeToken(String s, final int kn, final int bl, final int bc, final int el, final int ec) { tokenImage = s; specialTokens = null; kind = kn; beginLine = bl; beginColumn = bc; endLine = el; endColumn = ec; } /** * Gets the special token in the special tokens list at a given position. * * @param i the special token's position * @return the special token */ public NodeToken getSpecialAt(final int i) { if (specialTokens == null) throw new NoSuchElementException("No specialTokens in token"); return specialTokens.get(i); } /** * @return the number of special tokens */ public int numSpecials() { if (specialTokens == null) return 0; return specialTokens.size(); } /** * Adds a special token to the special tokens list. * * @param s the special token to add */ public void addSpecial(final NodeToken s) { if (specialTokens == null) specialTokens = new ArrayList(); specialTokens.add(s); } /** * Trims the special tokens list. */ public void trimSpecials() { if (specialTokens == null) return; specialTokens.trimToSize(); } /** * @return the token image */ @Override public String toString() { return tokenImage; } /** * Returns the list of special tokens of the current {@link NodeToken} as a string,
* taking in account a given indentation. * * @param spc the indentation * @return the string representing the special tokens list */ public String getSpecials(final String spc) { if (specialTokens == null) return ""; StringBuilder buf = new StringBuilder(64); for (final Iterator e = specialTokens.iterator(); e.hasNext();) { final String s = e.next().tokenImage; final int p = s.length() - 1; final char c = s.charAt(p); buf.append(s); // TODO modifier specials pour inclure fins de ligne if (c == '\n' || c == '\r') buf.append(spc); else buf.append(LS).append(spc); } return buf.toString(); } /** * Returns the list of special tokens of the current {@link NodeToken} and the current
* {@link NodeToken} as a string, taking in account a given indentation. * * @param spc the indentation * @return the string representing the special tokens list and the token */ public String withSpecials(final String spc) { final String specials = getSpecials(spc); final int len = specials.length(); if (len == 0) return tokenImage; StringBuilder buf = new StringBuilder(len + tokenImage.length()); buf.append(specials).append(tokenImage); return buf.toString(); } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/VariableInitializer.java0000644000175000017500000000330311416555700023624 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production VariableInitializer:
* Corresponding grammar :
* f0 -> . %0 ArrayInitializer()
* .. .. | %1 Expression()
*/ public class VariableInitializer implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public VariableInitializer(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/BlockStatement.java0000644000175000017500000000336611416555700022623 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production BlockStatement:
* Corresponding grammar :
* f0 -> . %0 #0 LocalVariableDeclaration() #1 ";"
* .. .. | %1 Statement()
* .. .. | %2 ClassOrInterfaceDeclaration()
*/ public class BlockStatement implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public BlockStatement(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AssertStatement.java0000644000175000017500000000461511416555700023030 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AssertStatement:
* Corresponding grammar :
* f0 -> "assert"
* f1 -> Expression()
* f2 -> [ #0 ":" #1 Expression() ]
* f3 -> ";"
*/ public class AssertStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Expression f1; /** A child node */ public NodeOptional f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public AssertStatement(final NodeToken n0, final Expression n1, final NodeOptional n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public AssertStatement(final Expression n0, final NodeOptional n1) { f0 = new NodeToken("assert"); f1 = n0; f2 = n1; f3 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/BNFProduction.java0000644000175000017500000000722111416555700022352 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production BNFProduction:
* Corresponding grammar :
* f0 -> AccessModifier()
* f1 -> ResultType()
* f2 -> Identifier()
* f3 -> FormalParameters()
* f4 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f5 -> ":"
* f6 -> Block()
* f7 -> "{"
* f8 -> ExpansionChoices()
* f9 -> "}"
*/ public class BNFProduction implements INode { /** A child node */ public AccessModifier f0; /** A child node */ public ResultType f1; /** A child node */ public Identifier f2; /** A child node */ public FormalParameters f3; /** A child node */ public NodeOptional f4; /** A child node */ public NodeToken f5; /** A child node */ public Block f6; /** A child node */ public NodeToken f7; /** A child node */ public ExpansionChoices f8; /** A child node */ public NodeToken f9; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node * @param n7 next child node * @param n8 next child node * @param n9 next child node */ public BNFProduction(final AccessModifier n0, final ResultType n1, final Identifier n2, final FormalParameters n3, final NodeOptional n4, final NodeToken n5, final Block n6, final NodeToken n7, final ExpansionChoices n8, final NodeToken n9) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; f7 = n7; f8 = n8; f9 = n9; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node */ public BNFProduction(final AccessModifier n0, final ResultType n1, final Identifier n2, final FormalParameters n3, final NodeOptional n4, final Block n5, final ExpansionChoices n6) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = new NodeToken(":"); f6 = n5; f7 = new NodeToken("{"); f8 = n6; f9 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PostfixExpression.java0000644000175000017500000000353411416555700023415 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PostfixExpression:
* Corresponding grammar :
* f0 -> PrimaryExpression()
* f1 -> [ %0 "++"
* .. .. | %1 "--" ]
*/ public class PostfixExpression implements INode { /** A child node */ public PrimaryExpression f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public PostfixExpression(final PrimaryExpression n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PreDecrementExpression.java0000644000175000017500000000406311416555700024334 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PreDecrementExpression:
* Corresponding grammar :
* f0 -> "--"
* f1 -> PrimaryExpression()
*/ public class PreDecrementExpression implements INode { /** A child node */ public NodeToken f0; /** A child node */ public PrimaryExpression f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public PreDecrementExpression(final NodeToken n0, final PrimaryExpression n1) { f0 = n0; f1 = n1; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public PreDecrementExpression(final PrimaryExpression n0) { f0 = new NodeToken("--"); f1 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/EnumDeclaration.java0000644000175000017500000000465211416555700022755 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production EnumDeclaration:
* Corresponding grammar :
* f0 -> "enum"
* f1 -> < IDENTIFIER >
* f2 -> [ ImplementsList() ]
* f3 -> EnumBody()
*/ public class EnumDeclaration implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeOptional f2; /** A child node */ public EnumBody f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public EnumDeclaration(final NodeToken n0, final NodeToken n1, final NodeOptional n2, final EnumBody n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public EnumDeclaration(final NodeToken n0, final NodeOptional n1, final EnumBody n2) { f0 = new NodeToken("enum"); f1 = n0; f2 = n1; f3 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ArrayDimsAndInits.java0000644000175000017500000000343011416555700023221 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ArrayDimsAndInits:
* Corresponding grammar :
* f0 -> . %0 #0 ( $0 "[" $1 Expression() $2 "]" )+
* .. .. . .. #1 ( $0 "[" $1 "]" )*
* .. .. | %1 #0 ( $0 "[" $1 "]" )+ #1 ArrayInitializer()
*/ public class ArrayDimsAndInits implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public ArrayDimsAndInits(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/SwitchLabel.java0000644000175000017500000000330011416555700022071 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production SwitchLabel:
* Corresponding grammar :
* f0 -> . %0 #0 "case" #1 Expression() #2 ":"
* .. .. | %1 #0 "default" #1 ":"
*/ public class SwitchLabel implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public SwitchLabel(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AnnotationTypeBody.java0000644000175000017500000000432411416555700023471 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AnnotationTypeBody:
* Corresponding grammar :
* f0 -> "{"
* f1 -> ( AnnotationTypeMemberDeclaration() )*
* f2 -> "}"
*/ public class AnnotationTypeBody implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeListOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public AnnotationTypeBody(final NodeToken n0, final NodeListOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public AnnotationTypeBody(final NodeListOptional n0) { f0 = new NodeToken("{"); f1 = n0; f2 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/TryStatement.java0000644000175000017500000000473311416555700022346 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production TryStatement:
* Corresponding grammar :
* f0 -> "try"
* f1 -> Block()
* f2 -> ( #0 "catch" #1 "(" #2 FormalParameter() #3 ")" #4 Block() )*
* f3 -> [ #0 "finally" #1 Block() ]
*/ public class TryStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Block f1; /** A child node */ public NodeListOptional f2; /** A child node */ public NodeOptional f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public TryStatement(final NodeToken n0, final Block n1, final NodeListOptional n2, final NodeOptional n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public TryStatement(final Block n0, final NodeListOptional n1, final NodeOptional n2) { f0 = new NodeToken("try"); f1 = n0; f2 = n1; f3 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Expansion.java0000644000175000017500000000350511416555700021643 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Expansion:
* Corresponding grammar :
* f0 -> ( #0 "LOOKAHEAD" #1 "(" #2 LocalLookahead() #3 ")" )?
* f1 -> ( ExpansionUnit() )+
*/ public class Expansion implements INode { /** A child node */ public NodeOptional f0; /** A child node */ public NodeList f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public Expansion(final NodeOptional n0, final NodeList n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AnnotationTypeMemberDeclaration.java0000644000175000017500000000403711416555700026152 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AnnotationTypeMemberDeclaration:
* Corresponding grammar :
* f0 -> . %0 #0 Modifiers()
* .. .. . .. #1 ( &0 $0 Type() $1 < IDENTIFIER > $2 "(" $3 ")"
* .. .. . .. .. $4 [ DefaultValue() ] $5 ";"
* .. .. . .. .. | &1 ClassOrInterfaceDeclaration()
* .. .. . .. .. | &2 EnumDeclaration()
* .. .. . .. .. | &3 AnnotationTypeDeclaration()
* .. .. . .. .. | &4 FieldDeclaration() )
* .. .. | %1 ";"
*/ public class AnnotationTypeMemberDeclaration implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public AnnotationTypeMemberDeclaration(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/JavaCCInput.java0000644000175000017500000000726211416555700022012 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production JavaCCInput:
* Corresponding grammar :
* f0 -> JavaCCOptions()
* f1 -> "PARSER_BEGIN"
* f2 -> "("
* f3 -> Identifier()
* f4 -> ")"
* f5 -> CompilationUnit()
* f6 -> "PARSER_END"
* f7 -> "("
* f8 -> Identifier()
* f9 -> ")"
* f10 -> ( Production() )+
*/ public class JavaCCInput implements INode { /** A child node */ public JavaCCOptions f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeToken f2; /** A child node */ public Identifier f3; /** A child node */ public NodeToken f4; /** A child node */ public CompilationUnit f5; /** A child node */ public NodeToken f6; /** A child node */ public NodeToken f7; /** A child node */ public Identifier f8; /** A child node */ public NodeToken f9; /** A child node */ public NodeList f10; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node * @param n7 next child node * @param n8 next child node * @param n9 next child node * @param n10 next child node */ public JavaCCInput(final JavaCCOptions n0, final NodeToken n1, final NodeToken n2, final Identifier n3, final NodeToken n4, final CompilationUnit n5, final NodeToken n6, final NodeToken n7, final Identifier n8, final NodeToken n9, final NodeList n10) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; f7 = n7; f8 = n8; f9 = n9; f10 = n10; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public JavaCCInput(final JavaCCOptions n0, final Identifier n1, final CompilationUnit n2, final Identifier n3, final NodeList n4) { f0 = n0; f1 = new NodeToken("PARSER_BEGIN"); f2 = new NodeToken("("); f3 = n1; f4 = new NodeToken(")"); f5 = n2; f6 = new NodeToken("PARSER_END"); f7 = new NodeToken("("); f8 = n3; f9 = new NodeToken(")"); f10 = n4; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Block.java0000644000175000017500000000421711416555700020732 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Block:
* Corresponding grammar :
* f0 -> "{"
* f1 -> ( BlockStatement() )*
* f2 -> "}"
*/ public class Block implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeListOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public Block(final NodeToken n0, final NodeListOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public Block(final NodeListOptional n0) { f0 = new NodeToken("{"); f1 = n0; f2 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ClassOrInterfaceBody.java0000644000175000017500000000433411416555700023705 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ClassOrInterfaceBody:
* Corresponding grammar :
* f0 -> "{"
* f1 -> ( ClassOrInterfaceBodyDeclaration() )*
* f2 -> "}"
*/ public class ClassOrInterfaceBody implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeListOptional f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ClassOrInterfaceBody(final NodeToken n0, final NodeListOptional n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node */ public ClassOrInterfaceBody(final NodeListOptional n0) { f0 = new NodeToken("{"); f1 = n0; f2 = new NodeToken("}"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NodeList.java0000644000175000017500000000737111416555700021425 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.IRetArguVisitor; import EDU.purdue.jtb.visitor.IRetVisitor; import EDU.purdue.jtb.visitor.IVoidArguVisitor; import EDU.purdue.jtb.visitor.IVoidVisitor; import java.util.*; /** * Represents a grammar list (+), e.g. ' ( A )+ '.
* The class stores the nodes list in an ArrayList. */ public class NodeList implements INodeList { /** The list of nodes */ public ArrayList nodes; /** The allocation sizes table */ private static final int allocTb[] = {1, 2, 3, 4, 5, 10, 20, 50}; /** The allocation number */ private int allocNb = 0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Initializes an empty list of nodes with a default first allocation. */ public NodeList() { nodes = new ArrayList(allocTb[allocNb]); } /** * Initializes an empty list of nodes with a given allocation. * * @param sz the list size */ public NodeList(final int sz) { nodes = new ArrayList(sz); } /** * Initializes an empty list of nodes with a default first allocation and adds a first node. * * @param firstNode the node to add */ public NodeList(final INode firstNode) { nodes = new ArrayList(allocTb[allocNb]); addNode(firstNode); } /** * Initializes an empty list of nodes with a given allocation and adds a first node. * * @param sz the list size * @param firstNode the node to add */ public NodeList(final int sz, final INode firstNode) { nodes = new ArrayList(sz); addNode(firstNode); } /** * Adds a node to the list of nodes, managing progressive allocation increments. * * @param n the node to add */ public void addNode(final INode n) { if (++allocNb < allocTb.length) nodes.ensureCapacity(allocTb[allocNb]); else nodes.ensureCapacity((allocNb - allocTb.length + 2) * allocTb[(allocTb.length - 1)]); nodes.add(n); } /** * Gets the node in the list at a given position. * * @param i the node's position * @return the node */ public INode elementAt(final int i) { return nodes.get(i); } /** * Returns an iterator on the nodes list. * * @return the iterator */ public Iterator elements() { return nodes.iterator(); } /** * Returns the number of nodes in the list. * * @return the list size */ public int size() { return nodes.size(); } /** * Accepts a {@link IRetArguVisitor} visitor with user Return and Argument data. * * @param the user Return type * @param
the user Argument type * @param vis the visitor * @param argu the user Argument data * @return the user Return data */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts a {@link IRetVisitor} visitor with user Return data. * * @param the user Return type * @param vis the visitor * @return the user Return data */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts a {@link IVoidArguVisitor} visitor with user Argument data. * * @param the user Argument type * @param vis the visitor * @param argu the user Argument data */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts a {@link IVoidVisitor} visitor with no user Return nor Argument data. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/JavaCodeProduction.java0000644000175000017500000000620211416555700023417 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production JavaCodeProduction:
* Corresponding grammar :
* f0 -> "JAVACODE"
* f1 -> AccessModifier()
* f2 -> ResultType()
* f3 -> Identifier()
* f4 -> FormalParameters()
* f5 -> [ #0 "throws" #1 Name()
* .. .. . #2 ( $0 "," $1 Name() )* ]
* f6 -> Block()
*/ public class JavaCodeProduction implements INode { /** A child node */ public NodeToken f0; /** A child node */ public AccessModifier f1; /** A child node */ public ResultType f2; /** A child node */ public Identifier f3; /** A child node */ public FormalParameters f4; /** A child node */ public NodeOptional f5; /** A child node */ public Block f6; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node * @param n6 next child node */ public JavaCodeProduction(final NodeToken n0, final AccessModifier n1, final ResultType n2, final Identifier n3, final FormalParameters n4, final NodeOptional n5, final Block n6) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; f6 = n6; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node */ public JavaCodeProduction(final AccessModifier n0, final ResultType n1, final Identifier n2, final FormalParameters n3, final NodeOptional n4, final Block n5) { f0 = new NodeToken("JAVACODE"); f1 = n0; f2 = n1; f3 = n2; f4 = n3; f5 = n4; f6 = n5; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/NormalAnnotation.java0000644000175000017500000000501611416555700023161 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production NormalAnnotation:
* Corresponding grammar :
* f0 -> "@"
* f1 -> Name()
* f2 -> "("
* f3 -> [ MemberValuePairs() ]
* f4 -> ")"
*/ public class NormalAnnotation implements INode { /** A child node */ public NodeToken f0; /** A child node */ public Name f1; /** A child node */ public NodeToken f2; /** A child node */ public NodeOptional f3; /** A child node */ public NodeToken f4; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node */ public NormalAnnotation(final NodeToken n0, final Name n1, final NodeToken n2, final NodeOptional n3, final NodeToken n4) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public NormalAnnotation(final Name n0, final NodeOptional n1) { f0 = new NodeToken("@"); f1 = n0; f2 = new NodeToken("("); f3 = n1; f4 = new NodeToken(")"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/RegExprSpec.java0000644000175000017500000000372611416555700022073 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production RegExprSpec:
* Corresponding grammar :
* f0 -> RegularExpression()
* f1 -> [ Block() ]
* f2 -> [ #0 ":" #1 < IDENTIFIER > ]
*/ public class RegExprSpec implements INode { /** A child node */ public RegularExpression f0; /** A child node */ public NodeOptional f1; /** A child node */ public NodeOptional f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public RegExprSpec(final RegularExpression n0, final NodeOptional n1, final NodeOptional n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Name.java0000644000175000017500000000346011416555700020557 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Name:
* Corresponding grammar :
* f0 -> JavaIdentifier()
* f1 -> ( #0 "." #1 JavaIdentifier() )*
*/ public class Name implements INode { /** A child node */ public JavaIdentifier f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public Name(final JavaIdentifier n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExpansionUnitInTCF.java0000644000175000017500000000555411416555700023335 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExpansionUnitInTCF:
* Corresponding grammar :
* f0 -> "try"
* f1 -> "{"
* f2 -> ExpansionChoices()
* f3 -> "}"
* f4 -> ( #0 "catch" #1 "(" #2 Name() #3 < IDENTIFIER > #4 ")" #5 Block() )*
* f5 -> [ #0 "finally" #1 Block() ]
*/ public class ExpansionUnitInTCF implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public ExpansionChoices f2; /** A child node */ public NodeToken f3; /** A child node */ public NodeListOptional f4; /** A child node */ public NodeOptional f5; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node */ public ExpansionUnitInTCF(final NodeToken n0, final NodeToken n1, final ExpansionChoices n2, final NodeToken n3, final NodeListOptional n4, final NodeOptional n5) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public ExpansionUnitInTCF(final ExpansionChoices n0, final NodeListOptional n1, final NodeOptional n2) { f0 = new NodeToken("try"); f1 = new NodeToken("{"); f2 = n0; f3 = new NodeToken("}"); f4 = n1; f5 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/VariableDeclarator.java0000644000175000017500000000355011416555700023425 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production VariableDeclarator:
* Corresponding grammar :
* f0 -> VariableDeclaratorId()
* f1 -> [ #0 "=" #1 VariableInitializer() ]
*/ public class VariableDeclarator implements INode { /** A child node */ public VariableDeclaratorId f0; /** A child node */ public NodeOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public VariableDeclarator(final VariableDeclaratorId n0, final NodeOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PackageDeclaration.java0000644000175000017500000000460611416555700023403 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PackageDeclaration:
* Corresponding grammar :
* f0 -> ( Annotation() )*
* f1 -> "package"
* f2 -> Name()
* f3 -> ";"
*/ public class PackageDeclaration implements INode { /** A child node */ public NodeListOptional f0; /** A child node */ public NodeToken f1; /** A child node */ public Name f2; /** A child node */ public NodeToken f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public PackageDeclaration(final NodeListOptional n0, final NodeToken n1, final Name n2, final NodeToken n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public PackageDeclaration(final NodeListOptional n0, final Name n1) { f0 = n0; f1 = new NodeToken("package"); f2 = n1; f3 = new NodeToken(";"); } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/MemberSelector.java0000644000175000017500000000432311416555700022606 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production MemberSelector:
* Corresponding grammar :
* f0 -> "."
* f1 -> TypeArguments()
* f2 -> < IDENTIFIER >
*/ public class MemberSelector implements INode { /** A child node */ public NodeToken f0; /** A child node */ public TypeArguments f1; /** A child node */ public NodeToken f2; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public MemberSelector(final NodeToken n0, final TypeArguments n1, final NodeToken n2) { f0 = n0; f1 = n1; f2 = n2; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public MemberSelector(final TypeArguments n0, final NodeToken n1) { f0 = new NodeToken("."); f1 = n0; f2 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/Production.java0000644000175000017500000000337711416555700022034 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production Production:
* Corresponding grammar :
* f0 -> . %0 JavaCodeProduction()
* .. .. | %1 RegularExprProduction()
* .. .. | %2 TokenManagerDecls()
* .. .. | %3 BNFProduction()
*/ public class Production implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public Production(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PrimaryPrefix.java0000644000175000017500000000360311416555700022477 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PrimaryPrefix:
* Corresponding grammar :
* f0 -> . %0 Literal()
* .. .. | %1 "this"
* .. .. | %2 #0 "super" #1 "." #2 < IDENTIFIER >
* .. .. | %3 #0 "(" #1 Expression() #2 ")"
* .. .. | %4 AllocationExpression()
* .. .. | %5 #0 ResultType() #1 "." #2 "class"
* .. .. | %6 Name()
*/ public class PrimaryPrefix implements INode { /** A child node */ public NodeChoice f0; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with its child node. * * @param n0 the child node */ public PrimaryPrefix(final NodeChoice n0) { f0 = n0; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ConditionalAndExpression.java0000644000175000017500000000361111416555700024643 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ConditionalAndExpression:
* Corresponding grammar :
* f0 -> InclusiveOrExpression()
* f1 -> ( #0 "&&" #1 InclusiveOrExpression() )*
*/ public class ConditionalAndExpression implements INode { /** A child node */ public InclusiveOrExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ConditionalAndExpression(final InclusiveOrExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/PrimaryExpression.java0000644000175000017500000000351111416555700023377 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production PrimaryExpression:
* Corresponding grammar :
* f0 -> PrimaryPrefix()
* f1 -> ( PrimarySuffix() )*
*/ public class PrimaryExpression implements INode { /** A child node */ public PrimaryPrefix f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public PrimaryExpression(final PrimaryPrefix n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AnnotationTypeDeclaration.java0000644000175000017500000000470611416555700025025 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AnnotationTypeDeclaration:
* Corresponding grammar :
* f0 -> "@"
* f1 -> "interface"
* f2 -> < IDENTIFIER >
* f3 -> AnnotationTypeBody()
*/ public class AnnotationTypeDeclaration implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public NodeToken f2; /** A child node */ public AnnotationTypeBody f3; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node */ public AnnotationTypeDeclaration(final NodeToken n0, final NodeToken n1, final NodeToken n2, final AnnotationTypeBody n3) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node */ public AnnotationTypeDeclaration(final NodeToken n0, final AnnotationTypeBody n1) { f0 = new NodeToken("@"); f1 = new NodeToken("interface"); f2 = n0; f3 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/IfStatement.java0000644000175000017500000000535111416555700022123 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production IfStatement:
* Corresponding grammar :
* f0 -> "if"
* f1 -> "("
* f2 -> Expression()
* f3 -> ")"
* f4 -> Statement()
* f5 -> [ #0 "else" #1 Statement() ]
*/ public class IfStatement implements INode { /** A child node */ public NodeToken f0; /** A child node */ public NodeToken f1; /** A child node */ public Expression f2; /** A child node */ public NodeToken f3; /** A child node */ public Statement f4; /** A child node */ public NodeOptional f5; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node * @param n2 next child node * @param n3 next child node * @param n4 next child node * @param n5 next child node */ public IfStatement(final NodeToken n0, final NodeToken n1, final Expression n2, final NodeToken n3, final Statement n4, final NodeOptional n5) { f0 = n0; f1 = n1; f2 = n2; f3 = n3; f4 = n4; f5 = n5; } /** * Constructs the node with only its non NodeToken child node(s). * * @param n0 first child node * @param n1 next child node * @param n2 next child node */ public IfStatement(final Expression n0, final Statement n1, final NodeOptional n2) { f0 = new NodeToken("if"); f1 = new NodeToken("("); f2 = n0; f3 = new NodeToken(")"); f4 = n1; f5 = n2; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/ExclusiveOrExpression.java0000644000175000017500000000353711416555700024234 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production ExclusiveOrExpression:
* Corresponding grammar :
* f0 -> AndExpression()
* f1 -> ( #0 "^" #1 AndExpression() )*
*/ public class ExclusiveOrExpression implements INode { /** A child node */ public AndExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public ExclusiveOrExpression(final AndExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/EDU/purdue/jtb/syntaxtree/AdditiveExpression.java0000644000175000017500000000364511416555700023515 0ustar cavedoncavedon/* Generated by JTB 1.4.4 */ package EDU.purdue.jtb.syntaxtree; import EDU.purdue.jtb.visitor.*; /** * JTB node class for the production AdditiveExpression:
* Corresponding grammar :
* f0 -> MultiplicativeExpression()
* f1 -> ( #0 ( %0 "+"
* .. .. . .. | %1 "-" ) #1 MultiplicativeExpression() )*
*/ public class AdditiveExpression implements INode { /** A child node */ public MultiplicativeExpression f0; /** A child node */ public NodeListOptional f1; /** The serial version uid */ private static final long serialVersionUID = 144L; /** * Constructs the node with all its children nodes. * * @param n0 first child node * @param n1 next child node */ public AdditiveExpression(final MultiplicativeExpression n0, final NodeListOptional n1) { f0 = n0; f1 = n1; } /** * Accepts the IRetArguVisitor visitor. * * @param the user return type * @param
the user argument type * @param vis the visitor * @param argu a user chosen argument * @return a user chosen return information */ public R accept(final IRetArguVisitor vis, final A argu) { return vis.visit(this, argu); } /** * Accepts the IRetVisitor visitor. * * @param the user return type * @param vis the visitor * @return a user chosen return information */ public R accept(final IRetVisitor vis) { return vis.visit(this); } /** * Accepts the IVoidArguVisitor visitor. * * @param the user argument type * @param vis the visitor * @param argu a user chosen argument */ public void accept(final IVoidArguVisitor vis, final A argu) { vis.visit(this, argu); } /** * Accepts the IVoidVisitor visitor. * * @param vis the visitor */ public void accept(final IVoidVisitor vis) { vis.visit(this); } } jtb-1.4.4/jtb_doc.html0000644000175000017500000002113011365271440014411 0ustar cavedoncavedon JTB 1.4.3.2

Java Tree Builder (JTB) 1.4.3.2

Last update : april 26th, 2010 - version 1.4.3.2

Overview

JTB (Java Tree Builder) is a syntax tree builder and visitors generator to be used in front of
JavaCC (Java Compiler Compiler).
It takes a JavaCC grammar file as input (usually a ".jtb" file) and automatically generates the following:
  • a set of syntax tree classes based on the productions in the grammar, utilizing the Visitor design pattern;
  • four interfaces: IVoidVisitor, IVoidArguVisitor, IRetVisitor, IRetArguVisitor;
  • four depth-first visitors: DepthFirstVoidVisitor, DepthFirstVoidArguVisitor, DepthFirstRetVisitor, DepthFirstREtArguVisitor, whose default methods simply visit the children of the current node;
  • a JavaCC grammar ".jj" file (jtb.out.jj by default), with the proper annotations to build the syntax tree during parsing (which then must be compiled with JavaCC).
New visitors, which subclass any generated one, can then override the default methods and perform various operations on and manipulate the generated syntax tree.

History

04/2010 - 1.4.3.2 : bug #2991455
04/2010 - 1.4.3.1 : bugs #2990962 and #2989497
03/2010 - 1.4.3 : Fixed wrong conditionals generation and TreeFormatter generation issues; added node declarations initialization
02/2010 - 1.4.2 : Fixed missing java.util package in generated JTBToolkit class, fixed accept inlining issue in visiting ExpansionChoices
02/2010 - 1.4.1 : Fixed wrong conditionals generation and missing static modifier for generated return types issues (bug 2945965), fixed hard error in semantic checker, fixed command line options overwrite issue
11/2009 - 1.4.0 : New version delivered / integrated under the JavaCC Eclipse Plug-in
xx/2005 - 1.3.2 : Last (known) version from UCLA Compilers Group : see JTB 1.3.2 home page

New Features in version 1.4.0+

Here are the following enhancements that have been added to JTB 1.3.2:
  • Internal code
    • Internal Java code extensively refactored (performances, namings, JDK 1.5 syntax, numerous fixes, ...)
    • Internal Java code Javadoc fully revised
    • Internal parser upgraded to version 4.2 of JavaCC, with performance enhancements
    • Added Ant build files
  • Generated code
    • Renamed syntax tree and visitors interfaces and classes
    • Generated Java code extensively refactored (performances, namings, JDK 1.5 syntax, numerous fixes, ...)
    • Generated Java code Javadoc fully revised, specially with more detailed fields comments
    • Special tokens fully printed in the output file (with the -tk option)
  • User enhancements
    • Removed "only void BNFProduction result type" limitation
    • Removed "only non void JavaCodeProduction" limitation
    • Added proper handling of "PrimaryExpression() = Identifier() ... | RegularExpression() ..." syntax
    • Added a -ia option for inlining visitor accept methods on base nodes
    • Changed behavior of option -jd: now turns on printing classes, methods and fields javadoc comments
    • Added a -dl option for depth level management generation
    • Added -d, -nd & -vd options, modified -p, -pd & -vp options (to separate directories from packages)
    • Added input file options "JTB_XX" (in the "options" section of the ".jtb grammar file) corresponding to the command line options "-xx"
      i.e: JTB_O = "myout.jj" <-> -o myout.jj, JTB_TK = true <-> -tk

How to use

On the command line:
java -jar jtb-1.4.x.jar -h : to view all available options
java -jar jtb-1.4.x.jar [CL_Option] -si : to use system.in as the input file
java -jar jtb-1.4.x.jar [CL_Option] [input-file] : to use input-file as the input file

In the input file options section:
options {(JTB_BOOL_OPT=(true|false); | JTB_STR_OPT="str";)*}

Options are the following:

CL_OptionJTB_OptionDescription
-cl JTB_CL=(true|false)Print a list of the classes generated to standard out
-d dir JTB_D="dir" Short for (and overwrites) "-nd dir/syntaxtree -vd dir/visitor"
-dl JTB_DL=(true|false)Generate depth level info
-e JTB_E=(true|false) Suppress JTB semantic error checking
-f JTB_F=(true|false) Use descriptive node class field names
-h N/A Display this help message and quit
-ia JTB_IA=(true|false)Inline visitors accept methods on base classes
-jd JTB_JD=(true|false)Generate JavaDoc-friendly comments in the nodes and visitor
-nd dir JTB_ND="dir" Use dir as the package for the syntax tree nodes
-np pkg JTB_NP="pkg" Use pkg as the package for the syntax tree nodes
-ns classJTB_NS="class" Use class as the class which all node classes will extend
-o file JTB_o="file" Use file as the filename for the annotated output grammar
-p pkg JTB_P="pkg" Short for (and overwrites) "-np pkg.syntaxtree -vp pkg.visitor"
-pp JTB_PP=(true|false)Generate parent pointers in all node classes
-printer JTB_PRINTER Generate a syntax tree dumping visitor
-si N/A Read from standard input rather than a file
-scheme JTB_SCHEME Generate Scheme records representing the grammar and a Scheme tree building visitor
-tk JTB_TK=(true|false)Generate special tokens into the tree
-vd dir JTB_VD="dir" Use dir as the package for the default visitor classes
-vp pkg JTB_VP="pkg" Use pkg as the package for the default visitor classes
-w JTB_W=(true|false )Do not overwrite existing files

Note that the JavaCC Eclipse Plug-in 1.5.17+ delivers both jtb132.jar and jtb-1.4.x.jar.

Support

Feel free to report any bug or suggest enhancement at the JavaCC Eclipse Plug-in Sourceforge site.

License

JTB 1.3.2 is licensed under the BSD license.
JTB 1.4.x adds the GPL license and the CECILL license.