PageRenderTime 73ms CodeModel.GetById 11ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/bsh/bsh.jj

#
Unknown | 2424 lines | 2326 code | 98 blank | 0 comment | 0 complexity | 14b9f04c54708cbbdde889850c34c04e MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0

Large files files are truncated, but you can click here to view the full file

   1/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. src/bsh/bsh.jj */
   2/*@egen*//*****************************************************************************
   3 *                                                                           *
   4 *  This file is part of the BeanShell Java Scripting distribution.          *
   5 *  Documentation and updates may be found at http://www.beanshell.org/      *
   6 *                                                                           *
   7 *  Sun Public License Notice:                                               *
   8 *                                                                           *
   9 *  The contents of this file are subject to the Sun Public License Version  *
  10 *  1.0 (the "License"); you may not use this file except in compliance with *
  11 *  the License. A copy of the License is available at http://www.sun.com    * 
  12 *                                                                           *
  13 *  The Original Code is BeanShell. The Initial Developer of the Original    *
  14 *  Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright     *
  15 *  (C) 2000.  All Rights Reserved.                                          *
  16 *                                                                           *
  17 *  GNU Public License Notice:                                               *
  18 *                                                                           *
  19 *  Alternatively, the contents of this file may be used under the terms of  *
  20 *  the GNU Lesser General Public License (the "LGPL"), in which case the    *
  21 *  provisions of LGPL are applicable instead of those above. If you wish to *
  22 *  allow use of your version of this file only under the  terms of the LGPL *
  23 *  and not to allow others to use your version of this file under the SPL,  *
  24 *  indicate your decision by deleting the provisions above and replace      *
  25 *  them with the notice and other provisions required by the LGPL.  If you  *
  26 *  do not delete the provisions above, a recipient may use your version of  *
  27 *  this file under either the SPL or the LGPL.                              *
  28 *                                                                           *
  29 *  Patrick Niemeyer (pat@pat.net)                                           *
  30 *  Author of Learning Java, O'Reilly & Associates                           *
  31 *  http://www.pat.net/~pat/                                                 *
  32 *                                                                           *
  33 *****************************************************************************/
  34
  35/*
  36	Notes:
  37	There is probably a lot of room for improvement in here.
  38	All of the syntactic lookaheads have been commented with:
  39		SYNTACTIC_LOOKAHEAD
  40	These are probably expensive and we may want to start weeding them out
  41	where possible.
  42*/
  43
  44options {
  45    JAVA_UNICODE_ESCAPE=true;
  46    STATIC=false;                                                                                       
  47	/* Print grammar debugging info as we parse 
  48	DEBUG_PARSER=true; */
  49	/* Print detailed lookahead debugging info
  50	DEBUG_LOOKAHEAD=true; */
  51}
  52
  53PARSER_BEGIN(Parser)
  54package bsh;
  55
  56import java.io.Reader;
  57
  58class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
  59  protected JJTParserState jjtree = new JJTParserState();
  60
  61/*@egen*/ 
  62
  63	void jjtreeOpenNodeScope(Node n) {
  64		((SimpleNode)n).firstToken = getToken(1);
  65	}
  66
  67	void jjtreeCloseNodeScope(Node n) {
  68		((SimpleNode)n).lastToken = getToken(0);
  69	}
  70
  71	/**
  72		Re-initialize the input stream and token source.
  73	*/
  74	void reInitInput( Reader in ) {
  75		ReInit(in);
  76	}
  77
  78	/**
  79		Explicitly re-initialize just the token reader.
  80		This seems to be necessary to avoid certain looping errors when
  81		reading bogus input.  See Interpreter.
  82	*/
  83	void reInitTokenInput( Reader in ) {
  84		jj_input_stream.ReInit( in, 
  85			jj_input_stream.getEndLine(), 
  86			jj_input_stream.getEndColumn() );
  87	}
  88
  89}
  90
  91
  92PARSER_END(Parser)
  93
  94SKIP : /* WHITE SPACE */
  95{ 
  96	" " | "\t" | "\r" | "\f"
  97	| "\n" 
  98	| < NONPRINTABLE: (["\u0000"-" ", "\u0080"-"\u00ff"])+ >
  99}
 100
 101SPECIAL_TOKEN : /* COMMENTS */
 102{
 103/*
 104	Single line comments fail on the last line of a file with no terminating
 105	linefeed.  I thought the <EOF> would fix that, but no...
 106  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* "<EOF>"|("\n"|"\r"|"\r\n")>
 107*/
 108  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
 109| <HASH_BANG_COMMENT: "#!" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
 110| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
 111| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
 112}
 113
 114TOKEN : /* RESERVED WORDS AND LITERALS */
 115{
 116< BOOLEAN: "boolean" >
 117| < BREAK: "break" >
 118| < CLASS: "class" >
 119| < BYTE: "byte" >
 120| < CASE: "case" >
 121| < CATCH: "catch" >
 122| < CHAR: "char" >
 123| < CONST: "const" >
 124| < CONTINUE: "continue" >
 125| < _DEFAULT: "default" >
 126| < DO: "do" >
 127| < DOUBLE: "double" >
 128| < ELSE: "else" >
 129| < FALSE: "false" >
 130| < FINAL: "final" >
 131| < FINALLY: "finally" >
 132| < FLOAT: "float" >
 133| < FOR: "for" >
 134| < GOTO: "goto" >
 135| < IF: "if" >
 136| < IMPORT: "import" >
 137| < INSTANCEOF: "instanceof" >
 138| < INT: "int" >
 139| < INTERFACE: "interface" >
 140| < LONG: "long" >
 141| < NEW: "new" >
 142| < NULL: "null" >
 143| < PRIVATE: "private" >
 144| < PROTECTED: "protected" >
 145| < PUBLIC: "public" >
 146| < RETURN: "return" >
 147| < SHORT: "short" >
 148| < STATIC: "static" >
 149| < SWITCH: "switch" >
 150| < THROW: "throw" >
 151| < TRUE: "true" >
 152| < TRY: "try" >
 153| < VOID: "void" >
 154| < WHILE: "while" >
 155}
 156
 157TOKEN : /* LITERALS */
 158{
 159  < INTEGER_LITERAL:
 160        <DECIMAL_LITERAL> (["l","L"])?
 161      | <HEX_LITERAL> (["l","L"])?
 162      | <OCTAL_LITERAL> (["l","L"])?
 163  >
 164|
 165  < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
 166|
 167  < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
 168|
 169  < #OCTAL_LITERAL: "0" (["0"-"7"])* >
 170|
 171  < FLOATING_POINT_LITERAL:
 172        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
 173      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
 174      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
 175      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
 176  >
 177|
 178  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
 179|
 180  < CHARACTER_LITERAL:
 181      "'"
 182      (   (~["'","\\","\n","\r"])
 183        | ("\\"
 184            ( ["n","t","b","r","f","\\","'","\""]
 185            | ["0"-"7"] ( ["0"-"7"] )?
 186            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
 187            )
 188          )
 189      )
 190      "'"
 191  >
 192|
 193  < STRING_LITERAL:
 194      "\""
 195      (   (~["\"","\\","\n","\r"])
 196        | ("\\"
 197            ( ["n","t","b","r","f","\\","'","\""]
 198            | ["0"-"7"] ( ["0"-"7"] )?
 199            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
 200            )
 201          )
 202      )*
 203      "\""
 204  >
 205}
 206
 207TOKEN : /* IDENTIFIERS */
 208{
 209  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
 210|
 211  < #LETTER:
 212      [
 213       "$",
 214       "A"-"Z",
 215       "_",
 216       "a"-"z",
 217       "\u00c0"-"\u00d6",
 218       "\u00d8"-"\u00f6",
 219       "\u00f8"-"\u00ff",
 220       "\u0100"-"\u1fff",
 221       "\u3040"-"\u318f",
 222       "\u3300"-"\u337f",
 223       "\u3400"-"\u3d2d",
 224       "\u4e00"-"\u9fff",
 225       "\uf900"-"\ufaff"
 226      ]
 227  >
 228|
 229  < #DIGIT:
 230      [
 231       "0"-"9",
 232       "\u0660"-"\u0669",
 233       "\u06f0"-"\u06f9",
 234       "\u0966"-"\u096f",
 235       "\u09e6"-"\u09ef",
 236       "\u0a66"-"\u0a6f",
 237       "\u0ae6"-"\u0aef",
 238       "\u0b66"-"\u0b6f",
 239       "\u0be7"-"\u0bef",
 240       "\u0c66"-"\u0c6f",
 241       "\u0ce6"-"\u0cef",
 242       "\u0d66"-"\u0d6f",
 243       "\u0e50"-"\u0e59",
 244       "\u0ed0"-"\u0ed9",
 245       "\u1040"-"\u1049"
 246      ]
 247  >
 248}
 249
 250TOKEN : /* SEPARATORS */
 251{
 252  < LPAREN: "(" >
 253| < RPAREN: ")" >
 254| < LBRACE: "{" >
 255| < RBRACE: "}" >
 256| < LBRACKET: "[" >
 257| < RBRACKET: "]" >
 258| < SEMICOLON: ";" >
 259| < COMMA: "," >
 260| < DOT: "." >
 261}
 262
 263TOKEN : /* OPERATORS */
 264{
 265  < ASSIGN: "=" >
 266| < GT: ">" >
 267| < GTX: "@gt" >
 268| < LT: "<" >
 269| < LTX: "@lt" >
 270| < BANG: "!" >
 271| < TILDE: "~" >
 272| < HOOK: "?" >
 273| < COLON: ":" >
 274| < EQ: "==" >
 275| < LE: "<=" >
 276| < LEX: "@lteq" >
 277| < GE: ">=" >
 278| < GEX: "@gteq" >
 279| < NE: "!=" >
 280| < BOOL_OR: "||" >
 281| < BOOL_ORX: "@or" >
 282| < BOOL_AND: "&&" >
 283| < BOOL_ANDX: "@and" >
 284| < INCR: "++" >
 285| < DECR: "--" >
 286| < PLUS: "+" >
 287| < MINUS: "-" >
 288| < STAR: "*" >
 289| < SLASH: "/" >
 290| < BIT_AND: "&" >
 291| < BIT_ANDX: "@bitwise_and" >
 292| < BIT_OR: "|" >
 293| < BIT_ORX: "@bitwise_or" >
 294| < XOR: "^" >
 295| < MOD: "%" >
 296| < LSHIFT: "<<" >
 297| < LSHIFTX: "@left_shift" >
 298| < RSIGNEDSHIFT: ">>" >
 299| < RSIGNEDSHIFTX: "@right_shift" >
 300| < RUNSIGNEDSHIFT: ">>>" >
 301| < RUNSIGNEDSHIFTX: "@right_unsigned_shift" >
 302| < PLUSASSIGN: "+=" >
 303| < MINUSASSIGN: "-=" >
 304| < STARASSIGN: "*=" >
 305| < SLASHASSIGN: "/=" >
 306| < ANDASSIGN: "&=" >
 307| < ANDASSIGNX: "@and_assign" >
 308| < ORASSIGN: "|=" >
 309| < ORASSIGNX: "@or_assign" >
 310| < XORASSIGN: "^=" >
 311| < MODASSIGN: "%=" >
 312| < LSHIFTASSIGN: "<<=" >
 313| < LSHIFTASSIGNX: "@left_shift_assign" >
 314| < RSIGNEDSHIFTASSIGN: ">>=" >
 315| < RSIGNEDSHIFTASSIGNX: "@right_shift_assign" >
 316| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
 317| < RUNSIGNEDSHIFTASSIGNX: "@right_unsigned_shift_assign" >
 318}
 319
 320
 321boolean Line() :
 322{}
 323{
 324  <EOF> { 
 325	Interpreter.debug("End of File!"); 
 326	return true; 
 327	}
 328|
 329  (
 330	/*
 331		SYNTACTIC_LOOKAHEAD
 332		I'm guessing this is expensive, but I don't know how to work around
 333		it...  Is there another syntactic indication that we are working 
 334		through an expression as opposed to a statement?
 335		What is the difference?  Well, some statements don't require a
 336		semicolon and they don't return vlues...  We could probably broaden
 337		bsh to allow everything to return a value, but the semi-colon thing
 338		is tougher.  You don't want to have to say if ( foo ) { } ;
 339		Maybe we can invert ths and enumerate all of those types of 
 340		statements in a special lookahead that's cheaper??
 341	*/
 342   LOOKAHEAD( Expression() ";" )
 343   Expression() ";" 
 344  |
 345   BlockStatement()
 346  )
 347	{ 
 348		return false; 
 349	}
 350}
 351
 352/*****************************************
 353 * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
 354 *****************************************/
 355
 356void MethodDeclaration()                    :
 357{/*@bgen(jjtree) MethodDeclaration */
 358  BSHMethodDeclaration jjtn000 = new BSHMethodDeclaration(JJTMETHODDECLARATION);
 359  boolean jjtc000 = true;
 360  jjtree.openNodeScope(jjtn000);
 361  jjtreeOpenNodeScope(jjtn000);
 362/*@egen*/ Token t = null; }
 363{/*@bgen(jjtree) MethodDeclaration */
 364    try {
 365/*@egen*/
 366	// SYNTACTIC_LOOKAHEAD
 367	// this one seems cheap enough
 368    LOOKAHEAD( MethodDeclarationTypeLookahead() )
 369    ReturnType() t = <IDENTIFIER> { jjtn000.name = t.image; }
 370    FormalParameters() Block()
 371|
 372    t = <IDENTIFIER> { jjtn000.name = t.image; }
 373    FormalParameters() Block()/*@bgen(jjtree)*/
 374    } catch (Throwable jjte000) {
 375      if (jjtc000) {
 376        jjtree.clearNodeScope(jjtn000);
 377        jjtc000 = false;
 378      } else {
 379        jjtree.popNode();
 380      }
 381      if (jjte000 instanceof RuntimeException) {
 382        throw (RuntimeException)jjte000;
 383      }
 384      if (jjte000 instanceof ParseException) {
 385        throw (ParseException)jjte000;
 386      }
 387      throw (Error)jjte000;
 388    } finally {
 389      if (jjtc000) {
 390        jjtree.closeNodeScope(jjtn000, true);
 391        jjtreeCloseNodeScope(jjtn000);
 392      }
 393    }
 394/*@egen*/
 395}
 396
 397void MethodDeclarationLookahead() : { }
 398{
 399	// SYNTACTIC_LOOKAHEAD
 400	// this one seems cheap enough
 401    LOOKAHEAD( MethodDeclarationTypeLookahead() )
 402    ReturnType() <IDENTIFIER> FormalParameters() "{"
 403|
 404    <IDENTIFIER> FormalParameters() "{"
 405}
 406
 407void MethodDeclarationTypeLookahead() : { }
 408{
 409    ReturnType() <IDENTIFIER> "("
 410}
 411
 412void ImportDeclaration()                    :
 413{/*@bgen(jjtree) ImportDeclaration */
 414    BSHImportDeclaration jjtn000 = new BSHImportDeclaration(JJTIMPORTDECLARATION);
 415    boolean jjtc000 = true;
 416    jjtree.openNodeScope(jjtn000);
 417    jjtreeOpenNodeScope(jjtn000);
 418/*@egen*/
 419    Token t = null;
 420}
 421{/*@bgen(jjtree) ImportDeclaration */
 422  try {
 423/*@egen*/
 424  LOOKAHEAD( 2 )
 425
 426  "import" AmbiguousName() [ t = "." "*" ] ";"/*@bgen(jjtree)*/
 427                                               {
 428                                                 jjtree.closeNodeScope(jjtn000, true);
 429                                                 jjtc000 = false;
 430                                                 jjtreeCloseNodeScope(jjtn000);
 431                                               }
 432/*@egen*/ {
 433    if ( t != null )
 434        jjtn000.importPackage = true;
 435    }
 436  |
 437	// bsh super import statement
 438  "import" "*" ";"/*@bgen(jjtree)*/
 439                   {
 440                     jjtree.closeNodeScope(jjtn000, true);
 441                     jjtc000 = false;
 442                     jjtreeCloseNodeScope(jjtn000);
 443                   }
 444/*@egen*/ {
 445		jjtn000.superImport = true;
 446	}/*@bgen(jjtree)*/
 447  } catch (Throwable jjte000) {
 448    if (jjtc000) {
 449      jjtree.clearNodeScope(jjtn000);
 450      jjtc000 = false;
 451    } else {
 452      jjtree.popNode();
 453    }
 454    if (jjte000 instanceof RuntimeException) {
 455      throw (RuntimeException)jjte000;
 456    }
 457    if (jjte000 instanceof ParseException) {
 458      throw (ParseException)jjte000;
 459    }
 460    throw (Error)jjte000;
 461  } finally {
 462    if (jjtc000) {
 463      jjtree.closeNodeScope(jjtn000, true);
 464      jjtreeCloseNodeScope(jjtn000);
 465    }
 466  }
 467/*@egen*/
 468}
 469
 470void VariableDeclarator()                     :
 471{/*@bgen(jjtree) VariableDeclarator */
 472  BSHVariableDeclarator jjtn000 = new BSHVariableDeclarator(JJTVARIABLEDECLARATOR);
 473  boolean jjtc000 = true;
 474  jjtree.openNodeScope(jjtn000);
 475  jjtreeOpenNodeScope(jjtn000);
 476/*@egen*/ Token t; }
 477{/*@bgen(jjtree) VariableDeclarator */
 478  try {
 479/*@egen*/
 480  t=<IDENTIFIER> [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
 481                                               {
 482                                                 jjtree.closeNodeScope(jjtn000, true);
 483                                                 jjtc000 = false;
 484                                                 jjtreeCloseNodeScope(jjtn000);
 485                                               }
 486/*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
 487  } catch (Throwable jjte000) {
 488    if (jjtc000) {
 489      jjtree.clearNodeScope(jjtn000);
 490      jjtc000 = false;
 491    } else {
 492      jjtree.popNode();
 493    }
 494    if (jjte000 instanceof RuntimeException) {
 495      throw (RuntimeException)jjte000;
 496    }
 497    if (jjte000 instanceof ParseException) {
 498      throw (ParseException)jjte000;
 499    }
 500    throw (Error)jjte000;
 501  } finally {
 502    if (jjtc000) {
 503      jjtree.closeNodeScope(jjtn000, true);
 504      jjtreeCloseNodeScope(jjtn000);
 505    }
 506  }
 507/*@egen*/
 508}
 509
 510/*
 511Can get rid of this if we ignore postfix array dimensions in declarations.
 512I don't like them and I don't want to deal with them right now.
 513
 514void VariableDeclaratorId() #VariableDeclaratorId :
 515{ Token t; }
 516{
 517  t=<IDENTIFIER> { jjtThis.name = t.image; }
 518  ( "[" "]" { jjtThis.addArrayDimension(); } )*
 519}
 520*/
 521
 522void VariableInitializer() :
 523{}
 524{
 525  ArrayInitializer()
 526|
 527  Expression()
 528}
 529
 530void ArrayInitializer()                   :
 531{/*@bgen(jjtree) ArrayInitializer */
 532  BSHArrayInitializer jjtn000 = new BSHArrayInitializer(JJTARRAYINITIALIZER);
 533  boolean jjtc000 = true;
 534  jjtree.openNodeScope(jjtn000);
 535  jjtreeOpenNodeScope(jjtn000);
 536/*@egen*/}
 537{/*@bgen(jjtree) ArrayInitializer */
 538  try {
 539/*@egen*/
 540  "{" [ VariableInitializer() 
 541		( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
 542  } catch (Throwable jjte000) {
 543    if (jjtc000) {
 544      jjtree.clearNodeScope(jjtn000);
 545      jjtc000 = false;
 546    } else {
 547      jjtree.popNode();
 548    }
 549    if (jjte000 instanceof RuntimeException) {
 550      throw (RuntimeException)jjte000;
 551    }
 552    if (jjte000 instanceof ParseException) {
 553      throw (ParseException)jjte000;
 554    }
 555    throw (Error)jjte000;
 556  } finally {
 557    if (jjtc000) {
 558      jjtree.closeNodeScope(jjtn000, true);
 559      jjtreeCloseNodeScope(jjtn000);
 560    }
 561  }
 562/*@egen*/
 563}
 564
 565void FormalParameters()                   :
 566{/*@bgen(jjtree) FormalParameters */
 567  BSHFormalParameters jjtn000 = new BSHFormalParameters(JJTFORMALPARAMETERS);
 568  boolean jjtc000 = true;
 569  jjtree.openNodeScope(jjtn000);
 570  jjtreeOpenNodeScope(jjtn000);
 571/*@egen*/}
 572{/*@bgen(jjtree) FormalParameters */
 573  try {
 574/*@egen*/
 575  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
 576  } catch (Throwable jjte000) {
 577    if (jjtc000) {
 578      jjtree.clearNodeScope(jjtn000);
 579      jjtc000 = false;
 580    } else {
 581      jjtree.popNode();
 582    }
 583    if (jjte000 instanceof RuntimeException) {
 584      throw (RuntimeException)jjte000;
 585    }
 586    if (jjte000 instanceof ParseException) {
 587      throw (ParseException)jjte000;
 588    }
 589    throw (Error)jjte000;
 590  } finally {
 591    if (jjtc000) {
 592      jjtree.closeNodeScope(jjtn000, true);
 593      jjtreeCloseNodeScope(jjtn000);
 594    }
 595  }
 596/*@egen*/
 597}
 598
 599/*
 600void FormalParameter() #FormalParameter :
 601{ Token t; }
 602{
 603    // added [] to Type for bsh.  Removed [ final ] - is that legal?
 604  [ LOOKAHEAD(2) Type() ] t=<IDENTIFIER> { jjtThis.name = t.image; }
 605}
 606*/
 607void FormalParameter()                  :
 608{/*@bgen(jjtree) FormalParameter */
 609  BSHFormalParameter jjtn000 = new BSHFormalParameter(JJTFORMALPARAMETER);
 610  boolean jjtc000 = true;
 611  jjtree.openNodeScope(jjtn000);
 612  jjtreeOpenNodeScope(jjtn000);
 613/*@egen*/ Token t; }
 614{/*@bgen(jjtree) FormalParameter */
 615  try {
 616/*@egen*/
 617  // added [] to Type for bsh.  Removed [ final ] - is that legal?
 618  LOOKAHEAD(2) Type() t=<IDENTIFIER>/*@bgen(jjtree)*/
 619                                     {
 620                                       jjtree.closeNodeScope(jjtn000, true);
 621                                       jjtc000 = false;
 622                                       jjtreeCloseNodeScope(jjtn000);
 623                                     }
 624/*@egen*/ { jjtn000.name = t.image; }
 625|
 626  t=<IDENTIFIER>/*@bgen(jjtree)*/
 627                 {
 628                   jjtree.closeNodeScope(jjtn000, true);
 629                   jjtc000 = false;
 630                   jjtreeCloseNodeScope(jjtn000);
 631                 }
 632/*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
 633  } catch (Throwable jjte000) {
 634    if (jjtc000) {
 635      jjtree.clearNodeScope(jjtn000);
 636      jjtc000 = false;
 637    } else {
 638      jjtree.popNode();
 639    }
 640    if (jjte000 instanceof RuntimeException) {
 641      throw (RuntimeException)jjte000;
 642    }
 643    if (jjte000 instanceof ParseException) {
 644      throw (ParseException)jjte000;
 645    }
 646    throw (Error)jjte000;
 647  } finally {
 648    if (jjtc000) {
 649      jjtree.closeNodeScope(jjtn000, true);
 650      jjtreeCloseNodeScope(jjtn000);
 651    }
 652  }
 653/*@egen*/
 654}
 655
 656
 657/*
 658	Type, name and expression syntax follows.
 659*/
 660void Type()       :
 661{/*@bgen(jjtree) Type */
 662  BSHType jjtn000 = new BSHType(JJTTYPE);
 663  boolean jjtc000 = true;
 664  jjtree.openNodeScope(jjtn000);
 665  jjtreeOpenNodeScope(jjtn000);
 666/*@egen*/ }
 667{/*@bgen(jjtree) Type */
 668  try {
 669/*@egen*/
 670	/* 
 671		The embedded lookahead is (was?) necessary to disambiguate for
 672		PrimaryPrefix.  ( )* is a choice point.  It took me a while to
 673		figure out where to put that.  This stuff is annoying.
 674	*/
 675  ( PrimitiveType() | AmbiguousName() ) 
 676	( LOOKAHEAD(2) "[" "]" { jjtn000.addArrayDimension(); } )*/*@bgen(jjtree)*/
 677  } catch (Throwable jjte000) {
 678    if (jjtc000) {
 679      jjtree.clearNodeScope(jjtn000);
 680      jjtc000 = false;
 681    } else {
 682      jjtree.popNode();
 683    }
 684    if (jjte000 instanceof RuntimeException) {
 685      throw (RuntimeException)jjte000;
 686    }
 687    if (jjte000 instanceof ParseException) {
 688      throw (ParseException)jjte000;
 689    }
 690    throw (Error)jjte000;
 691  } finally {
 692    if (jjtc000) {
 693      jjtree.closeNodeScope(jjtn000, true);
 694      jjtreeCloseNodeScope(jjtn000);
 695    }
 696  }
 697/*@egen*/ 
 698}
 699
 700/*
 701	Originally called ResultType in the grammar
 702*/
 703void ReturnType()             :
 704{/*@bgen(jjtree) ReturnType */
 705  BSHReturnType jjtn000 = new BSHReturnType(JJTRETURNTYPE);
 706  boolean jjtc000 = true;
 707  jjtree.openNodeScope(jjtn000);
 708  jjtreeOpenNodeScope(jjtn000);
 709/*@egen*/ }
 710{/*@bgen(jjtree) ReturnType */
 711  try {
 712/*@egen*/
 713  "void"/*@bgen(jjtree)*/
 714         {
 715           jjtree.closeNodeScope(jjtn000, true);
 716           jjtc000 = false;
 717           jjtreeCloseNodeScope(jjtn000);
 718         }
 719/*@egen*/ { jjtn000.isVoid = true; }
 720|
 721  Type()/*@bgen(jjtree)*/
 722  } catch (Throwable jjte000) {
 723    if (jjtc000) {
 724      jjtree.clearNodeScope(jjtn000);
 725      jjtc000 = false;
 726    } else {
 727      jjtree.popNode();
 728    }
 729    if (jjte000 instanceof RuntimeException) {
 730      throw (RuntimeException)jjte000;
 731    }
 732    if (jjte000 instanceof ParseException) {
 733      throw (ParseException)jjte000;
 734    }
 735    throw (Error)jjte000;
 736  } finally {
 737    if (jjtc000) {
 738      jjtree.closeNodeScope(jjtn000, true);
 739      jjtreeCloseNodeScope(jjtn000);
 740    }
 741  }
 742/*@egen*/
 743}
 744
 745void PrimitiveType()                :
 746{/*@bgen(jjtree) PrimitiveType */
 747  BSHPrimitiveType jjtn000 = new BSHPrimitiveType(JJTPRIMITIVETYPE);
 748  boolean jjtc000 = true;
 749  jjtree.openNodeScope(jjtn000);
 750  jjtreeOpenNodeScope(jjtn000);
 751/*@egen*/ } {/*@bgen(jjtree) PrimitiveType */
 752try {
 753/*@egen*/
 754"boolean"/*@bgen(jjtree)*/
 755          {
 756            jjtree.closeNodeScope(jjtn000, true);
 757            jjtc000 = false;
 758            jjtreeCloseNodeScope(jjtn000);
 759          }
 760/*@egen*/ { jjtn000.type = Boolean.TYPE; }
 761| "char"/*@bgen(jjtree)*/
 762         {
 763           jjtree.closeNodeScope(jjtn000, true);
 764           jjtc000 = false;
 765           jjtreeCloseNodeScope(jjtn000);
 766         }
 767/*@egen*/ { jjtn000.type =  Character.TYPE; }
 768| "byte"/*@bgen(jjtree)*/
 769         {
 770           jjtree.closeNodeScope(jjtn000, true);
 771           jjtc000 = false;
 772           jjtreeCloseNodeScope(jjtn000);
 773         }
 774/*@egen*/ { jjtn000.type =  Byte.TYPE; }
 775| "short"/*@bgen(jjtree)*/
 776          {
 777            jjtree.closeNodeScope(jjtn000, true);
 778            jjtc000 = false;
 779            jjtreeCloseNodeScope(jjtn000);
 780          }
 781/*@egen*/ { jjtn000.type =  Short.TYPE; }
 782| "int"/*@bgen(jjtree)*/
 783        {
 784          jjtree.closeNodeScope(jjtn000, true);
 785          jjtc000 = false;
 786          jjtreeCloseNodeScope(jjtn000);
 787        }
 788/*@egen*/ { jjtn000.type =  Integer.TYPE; }
 789| "long"/*@bgen(jjtree)*/
 790         {
 791           jjtree.closeNodeScope(jjtn000, true);
 792           jjtc000 = false;
 793           jjtreeCloseNodeScope(jjtn000);
 794         }
 795/*@egen*/ { jjtn000.type =  Long.TYPE; }
 796| "float"/*@bgen(jjtree)*/
 797          {
 798            jjtree.closeNodeScope(jjtn000, true);
 799            jjtc000 = false;
 800            jjtreeCloseNodeScope(jjtn000);
 801          }
 802/*@egen*/ { jjtn000.type =  Float.TYPE; }
 803| "double"/*@bgen(jjtree)*/
 804           {
 805             jjtree.closeNodeScope(jjtn000, true);
 806             jjtc000 = false;
 807             jjtreeCloseNodeScope(jjtn000);
 808           }
 809/*@egen*/ { jjtn000.type =  Double.TYPE; }/*@bgen(jjtree)*/
 810} finally {
 811  if (jjtc000) {
 812    jjtree.closeNodeScope(jjtn000, true);
 813    jjtreeCloseNodeScope(jjtn000);
 814  }
 815}
 816/*@egen*/
 817}
 818
 819void AmbiguousName()                :
 820/*
 821 * A lookahead of 2 is required below since "Name" can be followed
 822 * by a ".*" when used in the context of an "ImportDeclaration".
 823 */
 824{/*@bgen(jjtree) AmbiguousName */
 825    BSHAmbiguousName jjtn000 = new BSHAmbiguousName(JJTAMBIGUOUSNAME);
 826    boolean jjtc000 = true;
 827    jjtree.openNodeScope(jjtn000);
 828    jjtreeOpenNodeScope(jjtn000);
 829/*@egen*/
 830    Token t;
 831    StringBuffer s;
 832}
 833{/*@bgen(jjtree) AmbiguousName */
 834  try {
 835/*@egen*/
 836  t = <IDENTIFIER> {
 837        s = new StringBuffer(t.image);
 838    }
 839  ( LOOKAHEAD(2) "." t = <IDENTIFIER> {
 840        s.append("."+t.image);
 841    }
 842  )*/*@bgen(jjtree)*/
 843     {
 844       jjtree.closeNodeScope(jjtn000, true);
 845       jjtc000 = false;
 846       jjtreeCloseNodeScope(jjtn000);
 847     }
 848/*@egen*/ {
 849        jjtn000.text = s.toString();
 850    }/*@bgen(jjtree)*/
 851  } finally {
 852    if (jjtc000) {
 853      jjtree.closeNodeScope(jjtn000, true);
 854      jjtreeCloseNodeScope(jjtn000);
 855    }
 856  }
 857/*@egen*/
 858}
 859
 860/*
 861 * Expression syntax follows.
 862 */
 863void Expression() :
 864{ }
 865{
 866	/**
 867		SYNTACTIC_LOOKAHEAD
 868		This is probably expensive.  Can we simplify it somehow?
 869	*/
 870  LOOKAHEAD( LHSPrimaryExpression() AssignmentOperator() )
 871  Assignment()
 872|
 873  ConditionalExpression()
 874}
 875
 876void Assignment()             :
 877{/*@bgen(jjtree) Assignment */
 878  BSHAssignment jjtn000 = new BSHAssignment(JJTASSIGNMENT);
 879  boolean jjtc000 = true;
 880  jjtree.openNodeScope(jjtn000);
 881  jjtreeOpenNodeScope(jjtn000);
 882/*@egen*/ int op ; }
 883{/*@bgen(jjtree) Assignment */
 884  try {
 885/*@egen*/
 886  LHSPrimaryExpression()
 887  op = AssignmentOperator() {
 888    jjtn000.operator = op;
 889  }
 890  Expression()/*@bgen(jjtree)*/
 891  } catch (Throwable jjte000) {
 892    if (jjtc000) {
 893      jjtree.clearNodeScope(jjtn000);
 894      jjtc000 = false;
 895    } else {
 896      jjtree.popNode();
 897    }
 898    if (jjte000 instanceof RuntimeException) {
 899      throw (RuntimeException)jjte000;
 900    }
 901    if (jjte000 instanceof ParseException) {
 902      throw (ParseException)jjte000;
 903    }
 904    throw (Error)jjte000;
 905  } finally {
 906    if (jjtc000) {
 907      jjtree.closeNodeScope(jjtn000, true);
 908      jjtreeCloseNodeScope(jjtn000);
 909    }
 910  }
 911/*@egen*/
 912}
 913
 914int AssignmentOperator() :
 915{ Token t; }
 916{
 917    ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|=" |
 918      "<<=" | "@left_shift_assign" | ">>=" | "@right_shift_assign" |
 919      ">>>=" | "@right_unsigned_shift_assign" )
 920    {
 921        t = getToken(0);
 922        return t.kind;
 923    }
 924}
 925
 926void ConditionalExpression() : 
 927{ }
 928{
 929  ConditionalOrExpression() [ "?" Expression() ":"/*@bgen(jjtree) #TernaryExpression( 3) */
 930                                                   {
 931                                                     BSHTernaryExpression jjtn001 = new BSHTernaryExpression(JJTTERNARYEXPRESSION);
 932                                                     boolean jjtc001 = true;
 933                                                     jjtree.openNodeScope(jjtn001);
 934                                                     jjtreeOpenNodeScope(jjtn001);
 935                                                   }
 936                                                   try {
 937/*@egen*/ ConditionalExpression()/*@bgen(jjtree)*/
 938                                                   } catch (Throwable jjte001) {
 939                                                     if (jjtc001) {
 940                                                       jjtree.clearNodeScope(jjtn001);
 941                                                       jjtc001 = false;
 942                                                     } else {
 943                                                       jjtree.popNode();
 944                                                     }
 945                                                     if (jjte001 instanceof RuntimeException) {
 946                                                       throw (RuntimeException)jjte001;
 947                                                     }
 948                                                     if (jjte001 instanceof ParseException) {
 949                                                       throw (ParseException)jjte001;
 950                                                     }
 951                                                     throw (Error)jjte001;
 952                                                   } finally {
 953                                                     if (jjtc001) {
 954                                                       jjtree.closeNodeScope(jjtn001,  3);
 955                                                       jjtreeCloseNodeScope(jjtn001);
 956                                                     }
 957                                                   }
 958/*@egen*/ ]
 959}
 960
 961void ConditionalOrExpression() :
 962{ Token t=null; }
 963{
 964  ConditionalAndExpression()
 965  ( ( t = "||" | t = "@or" )
 966    ConditionalAndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
 967    {
 968      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
 969      boolean jjtc001 = true;
 970      jjtree.openNodeScope(jjtn001);
 971      jjtreeOpenNodeScope(jjtn001);
 972    }
 973    try {
 974/*@egen*//*@bgen(jjtree)*/
 975    {
 976      jjtree.closeNodeScope(jjtn001,  2);
 977      jjtc001 = false;
 978      jjtreeCloseNodeScope(jjtn001);
 979    }
 980/*@egen*/
 981    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
 982    } finally {
 983      if (jjtc001) {
 984        jjtree.closeNodeScope(jjtn001,  2);
 985        jjtreeCloseNodeScope(jjtn001);
 986      }
 987    }
 988/*@egen*/ )*
 989}
 990
 991void ConditionalAndExpression() :
 992{ Token t=null; }
 993{
 994  InclusiveOrExpression()
 995  ( ( t = "&&" | t = "@and" )
 996    InclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
 997    {
 998      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
 999      boolean jjtc001 = true;
1000      jjtree.openNodeScope(jjtn001);
1001      jjtreeOpenNodeScope(jjtn001);
1002    }
1003    try {
1004/*@egen*//*@bgen(jjtree)*/
1005    {
1006      jjtree.closeNodeScope(jjtn001,  2);
1007      jjtc001 = false;
1008      jjtreeCloseNodeScope(jjtn001);
1009    }
1010/*@egen*/
1011    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1012    } finally {
1013      if (jjtc001) {
1014        jjtree.closeNodeScope(jjtn001,  2);
1015        jjtreeCloseNodeScope(jjtn001);
1016      }
1017    }
1018/*@egen*/ )*
1019}
1020
1021void InclusiveOrExpression() :
1022{ Token t=null; }
1023{
1024  ExclusiveOrExpression()
1025  ( ( t = "|" | t = "@bitwise_or" )
1026    ExclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1027    {
1028      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1029      boolean jjtc001 = true;
1030      jjtree.openNodeScope(jjtn001);
1031      jjtreeOpenNodeScope(jjtn001);
1032    }
1033    try {
1034/*@egen*//*@bgen(jjtree)*/
1035    {
1036      jjtree.closeNodeScope(jjtn001,  2);
1037      jjtc001 = false;
1038      jjtreeCloseNodeScope(jjtn001);
1039    }
1040/*@egen*/
1041    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1042    } finally {
1043      if (jjtc001) {
1044        jjtree.closeNodeScope(jjtn001,  2);
1045        jjtreeCloseNodeScope(jjtn001);
1046      }
1047    }
1048/*@egen*/ )*
1049}
1050
1051void ExclusiveOrExpression() :
1052{ Token t=null; }
1053{
1054  AndExpression() ( t="^" AndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1055    {
1056      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1057      boolean jjtc001 = true;
1058      jjtree.openNodeScope(jjtn001);
1059      jjtreeOpenNodeScope(jjtn001);
1060    }
1061    try {
1062/*@egen*//*@bgen(jjtree)*/
1063    {
1064      jjtree.closeNodeScope(jjtn001,  2);
1065      jjtc001 = false;
1066      jjtreeCloseNodeScope(jjtn001);
1067    }
1068/*@egen*/
1069    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1070    } finally {
1071      if (jjtc001) {
1072        jjtree.closeNodeScope(jjtn001,  2);
1073        jjtreeCloseNodeScope(jjtn001);
1074      }
1075    }
1076/*@egen*/ )*
1077}
1078
1079void AndExpression() :
1080{ Token t=null; }
1081{
1082  EqualityExpression()
1083  ( ( t = "&" | t = "@bitwise_and" )
1084    EqualityExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1085    {
1086      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1087      boolean jjtc001 = true;
1088      jjtree.openNodeScope(jjtn001);
1089      jjtreeOpenNodeScope(jjtn001);
1090    }
1091    try {
1092/*@egen*//*@bgen(jjtree)*/
1093    {
1094      jjtree.closeNodeScope(jjtn001,  2);
1095      jjtc001 = false;
1096      jjtreeCloseNodeScope(jjtn001);
1097    }
1098/*@egen*/
1099    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1100    } finally {
1101      if (jjtc001) {
1102        jjtree.closeNodeScope(jjtn001,  2);
1103        jjtreeCloseNodeScope(jjtn001);
1104      }
1105    }
1106/*@egen*/ )*
1107}
1108
1109void EqualityExpression() :
1110{ Token t = null; }
1111{
1112  InstanceOfExpression() ( ( t= "==" | t= "!=" ) InstanceOfExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1113    {
1114      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1115      boolean jjtc001 = true;
1116      jjtree.openNodeScope(jjtn001);
1117      jjtreeOpenNodeScope(jjtn001);
1118    }
1119    try {
1120/*@egen*//*@bgen(jjtree)*/
1121    {
1122      jjtree.closeNodeScope(jjtn001,  2);
1123      jjtc001 = false;
1124      jjtreeCloseNodeScope(jjtn001);
1125    }
1126/*@egen*/
1127    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1128    } finally {
1129      if (jjtc001) {
1130        jjtree.closeNodeScope(jjtn001,  2);
1131        jjtreeCloseNodeScope(jjtn001);
1132      }
1133    }
1134/*@egen*/
1135  )*
1136}
1137
1138void InstanceOfExpression() :
1139{ Token t = null; }
1140{
1141  RelationalExpression()
1142  [ t = "instanceof" Type()/*@bgen(jjtree) #BinaryExpression( 2) */
1143                            {
1144                              BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1145                              boolean jjtc001 = true;
1146                              jjtree.openNodeScope(jjtn001);
1147                              jjtreeOpenNodeScope(jjtn001);
1148                            }
1149                            try {
1150/*@egen*//*@bgen(jjtree)*/
1151                            {
1152                              jjtree.closeNodeScope(jjtn001,  2);
1153                              jjtc001 = false;
1154                              jjtreeCloseNodeScope(jjtn001);
1155                            }
1156/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1157                            } finally {
1158                              if (jjtc001) {
1159                                jjtree.closeNodeScope(jjtn001,  2);
1160                                jjtreeCloseNodeScope(jjtn001);
1161                              }
1162                            }
1163/*@egen*/ ]
1164}
1165
1166void RelationalExpression() :
1167{ Token t = null; }
1168{
1169  ShiftExpression()
1170  ( ( t = "<" | t = "@lt" | t = ">" | t = "@gt" |
1171      t = "<=" | t = "@lteq" | t = ">=" | t = "@gteq" )
1172  ShiftExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1173  {
1174    BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1175    boolean jjtc001 = true;
1176    jjtree.openNodeScope(jjtn001);
1177    jjtreeOpenNodeScope(jjtn001);
1178  }
1179  try {
1180/*@egen*//*@bgen(jjtree)*/
1181  {
1182    jjtree.closeNodeScope(jjtn001,  2);
1183    jjtc001 = false;
1184    jjtreeCloseNodeScope(jjtn001);
1185  }
1186/*@egen*/
1187  { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1188  } finally {
1189    if (jjtc001) {
1190      jjtree.closeNodeScope(jjtn001,  2);
1191      jjtreeCloseNodeScope(jjtn001);
1192    }
1193  }
1194/*@egen*/ )*
1195}
1196
1197void ShiftExpression() :
1198{ Token t = null; }
1199{
1200  AdditiveExpression()
1201  ( ( t = "<<" | t = "@left_shift" | t = ">>" | t = "@right_shift" |
1202      t = ">>>" | t = "@right_unsigned_shift" )
1203  AdditiveExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1204  {
1205    BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1206    boolean jjtc001 = true;
1207    jjtree.openNodeScope(jjtn001);
1208    jjtreeOpenNodeScope(jjtn001);
1209  }
1210  try {
1211/*@egen*//*@bgen(jjtree)*/
1212  {
1213    jjtree.closeNodeScope(jjtn001,  2);
1214    jjtc001 = false;
1215    jjtreeCloseNodeScope(jjtn001);
1216  }
1217/*@egen*/
1218  { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1219  } finally {
1220    if (jjtc001) {
1221      jjtree.closeNodeScope(jjtn001,  2);
1222      jjtreeCloseNodeScope(jjtn001);
1223    }
1224  }
1225/*@egen*/ )*
1226}
1227
1228void AdditiveExpression() :
1229{ Token t = null; }
1230{
1231  MultiplicativeExpression()
1232  ( ( t= "+" | t= "-" ) MultiplicativeExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1233                                                   {
1234                                                     BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1235                                                     boolean jjtc001 = true;
1236                                                     jjtree.openNodeScope(jjtn001);
1237                                                     jjtreeOpenNodeScope(jjtn001);
1238                                                   }
1239                                                   try {
1240/*@egen*//*@bgen(jjtree)*/
1241                                                   {
1242                                                     jjtree.closeNodeScope(jjtn001,  2);
1243                                                     jjtc001 = false;
1244                                                     jjtreeCloseNodeScope(jjtn001);
1245                                                   }
1246/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1247                                                   } finally {
1248                                                     if (jjtc001) {
1249                                                       jjtree.closeNodeScope(jjtn001,  2);
1250                                                       jjtreeCloseNodeScope(jjtn001);
1251                                                     }
1252                                                   }
1253/*@egen*/
1254  )*
1255}
1256
1257void MultiplicativeExpression() :
1258{ Token t = null; }
1259{
1260  UnaryExpression() ( ( t= "*" | t= "/" | t= "%" )
1261  UnaryExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1262                    {
1263                      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1264                      boolean jjtc001 = true;
1265                      jjtree.openNodeScope(jjtn001);
1266                      jjtreeOpenNodeScope(jjtn001);
1267                    }
1268                    try {
1269/*@egen*//*@bgen(jjtree)*/
1270                    {
1271                      jjtree.closeNodeScope(jjtn001,  2);
1272                      jjtc001 = false;
1273                      jjtreeCloseNodeScope(jjtn001);
1274                    }
1275/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1276                    } finally {
1277                      if (jjtc001) {
1278                        jjtree.closeNodeScope(jjtn001,  2);
1279                        jjtreeCloseNodeScope(jjtn001);
1280                      }
1281                    }
1282/*@egen*/ )*
1283}
1284
1285void UnaryExpression() :
1286{ Token t = null; }
1287{
1288  ( t="+" | t="-" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1289    {
1290      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1291      boolean jjtc001 = true;
1292      jjtree.openNodeScope(jjtn001);
1293      jjtreeOpenNodeScope(jjtn001);
1294    }
1295    try {
1296/*@egen*//*@bgen(jjtree)*/
1297    {
1298      jjtree.closeNodeScope(jjtn001,  1);
1299      jjtc001 = false;
1300      jjtreeCloseNodeScope(jjtn001);
1301    }
1302/*@egen*/
1303    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1304    } finally {
1305      if (jjtc001) {
1306        jjtree.closeNodeScope(jjtn001,  1);
1307        jjtreeCloseNodeScope(jjtn001);
1308      }
1309    }
1310/*@egen*/
1311|
1312  PreIncrementExpression()
1313|
1314  PreDecrementExpression()
1315|
1316  UnaryExpressionNotPlusMinus()
1317}
1318
1319void PreIncrementExpression() :
1320{ Token t = null; }
1321{
1322  t="++" LHSPrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1323    {
1324      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1325      boolean jjtc001 = true;
1326      jjtree.openNodeScope(jjtn001);
1327      jjtreeOpenNodeScope(jjtn001);
1328    }
1329    try {
1330/*@egen*//*@bgen(jjtree)*/
1331    {
1332      jjtree.closeNodeScope(jjtn001,  1);
1333      jjtc001 = false;
1334      jjtreeCloseNodeScope(jjtn001);
1335    }
1336/*@egen*/
1337    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1338    } finally {
1339      if (jjtc001) {
1340        jjtree.closeNodeScope(jjtn001,  1);
1341        jjtreeCloseNodeScope(jjtn001);
1342      }
1343    }
1344/*@egen*/
1345}
1346
1347void PreDecrementExpression() :
1348{ Token t = null; }
1349{
1350  t="--" LHSPrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1351    {
1352      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1353      boolean jjtc001 = true;
1354      jjtree.openNodeScope(jjtn001);
1355      jjtreeOpenNodeScope(jjtn001);
1356    }
1357    try {
1358/*@egen*//*@bgen(jjtree)*/
1359    {
1360      jjtree.closeNodeScope(jjtn001,  1);
1361      jjtc001 = false;
1362      jjtreeCloseNodeScope(jjtn001);
1363    }
1364/*@egen*/
1365    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1366    } finally {
1367      if (jjtc001) {
1368        jjtree.closeNodeScope(jjtn001,  1);
1369        jjtreeCloseNodeScope(jjtn001);
1370      }
1371    }
1372/*@egen*/
1373}
1374
1375void UnaryExpressionNotPlusMinus() :
1376{ Token t = null; }
1377{
1378  ( t="~" | t="!" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1379    {
1380      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1381      boolean jjtc001 = true;
1382      jjtree.openNodeScope(jjtn001);
1383      jjtreeOpenNodeScope(jjtn001);
1384    }
1385    try {
1386/*@egen*//*@bgen(jjtree)*/
1387    {
1388      jjtree.closeNodeScope(jjtn001,  1);
1389      jjtc001 = false;
1390      jjtreeCloseNodeScope(jjtn001);
1391    }
1392/*@egen*/
1393    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1394    } finally {
1395      if (jjtc001) {
1396        jjtree.closeNodeScope(jjtn001,  1);
1397        jjtreeCloseNodeScope(jjtn001);
1398      }
1399    }
1400/*@egen*/
1401|
1402	// SYNTACTIC_LOOKAHEAD
1403  LOOKAHEAD( CastLookahead() ) CastExpression()
1404|
1405  PostfixExpression()
1406}
1407
1408// This production is to determine lookahead only.
1409void CastLookahead() : { }
1410{
1411  LOOKAHEAD(2) "(" PrimitiveType()
1412|
1413// SYNTACTIC_LOOKAHEAD
1414  LOOKAHEAD( "(" AmbiguousName() "[" ) "(" AmbiguousName() "[" "]"
1415|
1416  "(" AmbiguousName() ")" ( "~" | "!" | "(" | <IDENTIFIER> | /* "this" | "super" | */ "new" | Literal() )
1417}
1418
1419void PostfixExpression() :
1420{ Token t = null; }
1421{
1422 (
1423// SYNTACTIC_LOOKAHEAD
1424  LOOKAHEAD( LHSPrimaryExpression() ("++"|"--") )
1425  LHSPrimaryExpression()
1426	  [ ( t="++" | t="--" )/*@bgen(jjtree) #UnaryExpression( 1) */
1427                                {
1428                                  BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1429                                  boolean jjtc001 = true;
1430                                  jjtree.openNodeScope(jjtn001);
1431                                  jjtreeOpenNodeScope(jjtn001);
1432                                }
1433                                try {
1434/*@egen*//*@bgen(jjtree)*/
1435                                {
1436                                  jjtree.closeNodeScope(jjtn001,  1);
1437                                  jjtc001 = false;
1438                                  jjtreeCloseNodeScope(jjtn001);
1439                                }
1440/*@egen*/ { 
1441		jjtn001.kind = t.kind; jjtn001.postfix = true; }/*@bgen(jjtree)*/
1442                                } finally {
1443                                  if (jjtc001) {
1444                                    jjtree.closeNodeScope(jjtn001,  1);
1445                                    jjtreeCloseNodeScope(jjtn001);
1446                                  }
1447                                }
1448/*@egen*/ ]
1449|
1450  PrimaryExpression()
1451 )
1452}
1453
1454void CastExpression()                 :
1455{/*@bgen(jjtree) CastExpression */
1456  BSHCastExpression jjtn000 = new BSHCastExpression(JJTCASTEXPRESSION);
1457  boolean jjtc000 = true;
1458  jjtree.openNodeScope(jjtn000);
1459  jjtreeOpenNodeScope(jjtn000);
1460/*@egen*/ }
1461{/*@bgen(jjtree) CastExpression */
1462  try {
1463/*@egen*/
1464// SYNTACTIC_LOOKAHEAD
1465  LOOKAHEAD( "(" PrimitiveType() ) "(" Type() ")" UnaryExpression()
1466|
1467  "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
1468  } catch (Throwable jjte000) {
1469    if (jjtc000) {
1470      jjtree.clearNodeScope(jjtn000);
1471      jjtc000 = false;
1472    } else {
1473      jjtree.popNode();
1474    }
1475    if (jjte000 instanceof RuntimeException) {
1476      throw (RuntimeException)jjte000;
1477    }
1478    if (jjte000 instanceof ParseException) {
1479      throw (ParseException)jjte000;
1480    }
1481    throw (Error)jjte000;
1482  } finally {
1483    if (jjtc000) {
1484      jjtree.closeNodeScope(jjtn000, true);
1485      jjtreeCloseNodeScope(jjtn000);
1486    }
1487  }
1488/*@egen*/
1489}
1490
1491void PrimaryExpression()                    : {/*@bgen(jjtree) PrimaryExpression */
1492  BSHPrimaryExpression jjtn000 = new BSHPrimaryExpression(JJTPRIMARYEXPRESSION);
1493  boolean jjtc000 = true;
1494  jjtree.openNodeScope(jjtn000);
1495  jjtreeOpenNodeScope(jjtn000);
1496/*@egen*/ }
1497{/*@bgen(jjtree) PrimaryExpression */
1498 try {
1499/*@egen*/
1500 PrimaryPrefix() ( PrimarySuffix() )*/*@bgen(jjtree)*/
1501 } catch (Throwable jjte000) {
1502   if (jjtc000) {
1503     jjtree.clearNodeScope(jjtn000);
1504     jjtc000 = false;
1505   } else {
1506     jjtree.popNode();
1507   }
1508   if (jjte000 instanceof RuntimeException) {
1509     throw (RuntimeException)jjte000;
1510   }
1511   if (jjte000 instanceof ParseException) {
1512     throw (ParseException)jjte000;
1513   }
1514   throw (Error)jjte000;
1515 } finally {
1516   if (jjtc000) {
1517     jjtree.closeNodeScope(jjtn000, true);
1518     jjtreeCloseNodeScope(jjtn000);
1519   }
1520 }
1521/*@egen*/
1522}
1523
1524// The MethodInvocation node here simplifies the prefix/suffix parsing a bit
1525//  by forcing the prefix to an object.
1526void PrimaryPrefix() : { }
1527{
1528  Literal()
1529|
1530  "(" Expression() ")"
1531|
1532  AllocationExpression()
1533|
1534// SYNTACTIC_LOOKAHEAD
1535  LOOKAHEAD( Type() "." "class" )
1536  Type()
1537|/*@bgen(jjtree) #MethodInvocation(> 1) */
1538  {
1539    BSHMethodInvocation jjtn001 = new BSHMethodInvocation(JJTMETHODINVOCATION);
1540    boolean jjtc001 = true;
1541    jjtree.openNodeScope(jjtn001);
1542    jjtreeOpenNodeScope(jjtn001);
1543  }
1544  try {
1545/*@egen*/
1546	/* 
1547		Handle method invocation OR straight ambigous name...
1548		(probably should just write this as two rules more clearly)
1549	*/ 
1550  ( AmbiguousName() [ Arguments() ]  )/*@bgen(jjtree)*/
1551  } catch (Throwable jjte001) {
1552    if (jjtc001) {
1553      jjtree.clearNodeScope(jjtn001);
1554      jjtc001 = false;
1555    } else {
1556      jjtree.popNode();
1557    }
1558    if (jjte001 instanceof RuntimeException) {
1559      throw (RuntimeException)jjte001;
1560    }
1561    if (jjte001 instanceof ParseException) {
1562      throw (ParseException)jjte001;
1563    }
1564    throw (Error)jjte001;
1565  } finally {
1566    if (jjtc001) {
1567      jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1);
1568      jjtreeCloseNodeScope(jjtn001);
1569    }
1570  }
1571/*@egen*/
1572
1573/*
1574|
1575  LOOKAHEAD( "void" "." "class" )
1576*/
1577}
1578
1579void PrimarySuffix()                :
1580{/*@bgen(jjtree) PrimarySuffix */
1581    BSHPrimarySuffix jjtn000 = new BSHPrimarySuffix(JJTPRIMARYSUFFIX);
1582    boolean jjtc000 = true;
1583    jjtree.openNodeScope(jjtn000);
1584    jjtreeOpenNodeScope(jjtn000);
1585/*@egen*/
1586    Token t = null;
1587}
1588{/*@bgen(jjtree) PrimarySuffix */
1589  try {
1590/*@egen*/
1591  LOOKAHEAD(2)
1592  "." "class"/*@bgen(jjtree)*/
1593              {
1594                jjtree.closeNodeScope(jjtn000, true);
1595                jjtc000 = false;
1596                jjtreeCloseNodeScope(jjtn000);
1597              }
1598/*@egen*/ {
1599        jjtn000.operation = BSHPrimarySuffix.CLASS;
1600    }
1601|
1602  "[" Expression() "]"/*@bgen(jjtree)*/
1603                       {
1604                         jjtree.closeNodeScope(jjtn000, true);
1605                         jjtc000 = false;
1606                         jjtreeCloseNodeScope(jjtn000);
1607                       }
1608/*@egen*/ {
1609        jjtn000.operation = BSHPrimarySuffix.INDEX;
1610    }
1611|
1612    // Field access or method invocation
1613  "." t = <IDENTIFIER> [ Arguments() ]/*@bgen(jjtree)*/
1614                                       {
1615                                         jjtree.closeNodeScope(jjtn000, true);
1616                                         jjtc000 = false;
1617                                         jjtreeCloseNodeScope(jjtn000);
1618                                       }
1619/*@egen*/ {
1620        jjtn000.operation = BSHPrimarySuffix.NAME;
1621        jjtn000.field = t.image;
1622    }
1623|
1624  "{" Expression() "}"/*@bgen(jjtree)*/
1625                       {
1626                         jjtree.closeNodeScope(jjtn000, true);
1627                         jjtc000 = false;
1628                         jjtreeCloseNodeScope(jjtn000);
1629                       }
1630/*@egen*/ {
1631        jjtn000.operation = BSHPrimarySuffix.PROPERTY;
1632    }/*@bgen(jjtree)*/
1633  } catch (Throwable jjte000) {
1634    if (jjtc000) {
1635      jjtree.clearNodeScope(jjtn000);
1636      jjtc000 = false;
1637    } else {
1638      jjtree.popNode();
1639    }
1640    if (jjte000 instanceof RuntimeException) {
1641      throw (RuntimeException)jjte000;
1642    }
1643    if (jjte000 instanceof ParseException) {
1644      throw (ParseException)jjte000;
1645    }
1646    throw (Error)jjte000;
1647  } finally {
1648    if (jjtc000) {
1649      jjtree.closeNodeScope(jjtn000, true);
1650      jjtreeCloseNodeScope(jjtn000);
1651    }
1652  }
1653/*@egen*/
1654/*
1655    For inner classes
1656|
1657  LOOKAHEAD(2)
1658  "." AllocationExpression()
1659*/
1660}
1661
1662
1663/*
1664	Begin LHS part of the grammar --
1665
1666	The reason this stuff is duplicated (e.g. LHSPrimaryPrefix and 
1667	PrimaryPrefix) is that the whole grammar splits based on whether we 
1668	are preparig to do an assignment or not.  This is an important issue 
1669	to revisit in the future.
1670*/
1671/**
1672	The method invocation is here to force this to an object type in order 
1673	to simplify the suffix processing.  
1674*/
1675void LHSPrimaryPrefix() : { }
1676{/*@bgen(jjtree) #MethodInvocation(> 1) */
1677  {
1678    BSHMethodInvocation jjtn001 = new BSHMethodInvocation(JJTMETHODINVOCATION);
1679    boolean jjtc001 = true;
1680    jjtree.openNodeScope(jjtn001);
1681    jjtreeOpenNodeScope(jjtn001);
1682  }
1683  try {
1684/*@egen*/
1685	/* 
1686		Method invocation or simple ambiguous name.
1687		(probably should just write this as two rules more clearly)
1688	*/ 
1689  ( AmbiguousName() [ Arguments() ]  )/*@bgen(jjtree)*/
1690  } catch (Throwable jjte001) {
1691    if (jjtc001) {
1692      jjtree.clearNodeScope(jjtn001);
1693      jjtc001 = false;
1694    } else {
1695      jjtree.popNode();
1696    }
1697    if (jjte001 instanceof RuntimeException) {
1698      throw (RuntimeException)jjte001;
1699    }
1700    if (jjte001 instanceof ParseException) {
1701      throw (ParseException)jjte001;
1702    }
1703    throw (Error)jjte001;
1704  } finally {
1705    if (jjtc001) {
1706      jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1);
1707      jjtreeCloseNodeScope(jjtn001);
1708    }
1709  }
1710/*@egen*/
1711}
1712
1713void LHSPrimaryExpression()                       : {/*@bgen(jjtree) LHSPrimaryExpression */
1714  BSHLHSPrimaryExpression jjtn000 = new BSHLHSPrimaryExpression(JJTLHSPRIMARYEXPRESSION);
1715  boolean jjtc000 = true;
1716  jjtree.openNodeScope(jjtn000);
1717  jjtreeOpenNodeScope(jjtn000);
1718/*@egen*/ }
1719{/*@bgen(jjtree) LHSPrimaryExpression */
1720  try {
1721/*@egen*/
1722  LHSPrimaryPrefix() ( LHSPrimarySuffix( ) )*/*@bgen(jjtree)*/
1723  } catch (Throwable jjte000) {
1724    if (jjtc000) {
1725      jjtree.clearNodeScope(jjtn000);
1726      jjtc000 = false;
1727    } else {
1728      jjtree.popNode();
1729    }
1730    if (jjte000 instanceof RuntimeException) {
1731      throw (RuntimeException)jjte000;
1732    }
1733    if (jjte000 instanceof ParseException) {
1734      throw (ParseException)jjte000;
1735    }
1736    throw (Error)jjte000;
1737  } finally {
1738    if (jjtc000) {
1739      jjtree.closeNodeScope(jjtn000, true);
1740      jjtreeCloseNodeScope(jjtn000);
1741    }
1742  }
1743/*@egen*/
1744}
1745
1746void LHSPrimarySuffix()                   :
1747{/*@bgen(jjtree) LHSPrimarySuffix */
1748    BSHLHSPrimarySuffix jjtn000 = new BSHLHSPrimarySuffix(JJTLHSPRIMARYSUFFIX);
1749    boolean jjtc000 = true;
1750    jjtree.openNodeScope(jjtn000);
1751    jjtreeOpenNodeScope(jjtn000);
1752/*@egen*/
1753    Token t=null, t1, t2 = null;
1754}
1755{/*@bgen(jjtree) LHSPrimarySuffix */
1756  try {
1757/*@egen*/
1758    // Indexed to a field
1759  "[" Expression() "]"/*@bgen(jjtree)*/
1760                       {
1761                         jjtree.closeNodeScope(jjtn000, true);
1762                         jjtc000 = false;
1763                         jjtreeCloseNodeScope(jjtn000);
1764                       }
1765/*@egen*/ {
1766        jjtn000.operation = BSHLHSPrimarySuffix.INDEX;
1767    }
1768|
1769    // Field access or method invocation followed by field access
1770  "." t1 = <IDENTIFIER> [ Arguments() "." t2 = <IDENTIFIER> ]/*@bgen(jjtree)*/
1771                                                              {
1772                                                                jjtree.closeNodeScope(jjtn0

Large files files are truncated, but you can click here to view the full file