PageRenderTime 505ms CodeModel.GetById 351ms app.highlight 139ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/bsh/bsh.jj

#
Unknown | 2426 lines | 2327 code | 99 blank | 0 comment | 0 complexity | f89cbe7a83ffa7a652e500e3e08d8f94 MD5 | raw file

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

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