/jEdit/branches/concurrency/org/gjt/sp/jedit/bsh/bsh.jj
# · Unknown · 2439 lines · 2337 code · 102 blank · 0 comment · 0 complexity · b86ea8223399b8e62874ea09dd2fe1b9 MD5 · raw file
Large files are truncated click here to view the full file
- /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. src/bsh/bsh.jj */
- /*@egen*//*****************************************************************************
- * *
- * This file is part of the BeanShell Java Scripting distribution. *
- * Documentation and updates may be found at http://www.beanshell.org/ *
- * *
- * Sun Public License Notice: *
- * *
- * The contents of this file are subject to the Sun Public License Version *
- * 1.0 (the "License"); you may not use this file except in compliance with *
- * the License. A copy of the License is available at http://www.sun.com *
- * *
- * The Original Code is BeanShell. The Initial Developer of the Original *
- * Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
- * (C) 2000. All Rights Reserved. *
- * *
- * GNU Public License Notice: *
- * *
- * Alternatively, the contents of this file may be used under the terms of *
- * the GNU Lesser General Public License (the "LGPL"), in which case the *
- * provisions of LGPL are applicable instead of those above. If you wish to *
- * allow use of your version of this file only under the terms of the LGPL *
- * and not to allow others to use your version of this file under the SPL, *
- * indicate your decision by deleting the provisions above and replace *
- * them with the notice and other provisions required by the LGPL. If you *
- * do not delete the provisions above, a recipient may use your version of *
- * this file under either the SPL or the LGPL. *
- * *
- * Patrick Niemeyer (pat@pat.net) *
- * Author of Learning Java, O'Reilly & Associates *
- * http://www.pat.net/~pat/ *
- * *
- *****************************************************************************/
- /*
- Notes:
- There is probably a lot of room for improvement in here.
- All of the syntactic lookaheads have been commented with:
- SYNTACTIC_LOOKAHEAD
- These are probably expensive and we may want to start weeding them out
- where possible.
- */
- options {
- JAVA_UNICODE_ESCAPE=true;
- STATIC=false;
- /* Print grammar debugging info as we parse
- DEBUG_PARSER=true;
- */
- /* Print detailed lookahead debugging info
- DEBUG_LOOKAHEAD=true;
- */
- // Not sure exactly what this does
- ERROR_REPORTING=false;
- // This breaks something for interactive use on the command line,
- // but may be useful in non-interactive use.
- //CACHE_TOKENS=true;
- }
- PARSER_BEGIN(Parser)
- package org.gjt.sp.jedit.bsh;
- import java.io.*;
- import java.util.Vector;
- /**
- This is the BeanShell parser. It is used internally by the Interpreter
- class (which is probably what you are looking for). The parser knows
- only how to parse the structure of the language, it does not understand
- names, commands, etc.
- <p>
- You can use the Parser from the command line to do basic structural
- validation of BeanShell files without actually executing them. e.g.
- <code><pre>
- java bsh.Parser [ -p ] file [ file ] [ ... ]
- </pre></code>
- <p>
- The -p option causes the abstract syntax to be printed.
- <p>
- From code you'd use the Parser like this:
- <p
- <code><pre>
- Parser parser = new Parser(in);
- while( !(eof=parser.Line()) ) {
- SimpleNode node = parser.popNode();
- // use the node, etc. (See bsh.BSH* classes)
- }
- </pre></code>
- */
- public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/
- {/*@bgen(jjtree)*/
- protected JJTParserState jjtree = new JJTParserState();
- /*@egen*/
- boolean retainComments = false;
-
- public void setRetainComments( boolean b ) {
- retainComments = b;
- }
- void jjtreeOpenNodeScope(Node n) {
- ((SimpleNode)n).firstToken = getToken(1);
- }
- void jjtreeCloseNodeScope(Node n) {
- ((SimpleNode)n).lastToken = getToken(0);
- }
- /**
- Re-initialize the input stream and token source.
- */
- void reInitInput( Reader in ) {
- ReInit(in);
- }
- public SimpleNode popNode()
- {
- if ( jjtree.nodeArity() > 0) // number of child nodes
- return (SimpleNode)jjtree.popNode();
- else
- return null;
- }
- /**
- Explicitly re-initialize just the token reader.
- This seems to be necessary to avoid certain looping errors when
- reading bogus input. See Interpreter.
- */
- void reInitTokenInput( Reader in ) {
- jj_input_stream.ReInit( in,
- jj_input_stream.getEndLine(),
- jj_input_stream.getEndColumn() );
- }
- public static void main( String [] args )
- throws IOException, ParseException
- {
- boolean print = false;
- int i=0;
- if ( args[0].equals("-p") ) {
- i++;
- print=true;
- }
- for(; i< args.length; i++) {
- Reader in = new FileReader(args[i]);
- Parser parser = new Parser(in);
- parser.setRetainComments(true);
- while( !parser.Line()/*eof*/ )
- if ( print )
- System.out.println( parser.popNode() );
- }
- }
- /**
- Lookahead for the enhanced for statement.
- Expect "for" "(" and then see whether we hit ":" or a ";" first.
- */
- boolean isRegularForStatement()
- {
- int curTok = 1;
- Token tok;
- tok = getToken(curTok++);
- if ( tok.kind != FOR ) return false;
- tok = getToken(curTok++);
- if ( tok.kind != LPAREN ) return false;
- while (true)
- {
- tok = getToken(curTok++);
- switch (tok.kind) {
- case COLON:
- return false;
- case SEMICOLON:
- return true;
- case EOF:
- return false;
- }
- }
- }
- /**
- Generate a ParseException with the specified message, pointing to the
- current token.
- The auto-generated Parser.generateParseException() method does not
- provide line number info, therefore we do this.
- */
- ParseException createParseException( String message )
- {
- Token errortok = token;
- int line = errortok.beginLine, column = errortok.beginColumn;
- String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
- return new ParseException( "Parse error at line " + line
- + ", column " + column + " : " + message );
- }
- }
- PARSER_END(Parser)
- SKIP : /* WHITE SPACE */
- {
- " " | "\t" | "\r" | "\f"
- | "\n"
- | < NONPRINTABLE: (["\u0000"-" ", "\u0080"-"\u00ff"])+ >
- }
- SPECIAL_TOKEN : /* COMMENTS */
- {
- /*
- SINGLE_LINE_COMMENT includes a hack to accept SLC at the end of a file
- with no terminanting linefeed. This is actually illegal according to
- spec, but comes up often enough to warrant it... (especially in eval()).
- */
- <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
- | <HASH_BANG_COMMENT: "#!" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
- /* Moved FORMAL_COMMENT to a real token. Modified MULTI_LINE_COMMENT to not
- catch formal comments (require no star after star) */
- | <MULTI_LINE_COMMENT:
- "/*" (~["*"])+ "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
- }
- TOKEN : /* RESERVED WORDS AND LITERALS */
- {
- < ABSTRACT : "abstract" >
- | < BOOLEAN: "boolean" >
- | < BREAK: "break" >
- | < CLASS: "class" >
- | < BYTE: "byte" >
- | < CASE: "case" >
- | < CATCH: "catch" >
- | < CHAR: "char" >
- | < 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" >
- | < SWITCH: "switch" >
- | < SYNCHRONIZED: "synchronized" >
- | < TRANSIENT: "transient" >
- | < THROW: "throw" >
- | < THROWS: "throws" >
- | < TRUE: "true" >
- | < TRY: "try" >
- | < VOID: "void" >
- | < VOLATILE: "volatile" >
- | < WHILE: "while" >
- }
- TOKEN : /* LITERALS */
- {
- < 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:
- (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
- | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
- | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
- | (["0"-"9"])+ (<EXPONENT>)? ["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"]
- )
- )
- )
- "'"
- >
- |
- < STRING_LITERAL:
- "\""
- ( (~["\"","\\","\n","\r"])
- | ("\\"
- ( ["n","t","b","r","f","\\","'","\""]
- | ["0"-"7"] ( ["0"-"7"] )?
- | ["0"-"3"] ["0"-"7"] ["0"-"7"]
- )
- )
- )*
- "\""
- >
- |
- < FORMAL_COMMENT:
- "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/"
- >
- }
- TOKEN : /* IDENTIFIERS */
- {
- < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
- |
- < #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 : /* SEPARATORS */
- {
- < LPAREN: "(" >
- | < RPAREN: ")" >
- | < LBRACE: "{" >
- | < RBRACE: "}" >
- | < LBRACKET: "[" >
- | < RBRACKET: "]" >
- | < SEMICOLON: ";" >
- | < COMMA: "," >
- | < DOT: "." >
- }
- TOKEN : /* OPERATORS */
- {
- < ASSIGN: "=" >
- | < GT: ">" >
- | < GTX: "@gt" >
- | < LT: "<" >
- | < LTX: "@lt" >
- | < BANG: "!" >
- | < TILDE: "~" >
- | < HOOK: "?" >
- | < COLON: ":" >
- | < EQ: "==" >
- | < LE: "<=" >
- | < LEX: "@lteq" >
- | < GE: ">=" >
- | < GEX: "@gteq" >
- | < NE: "!=" >
- | < BOOL_OR: "||" >
- | < BOOL_ORX: "@or" >
- | < BOOL_AND: "&&" >
- | < BOOL_ANDX: "@and" >
- | < INCR: "++" >
- | < DECR: "--" >
- | < PLUS: "+" >
- | < MINUS: "-" >
- | < STAR: "*" >
- | < SLASH: "/" >
- | < BIT_AND: "&" >
- | < BIT_ANDX: "@bitwise_and" >
- | < BIT_OR: "|" >
- | < BIT_ORX: "@bitwise_or" >
- | < XOR: "^" >
- | < MOD: "%" >
- | < LSHIFT: "<<" >
- | < LSHIFTX: "@left_shift" >
- | < RSIGNEDSHIFT: ">>" >
- | < RSIGNEDSHIFTX: "@right_shift" >
- | < RUNSIGNEDSHIFT: ">>>" >
- | < RUNSIGNEDSHIFTX: "@right_unsigned_shift" >
- | < PLUSASSIGN: "+=" >
- | < MINUSASSIGN: "-=" >
- | < STARASSIGN: "*=" >
- | < SLASHASSIGN: "/=" >
- | < ANDASSIGN: "&=" >
- | < ANDASSIGNX: "@and_assign" >
- | < ORASSIGN: "|=" >
- | < ORASSIGNX: "@or_assign" >
- | < XORASSIGN: "^=" >
- | < MODASSIGN: "%=" >
- | < LSHIFTASSIGN: "<<=" >
- | < LSHIFTASSIGNX: "@left_shift_assign" >
- | < RSIGNEDSHIFTASSIGN: ">>=" >
- | < RSIGNEDSHIFTASSIGNX: "@right_shift_assign" >
- | < RUNSIGNEDSHIFTASSIGN: ">>>=" >
- | < RUNSIGNEDSHIFTASSIGNX: "@right_unsigned_shift_assign" >
- }
- /*
- Thanks to Sreenivasa Viswanadha for suggesting how to get rid of expensive
- lookahead here.
- */
- boolean Line() :
- {}
- {
- <EOF> {
- Interpreter.debug("End of File!");
- return true;
- }
- |
- BlockStatement() {
- return false;
- }
- }
- /*****************************************
- * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
- *****************************************/
- /*
- Gather modifiers for a class, method, or field.
- I lookahead is true then we are being called as part of a lookahead and we
- should not enforce any rules. Otherwise we validate based on context
- (field, method, class)
- */
- Modifiers Modifiers( int context, boolean lookahead ) :
- {
- Modifiers mods = null;
- }
- {
- (
- (
- "private" | "protected" | "public" | "synchronized" | "final"
- | "native" | "transient" | "volatile" | "abstract" | "static"
- | "strictfp"
- ) {
- if ( !lookahead )
- try {
- if ( mods == null ) mods = new Modifiers();
- mods.addModifier( context, getToken(0).image );
- } catch ( IllegalStateException e ) {
- throw createParseException( e.getMessage() );
- }
- }
- )* {
- return mods;
- }
- }
- /**
- */
- void ClassDeclaration() :
- {/*@bgen(jjtree) ClassDeclaration */
- BSHClassDeclaration jjtn000 = new BSHClassDeclaration(JJTCLASSDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/
- Modifiers mods;
- Token name;
- int numInterfaces;
- }
- {/*@bgen(jjtree) ClassDeclaration */
- try {
- /*@egen*/
- mods = Modifiers( Modifiers.CLASS, false )
- ( "class" | "interface" { jjtn000.isInterface=true; } )
- name=<IDENTIFIER>
- [ "extends" AmbiguousName() { jjtn000.extend = true; } ]
- [ "implements" numInterfaces=NameList()
- { jjtn000.numInterfaces=numInterfaces; } ]
- Block()/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/
- {
- jjtn000.modifiers = mods;
- jjtn000.name = name.image;
- }/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void MethodDeclaration() :
- {/*@bgen(jjtree) MethodDeclaration */
- BSHMethodDeclaration jjtn000 = new BSHMethodDeclaration(JJTMETHODDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/
- Token t = null;
- Modifiers mods;
- int count;
- }
- {/*@bgen(jjtree) MethodDeclaration */
- try {
- /*@egen*/
- mods = Modifiers( Modifiers.METHOD, false ) { jjtn000.modifiers = mods; }
- (
- LOOKAHEAD( <IDENTIFIER> "(" )
- t = <IDENTIFIER> { jjtn000.name = t.image; }
- |
- ReturnType()
- t = <IDENTIFIER> { jjtn000.name = t.image; }
- )
- FormalParameters()
- [ "throws" count=NameList() { jjtn000.numThrows=count; } ]
- ( Block() | ";" )/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void PackageDeclaration () :
- {/*@bgen(jjtree) PackageDeclaration */
- BSHPackageDeclaration jjtn000 = new BSHPackageDeclaration(JJTPACKAGEDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) PackageDeclaration */
- try {
- /*@egen*/
- "package" AmbiguousName()/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void ImportDeclaration() :
- {/*@bgen(jjtree) ImportDeclaration */
- BSHImportDeclaration jjtn000 = new BSHImportDeclaration(JJTIMPORTDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/
- Token s = null;
- Token t = null;
- }
- {/*@bgen(jjtree) ImportDeclaration */
- try {
- /*@egen*/
- LOOKAHEAD( 3 )
- [ s = "static" ] "import" AmbiguousName() [ t = "." "*" ] ";"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/
- {
- if ( s != null ) jjtn000.staticImport = true;
- if ( t != null ) jjtn000.importPackage = true;
- }
- |
- // bsh super import statement
- "import" "*" ";"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ {
- jjtn000.superImport = true;
- }/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void VariableDeclarator() :
- {/*@bgen(jjtree) VariableDeclarator */
- BSHVariableDeclarator jjtn000 = new BSHVariableDeclarator(JJTVARIABLEDECLARATOR);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/
- Token t;
- }
- {/*@bgen(jjtree) VariableDeclarator */
- try {
- /*@egen*/
- t=<IDENTIFIER> [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/
- {
- jjtn000.name = t.image;
- }/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- /*
- this originally handled postfix array dimensions...
- void VariableDeclaratorId() #VariableDeclaratorId :
- { Token t; }
- {
- t=<IDENTIFIER> { jjtThis.name = t.image; }
- ( "[" "]" { jjtThis.addUndefinedDimension(); } )*
- }
- */
- void VariableInitializer() :
- {}
- {
- ArrayInitializer()
- |
- Expression()
- }
- void ArrayInitializer() :
- {/*@bgen(jjtree) ArrayInitializer */
- BSHArrayInitializer jjtn000 = new BSHArrayInitializer(JJTARRAYINITIALIZER);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/}
- {/*@bgen(jjtree) ArrayInitializer */
- try {
- /*@egen*/
- "{" [ VariableInitializer()
- ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void FormalParameters() :
- {/*@bgen(jjtree) FormalParameters */
- BSHFormalParameters jjtn000 = new BSHFormalParameters(JJTFORMALPARAMETERS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/}
- {/*@bgen(jjtree) FormalParameters */
- try {
- /*@egen*/
- "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void FormalParameter() :
- {/*@bgen(jjtree) FormalParameter */
- BSHFormalParameter jjtn000 = new BSHFormalParameter(JJTFORMALPARAMETER);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ Token t; }
- {/*@bgen(jjtree) FormalParameter */
- try {
- /*@egen*/
- // added [] to Type for bsh. Removed [ final ] - is that legal?
- LOOKAHEAD(2) Type() t=<IDENTIFIER>/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.name = t.image; }
- |
- t=<IDENTIFIER>/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- /*
- Type, name and expression syntax follows.
- */
- void Type() :
- {/*@bgen(jjtree) Type */
- BSHType jjtn000 = new BSHType(JJTTYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) Type */
- try {
- /*@egen*/
- /*
- The embedded lookahead is (was?) necessary to disambiguate for
- PrimaryPrefix. ( )* is a choice point. It took me a while to
- figure out where to put that. This stuff is annoying.
- */
- ( PrimitiveType() | AmbiguousName() )
- ( LOOKAHEAD(2) "[" "]" { jjtn000.addArrayDimension(); } )*/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- /*
- Originally called ResultType in the grammar
- */
- void ReturnType() :
- {/*@bgen(jjtree) ReturnType */
- BSHReturnType jjtn000 = new BSHReturnType(JJTRETURNTYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) ReturnType */
- try {
- /*@egen*/
- "void"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.isVoid = true; }
- |
- Type()/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void PrimitiveType() :
- {/*@bgen(jjtree) PrimitiveType */
- BSHPrimitiveType jjtn000 = new BSHPrimitiveType(JJTPRIMITIVETYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ } {/*@bgen(jjtree) PrimitiveType */
- try {
- /*@egen*/
- "boolean"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Boolean.TYPE; }
- | "char"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Character.TYPE; }
- | "byte"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Byte.TYPE; }
- | "short"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Short.TYPE; }
- | "int"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Integer.TYPE; }
- | "long"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Long.TYPE; }
- | "float"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Float.TYPE; }
- | "double"/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ { jjtn000.type = Double.TYPE; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void AmbiguousName() :
- /*
- A lookahead of 2 is required below since "Name" can be followed by a ".*"
- when used in the context of an "ImportDeclaration".
- */
- {/*@bgen(jjtree) AmbiguousName */
- BSHAmbiguousName jjtn000 = new BSHAmbiguousName(JJTAMBIGUOUSNAME);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/
- Token t;
- StringBuffer s;
- }
- {/*@bgen(jjtree) AmbiguousName */
- try {
- /*@egen*/
- t = <IDENTIFIER> {
- s = new StringBuffer(t.image);
- }
- ( LOOKAHEAD(2) "." t = <IDENTIFIER> { s.append("."+t.image); } )*/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- }
- /*@egen*/ {
- jjtn000.text = s.toString();
- }/*@bgen(jjtree)*/
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- int NameList() :
- { int count = 0; }
- {
- AmbiguousName() { ++count; } ( "," AmbiguousName() { ++count; } )*
- { return count; }
- }
- /*
- * Expression syntax follows.
- */
- void Expression() :
- { }
- {
- /**
- SYNTACTIC_LOOKAHEAD
- Note: the original grammar was cheating here and we've fixed that,
- but at the expense of another syntactic lookahead.
- */
- LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
- Assignment()
- |
- ConditionalExpression()
- }
- void Assignment() :
- {/*@bgen(jjtree) Assignment */
- BSHAssignment jjtn000 = new BSHAssignment(JJTASSIGNMENT);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ int op ; }
- {/*@bgen(jjtree) Assignment */
- try {
- /*@egen*/
- PrimaryExpression()
- op = AssignmentOperator() { jjtn000.operator = op; }
- // Add this for blocks, e.g. foo = { };
- //( Expression() | Block() )
- Expression()/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- int AssignmentOperator() :
- { Token t; }
- {
- ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|=" |
- "<<=" | "@left_shift_assign" | ">>=" | "@right_shift_assign" |
- ">>>=" | "@right_unsigned_shift_assign" )
- {
- t = getToken(0);
- return t.kind;
- }
- }
- void ConditionalExpression() :
- { }
- {
- ConditionalOrExpression() [ "?" Expression() ":"/*@bgen(jjtree) #TernaryExpression( 3) */
- {
- BSHTernaryExpression jjtn001 = new BSHTernaryExpression(JJTTERNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*/ ConditionalExpression()/*@bgen(jjtree)*/
- } catch (Throwable jjte001) {
- if (jjtc001) {
- jjtree.clearNodeScope(jjtn001);
- jjtc001 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte001 instanceof RuntimeException) {
- throw (RuntimeException)jjte001;
- }
- if (jjte001 instanceof ParseException) {
- throw (ParseException)jjte001;
- }
- throw (Error)jjte001;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 3);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ ]
- }
- void ConditionalOrExpression() :
- { Token t=null; }
- {
- ConditionalAndExpression()
- ( ( t = "||" | t = "@or" )
- ConditionalAndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void ConditionalAndExpression() :
- { Token t=null; }
- {
- InclusiveOrExpression()
- ( ( t = "&&" | t = "@and" )
- InclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void InclusiveOrExpression() :
- { Token t=null; }
- {
- ExclusiveOrExpression()
- ( ( t = "|" | t = "@bitwise_or" )
- ExclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void ExclusiveOrExpression() :
- { Token t=null; }
- {
- AndExpression() ( t="^" AndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void AndExpression() :
- { Token t=null; }
- {
- EqualityExpression()
- ( ( t = "&" | t = "@bitwise_and" )
- EqualityExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void EqualityExpression() :
- { Token t = null; }
- {
- InstanceOfExpression() ( ( t= "==" | t= "!=" ) InstanceOfExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- )*
- }
- void InstanceOfExpression() :
- { Token t = null; }
- {
- RelationalExpression()
- [ t = "instanceof" Type()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ ]
- }
- void RelationalExpression() :
- { Token t = null; }
- {
- ShiftExpression()
- ( ( t = "<" | t = "@lt" | t = ">" | t = "@gt" |
- t = "<=" | t = "@lteq" | t = ">=" | t = "@gteq" )
- ShiftExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void ShiftExpression() :
- { Token t = null; }
- {
- AdditiveExpression()
- ( ( t = "<<" | t = "@left_shift" | t = ">>" | t = "@right_shift" |
- t = ">>>" | t = "@right_unsigned_shift" )
- AdditiveExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void AdditiveExpression() :
- { Token t = null; }
- {
- MultiplicativeExpression()
- ( ( t= "+" | t= "-" ) MultiplicativeExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- )*
- }
- void MultiplicativeExpression() :
- { Token t = null; }
- {
- UnaryExpression() ( ( t= "*" | t= "/" | t= "%" )
- UnaryExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
- {
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/ )*
- }
- void UnaryExpression() :
- { Token t = null; }
- {
- ( t="+" | t="-" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
- {
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- |
- PreIncrementExpression()
- |
- PreDecrementExpression()
- |
- UnaryExpressionNotPlusMinus()
- }
- void PreIncrementExpression() :
- { Token t = null; }
- {
- t="++" PrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
- {
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- }
- void PreDecrementExpression() :
- { Token t = null; }
- {
- t="--" PrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
- {
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- }
- void UnaryExpressionNotPlusMinus() :
- { Token t = null; }
- {
- ( t="~" | t="!" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
- {
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/
- { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- |
- // SYNTACTIC_LOOKAHEAD
- LOOKAHEAD( CastLookahead() ) CastExpression()
- |
- PostfixExpression()
- }
- // This production is to determine lookahead only.
- void CastLookahead() : { }
- {
- LOOKAHEAD(2) "(" PrimitiveType()
- |
- // SYNTACTIC_LOOKAHEAD
- LOOKAHEAD( "(" AmbiguousName() "[" ) "(" AmbiguousName() "[" "]"
- |
- "(" AmbiguousName() ")" ( "~" | "!" | "(" | <IDENTIFIER> | /* "this" | "super" | */ "new" | Literal() )
- }
- void PostfixExpression() :
- { Token t = null; }
- {
- // SYNTACTIC_LOOKAHEAD
- LOOKAHEAD( PrimaryExpression() ("++"|"--") )
- PrimaryExpression()
- ( t="++" | t="--" )/*@bgen(jjtree) #UnaryExpression( 1) */
- {
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- }
- try {
- /*@egen*//*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- }
- /*@egen*/ {
- jjtn001.kind = t.kind; jjtn001.postfix = true; }/*@bgen(jjtree)*/
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- /*@egen*/
- |
- PrimaryExpression()
- }
- void CastExpression() :
- {/*@bgen(jjtree) CastExpression */
- BSHCastExpression jjtn000 = new BSHCastExpression(JJTCASTEXPRESSION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) CastExpression */
- try {
- /*@egen*/
- // SYNTACTIC_LOOKAHEAD
- LOOKAHEAD( "(" PrimitiveType() ) "(" Type() ")" UnaryExpression()
- |
- "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void PrimaryExpression() : {/*@bgen(jjtree) PrimaryExpression */
- BSHPrimaryExpression jjtn000 = new BSHPrimaryExpression(JJTPRIMARYEXPRESSION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) PrimaryExpression */
- try {
- /*@egen*/
- PrimaryPrefix() ( PrimarySuffix() )*/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void MethodInvocation() : {/*@bgen(jjtree) MethodInvocation */
- BSHMethodInvocation jjtn000 = new BSHMethodInvocation(JJTMETHODINVOCATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- /*@egen*/ }
- {/*@bgen(jjtree) MethodInvocation */
- try {
- /*@egen*/
- AmbiguousName() Arguments()/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- /*@egen*/
- }
- void PrimaryPrefix() : { }
- {
- Literal()
- |
- "(" Expression() ")"
- |
- AllocationExpression()
- |
- // SYNTACTIC_LOOKAHEAD
- LOOKAHEAD( MethodInvocation() )…