PageRenderTime 6ms CodeModel.GetById 143ms app.highlight 79ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/bsh/bsh.jj

#
Unknown | 2431 lines | 2327 code | 104 blank | 0 comment | 0 complexity | 533d4ebc6f351bd196d1df3f83e99ee3 MD5 | raw 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.*;
  59
  60/**
  61	This is the BeanShell parser.  It is used internally by the Interpreter
  62	class (which is probably what you are looking for).  The parser knows
  63	only how to parse the structure of the language, it does not understand
  64	names, commands, etc.
  65	<p>
  66	You can use the Parser from the command line to do basic structural 
  67	validation of BeanShell files without actually executing them. e.g.
  68	<code><pre>
  69		java bsh.Parser [ -p ] file [ file ] [ ... ]
  70	</pre></code>
  71	<p>
  72	The -p option causes the abstract syntax to be printed.
  73	<p>
  74
  75	From code you'd use the Parser like this:
  76	<p
  77	<code><pre>
  78		Parser parser = new Parser(in);
  79		while( !(eof=parser.Line()) ) {
  80			SimpleNode node = parser.popNode();
  81			// use the node, etc. (See bsh.BSH* classes)
  82		}
  83	</pre></code>
  84*/
  85public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/ 
  86{/*@bgen(jjtree)*/
  87  protected JJTParserState jjtree = new JJTParserState();
  88
  89/*@egen*/ 
  90	boolean retainComments = false;
  91	
  92	public void setRetainComments( boolean b ) {
  93		retainComments = b;
  94	}
  95
  96	void jjtreeOpenNodeScope(Node n) {
  97		((SimpleNode)n).firstToken = getToken(1);
  98	}
  99
 100	void jjtreeCloseNodeScope(Node n) {
 101		((SimpleNode)n).lastToken = getToken(0);
 102	}
 103
 104	/**
 105		Re-initialize the input stream and token source.
 106	*/
 107	void reInitInput( Reader in ) {
 108		ReInit(in);
 109	}
 110
 111	public SimpleNode popNode() 
 112	{
 113		if ( jjtree.nodeArity() > 0)  // number of child nodes 
 114			return (SimpleNode)jjtree.popNode();
 115		else
 116			return null;
 117	}
 118
 119	/**
 120		Explicitly re-initialize just the token reader.
 121		This seems to be necessary to avoid certain looping errors when
 122		reading bogus input.  See Interpreter.
 123	*/
 124	void reInitTokenInput( Reader in ) {
 125		jj_input_stream.ReInit( in, 
 126			jj_input_stream.getEndLine(), 
 127			jj_input_stream.getEndColumn() );
 128	}
 129
 130	public static void main( String [] args ) 
 131		throws IOException, ParseException
 132	{
 133		boolean print = false;
 134		int i=0;
 135		if ( args[0].equals("-p") ) {
 136			i++;
 137			print=true;
 138		}
 139		for(; i< args.length; i++) {
 140			Reader in = new FileReader(args[i]);
 141			Parser parser = new Parser(in);
 142			parser.setRetainComments(true);
 143			while( !parser.Line()/*eof*/ )
 144				if ( print )
 145					System.out.println( parser.popNode() );
 146		}
 147	}
 148
 149}
 150
 151
 152PARSER_END(Parser)
 153
 154SKIP : /* WHITE SPACE */
 155{ 
 156	" " | "\t" | "\r" | "\f"
 157	| "\n" 
 158	| < NONPRINTABLE: (["\u0000"-" ", "\u0080"-"\u00ff"])+ >
 159}
 160
 161SPECIAL_TOKEN : /* COMMENTS */
 162{
 163/*
 164	SINGLE_LINE_COMMENT includes a hack to accept SLC at the end of a file
 165	with no terminanting linefeed.  This is actually illegal according to 
 166	spec, but comes up often enough to warrant it... (especially in eval()).
 167*/
 168  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
 169
 170| <HASH_BANG_COMMENT: "#!" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
 171
 172 /* Moved FORMAL_COMMENT to a real token.  Modified MULTI_LINE_COMMENT to not 
 173    catch formal comments (require no star after star) */
 174| <MULTI_LINE_COMMENT: 
 175	"/*" (~["*"])+ "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
 176}
 177
 178TOKEN : /* RESERVED WORDS AND LITERALS */
 179{
 180< BOOLEAN: "boolean" >
 181| < BREAK: "break" >
 182| < CLASS: "class" >
 183| < BYTE: "byte" >
 184| < CASE: "case" >
 185| < CATCH: "catch" >
 186| < CHAR: "char" >
 187| < CONST: "const" >
 188| < CONTINUE: "continue" >
 189| < _DEFAULT: "default" >
 190| < DO: "do" >
 191| < DOUBLE: "double" >
 192| < ELSE: "else" >
 193| < FALSE: "false" >
 194| < FINAL: "final" >
 195| < FINALLY: "finally" >
 196| < FLOAT: "float" >
 197| < FOR: "for" >
 198| < GOTO: "goto" >
 199| < IF: "if" >
 200| < IMPORT: "import" >
 201| < INSTANCEOF: "instanceof" >
 202| < INT: "int" >
 203| < INTERFACE: "interface" >
 204| < LONG: "long" >
 205| < NEW: "new" >
 206| < NULL: "null" >
 207| < PRIVATE: "private" >
 208| < PROTECTED: "protected" >
 209| < PUBLIC: "public" >
 210| < RETURN: "return" >
 211| < SHORT: "short" >
 212| < STATIC: "static" >
 213| < SWITCH: "switch" >
 214| < THROW: "throw" >
 215| < TRUE: "true" >
 216| < TRY: "try" >
 217| < VOID: "void" >
 218| < WHILE: "while" >
 219}
 220
 221TOKEN : /* LITERALS */
 222{
 223  < INTEGER_LITERAL:
 224        <DECIMAL_LITERAL> (["l","L"])?
 225      | <HEX_LITERAL> (["l","L"])?
 226      | <OCTAL_LITERAL> (["l","L"])?
 227  >
 228|
 229  < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
 230|
 231  < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
 232|
 233  < #OCTAL_LITERAL: "0" (["0"-"7"])* >
 234|
 235  < FLOATING_POINT_LITERAL:
 236        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
 237      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
 238      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
 239      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
 240  >
 241|
 242  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
 243|
 244  < CHARACTER_LITERAL:
 245      "'"
 246      (   (~["'","\\","\n","\r"])
 247        | ("\\"
 248            ( ["n","t","b","r","f","\\","'","\""]
 249            | ["0"-"7"] ( ["0"-"7"] )?
 250            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
 251            )
 252          )
 253      )
 254      "'"
 255  >
 256|
 257  < STRING_LITERAL:
 258      "\""
 259      (   (~["\"","\\","\n","\r"])
 260        | ("\\"
 261            ( ["n","t","b","r","f","\\","'","\""]
 262            | ["0"-"7"] ( ["0"-"7"] )?
 263            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
 264            )
 265          )
 266      )*
 267      "\""
 268  >
 269|
 270   < FORMAL_COMMENT: 
 271		"/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/"
 272	>
 273}
 274
 275TOKEN : /* IDENTIFIERS */
 276{
 277  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
 278|
 279  < #LETTER:
 280      [
 281       "$",
 282       "A"-"Z",
 283       "_",
 284       "a"-"z",
 285       "\u00c0"-"\u00d6",
 286       "\u00d8"-"\u00f6",
 287       "\u00f8"-"\u00ff",
 288       "\u0100"-"\u1fff",
 289       "\u3040"-"\u318f",
 290       "\u3300"-"\u337f",
 291       "\u3400"-"\u3d2d",
 292       "\u4e00"-"\u9fff",
 293       "\uf900"-"\ufaff"
 294      ]
 295  >
 296|
 297  < #DIGIT:
 298      [
 299       "0"-"9",
 300       "\u0660"-"\u0669",
 301       "\u06f0"-"\u06f9",
 302       "\u0966"-"\u096f",
 303       "\u09e6"-"\u09ef",
 304       "\u0a66"-"\u0a6f",
 305       "\u0ae6"-"\u0aef",
 306       "\u0b66"-"\u0b6f",
 307       "\u0be7"-"\u0bef",
 308       "\u0c66"-"\u0c6f",
 309       "\u0ce6"-"\u0cef",
 310       "\u0d66"-"\u0d6f",
 311       "\u0e50"-"\u0e59",
 312       "\u0ed0"-"\u0ed9",
 313       "\u1040"-"\u1049"
 314      ]
 315  >
 316}
 317
 318TOKEN : /* SEPARATORS */
 319{
 320  < LPAREN: "(" >
 321| < RPAREN: ")" >
 322| < LBRACE: "{" >
 323| < RBRACE: "}" >
 324| < LBRACKET: "[" >
 325| < RBRACKET: "]" >
 326| < SEMICOLON: ";" >
 327| < COMMA: "," >
 328| < DOT: "." >
 329}
 330
 331TOKEN : /* OPERATORS */
 332{
 333  < ASSIGN: "=" >
 334| < GT: ">" >
 335| < GTX: "@gt" >
 336| < LT: "<" >
 337| < LTX: "@lt" >
 338| < BANG: "!" >
 339| < TILDE: "~" >
 340| < HOOK: "?" >
 341| < COLON: ":" >
 342| < EQ: "==" >
 343| < LE: "<=" >
 344| < LEX: "@lteq" >
 345| < GE: ">=" >
 346| < GEX: "@gteq" >
 347| < NE: "!=" >
 348| < BOOL_OR: "||" >
 349| < BOOL_ORX: "@or" >
 350| < BOOL_AND: "&&" >
 351| < BOOL_ANDX: "@and" >
 352| < INCR: "++" >
 353| < DECR: "--" >
 354| < PLUS: "+" >
 355| < MINUS: "-" >
 356| < STAR: "*" >
 357| < SLASH: "/" >
 358| < BIT_AND: "&" >
 359| < BIT_ANDX: "@bitwise_and" >
 360| < BIT_OR: "|" >
 361| < BIT_ORX: "@bitwise_or" >
 362| < XOR: "^" >
 363| < MOD: "%" >
 364| < LSHIFT: "<<" >
 365| < LSHIFTX: "@left_shift" >
 366| < RSIGNEDSHIFT: ">>" >
 367| < RSIGNEDSHIFTX: "@right_shift" >
 368| < RUNSIGNEDSHIFT: ">>>" >
 369| < RUNSIGNEDSHIFTX: "@right_unsigned_shift" >
 370| < PLUSASSIGN: "+=" >
 371| < MINUSASSIGN: "-=" >
 372| < STARASSIGN: "*=" >
 373| < SLASHASSIGN: "/=" >
 374| < ANDASSIGN: "&=" >
 375| < ANDASSIGNX: "@and_assign" >
 376| < ORASSIGN: "|=" >
 377| < ORASSIGNX: "@or_assign" >
 378| < XORASSIGN: "^=" >
 379| < MODASSIGN: "%=" >
 380| < LSHIFTASSIGN: "<<=" >
 381| < LSHIFTASSIGNX: "@left_shift_assign" >
 382| < RSIGNEDSHIFTASSIGN: ">>=" >
 383| < RSIGNEDSHIFTASSIGNX: "@right_shift_assign" >
 384| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
 385| < RUNSIGNEDSHIFTASSIGNX: "@right_unsigned_shift_assign" >
 386}
 387
 388
 389boolean Line() :
 390{}
 391{
 392  <EOF> { 
 393	Interpreter.debug("End of File!"); 
 394	return true; 
 395	}
 396|
 397  (
 398	/*
 399		SYNTACTIC_LOOKAHEAD
 400		I'm guessing this is expensive, but I don't know how to work around
 401		it...  Is there another syntactic indication that we are working 
 402		through an expression as opposed to a statement?
 403		What is the difference?  Well, some statements don't require a
 404		semicolon and they don't return vlues...  We could probably broaden
 405		bsh to allow everything to return a value, but the semi-colon thing
 406		is tougher.  You don't want to have to say if ( foo ) { } ;
 407		Maybe we can invert ths and enumerate all of those types of 
 408		statements in a special lookahead that's cheaper??
 409	*/
 410   LOOKAHEAD( Expression() ";" )
 411   Expression() ";" 
 412  |
 413   BlockStatement()
 414  )
 415	{ 
 416		return false; 
 417	}
 418}
 419
 420/*****************************************
 421 * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
 422 *****************************************/
 423
 424void MethodDeclaration()                    :
 425{/*@bgen(jjtree) MethodDeclaration */
 426  BSHMethodDeclaration jjtn000 = new BSHMethodDeclaration(JJTMETHODDECLARATION);
 427  boolean jjtc000 = true;
 428  jjtree.openNodeScope(jjtn000);
 429  jjtreeOpenNodeScope(jjtn000);
 430/*@egen*/ Token t = null; }
 431{/*@bgen(jjtree) MethodDeclaration */
 432    try {
 433/*@egen*/
 434	// SYNTACTIC_LOOKAHEAD
 435	// this one seems cheap enough
 436    LOOKAHEAD( MethodDeclarationTypeLookahead() )
 437    ReturnType() t = <IDENTIFIER> { jjtn000.name = t.image; }
 438    FormalParameters() Block()
 439|
 440    t = <IDENTIFIER> { jjtn000.name = t.image; }
 441    FormalParameters() Block()/*@bgen(jjtree)*/
 442    } catch (Throwable jjte000) {
 443      if (jjtc000) {
 444        jjtree.clearNodeScope(jjtn000);
 445        jjtc000 = false;
 446      } else {
 447        jjtree.popNode();
 448      }
 449      if (jjte000 instanceof RuntimeException) {
 450        throw (RuntimeException)jjte000;
 451      }
 452      if (jjte000 instanceof ParseException) {
 453        throw (ParseException)jjte000;
 454      }
 455      throw (Error)jjte000;
 456    } finally {
 457      if (jjtc000) {
 458        jjtree.closeNodeScope(jjtn000, true);
 459        jjtreeCloseNodeScope(jjtn000);
 460      }
 461    }
 462/*@egen*/
 463}
 464
 465void MethodDeclarationLookahead() : { }
 466{
 467	// SYNTACTIC_LOOKAHEAD
 468	// this one seems cheap enough
 469    LOOKAHEAD( MethodDeclarationTypeLookahead() )
 470    ReturnType() <IDENTIFIER> FormalParameters() "{"
 471|
 472    <IDENTIFIER> FormalParameters() "{"
 473}
 474
 475void MethodDeclarationTypeLookahead() : { }
 476{
 477    ReturnType() <IDENTIFIER> "("
 478}
 479
 480void ImportDeclaration()                    :
 481{/*@bgen(jjtree) ImportDeclaration */
 482    BSHImportDeclaration jjtn000 = new BSHImportDeclaration(JJTIMPORTDECLARATION);
 483    boolean jjtc000 = true;
 484    jjtree.openNodeScope(jjtn000);
 485    jjtreeOpenNodeScope(jjtn000);
 486/*@egen*/
 487    Token t = null;
 488}
 489{/*@bgen(jjtree) ImportDeclaration */
 490  try {
 491/*@egen*/
 492  LOOKAHEAD( 2 )
 493
 494  "import" AmbiguousName() [ t = "." "*" ] ";"/*@bgen(jjtree)*/
 495                                               {
 496                                                 jjtree.closeNodeScope(jjtn000, true);
 497                                                 jjtc000 = false;
 498                                                 jjtreeCloseNodeScope(jjtn000);
 499                                               }
 500/*@egen*/ {
 501    if ( t != null )
 502        jjtn000.importPackage = true;
 503    }
 504  |
 505	// bsh super import statement
 506  "import" "*" ";"/*@bgen(jjtree)*/
 507                   {
 508                     jjtree.closeNodeScope(jjtn000, true);
 509                     jjtc000 = false;
 510                     jjtreeCloseNodeScope(jjtn000);
 511                   }
 512/*@egen*/ {
 513		jjtn000.superImport = true;
 514	}/*@bgen(jjtree)*/
 515  } catch (Throwable jjte000) {
 516    if (jjtc000) {
 517      jjtree.clearNodeScope(jjtn000);
 518      jjtc000 = false;
 519    } else {
 520      jjtree.popNode();
 521    }
 522    if (jjte000 instanceof RuntimeException) {
 523      throw (RuntimeException)jjte000;
 524    }
 525    if (jjte000 instanceof ParseException) {
 526      throw (ParseException)jjte000;
 527    }
 528    throw (Error)jjte000;
 529  } finally {
 530    if (jjtc000) {
 531      jjtree.closeNodeScope(jjtn000, true);
 532      jjtreeCloseNodeScope(jjtn000);
 533    }
 534  }
 535/*@egen*/
 536}
 537
 538void VariableDeclarator()                     :
 539{/*@bgen(jjtree) VariableDeclarator */
 540  BSHVariableDeclarator jjtn000 = new BSHVariableDeclarator(JJTVARIABLEDECLARATOR);
 541  boolean jjtc000 = true;
 542  jjtree.openNodeScope(jjtn000);
 543  jjtreeOpenNodeScope(jjtn000);
 544/*@egen*/ Token t; }
 545{/*@bgen(jjtree) VariableDeclarator */
 546  try {
 547/*@egen*/
 548  t=<IDENTIFIER> [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
 549                                               {
 550                                                 jjtree.closeNodeScope(jjtn000, true);
 551                                                 jjtc000 = false;
 552                                                 jjtreeCloseNodeScope(jjtn000);
 553                                               }
 554/*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
 555  } catch (Throwable jjte000) {
 556    if (jjtc000) {
 557      jjtree.clearNodeScope(jjtn000);
 558      jjtc000 = false;
 559    } else {
 560      jjtree.popNode();
 561    }
 562    if (jjte000 instanceof RuntimeException) {
 563      throw (RuntimeException)jjte000;
 564    }
 565    if (jjte000 instanceof ParseException) {
 566      throw (ParseException)jjte000;
 567    }
 568    throw (Error)jjte000;
 569  } finally {
 570    if (jjtc000) {
 571      jjtree.closeNodeScope(jjtn000, true);
 572      jjtreeCloseNodeScope(jjtn000);
 573    }
 574  }
 575/*@egen*/
 576}
 577
 578/*
 579Can get rid of this if we ignore postfix array dimensions in declarations.
 580I don't like them and I don't want to deal with them right now.
 581
 582void VariableDeclaratorId() #VariableDeclaratorId :
 583{ Token t; }
 584{
 585  t=<IDENTIFIER> { jjtThis.name = t.image; }
 586  ( "[" "]" { jjtThis.addArrayDimension(); } )*
 587}
 588*/
 589
 590void VariableInitializer() :
 591{}
 592{
 593  ArrayInitializer()
 594|
 595  Expression()
 596}
 597
 598void ArrayInitializer()                   :
 599{/*@bgen(jjtree) ArrayInitializer */
 600  BSHArrayInitializer jjtn000 = new BSHArrayInitializer(JJTARRAYINITIALIZER);
 601  boolean jjtc000 = true;
 602  jjtree.openNodeScope(jjtn000);
 603  jjtreeOpenNodeScope(jjtn000);
 604/*@egen*/}
 605{/*@bgen(jjtree) ArrayInitializer */
 606  try {
 607/*@egen*/
 608  "{" [ VariableInitializer() 
 609		( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
 610  } catch (Throwable jjte000) {
 611    if (jjtc000) {
 612      jjtree.clearNodeScope(jjtn000);
 613      jjtc000 = false;
 614    } else {
 615      jjtree.popNode();
 616    }
 617    if (jjte000 instanceof RuntimeException) {
 618      throw (RuntimeException)jjte000;
 619    }
 620    if (jjte000 instanceof ParseException) {
 621      throw (ParseException)jjte000;
 622    }
 623    throw (Error)jjte000;
 624  } finally {
 625    if (jjtc000) {
 626      jjtree.closeNodeScope(jjtn000, true);
 627      jjtreeCloseNodeScope(jjtn000);
 628    }
 629  }
 630/*@egen*/
 631}
 632
 633void FormalParameters()                   :
 634{/*@bgen(jjtree) FormalParameters */
 635  BSHFormalParameters jjtn000 = new BSHFormalParameters(JJTFORMALPARAMETERS);
 636  boolean jjtc000 = true;
 637  jjtree.openNodeScope(jjtn000);
 638  jjtreeOpenNodeScope(jjtn000);
 639/*@egen*/}
 640{/*@bgen(jjtree) FormalParameters */
 641  try {
 642/*@egen*/
 643  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
 644  } catch (Throwable jjte000) {
 645    if (jjtc000) {
 646      jjtree.clearNodeScope(jjtn000);
 647      jjtc000 = false;
 648    } else {
 649      jjtree.popNode();
 650    }
 651    if (jjte000 instanceof RuntimeException) {
 652      throw (RuntimeException)jjte000;
 653    }
 654    if (jjte000 instanceof ParseException) {
 655      throw (ParseException)jjte000;
 656    }
 657    throw (Error)jjte000;
 658  } finally {
 659    if (jjtc000) {
 660      jjtree.closeNodeScope(jjtn000, true);
 661      jjtreeCloseNodeScope(jjtn000);
 662    }
 663  }
 664/*@egen*/
 665}
 666
 667/*
 668void FormalParameter() #FormalParameter :
 669{ Token t; }
 670{
 671    // added [] to Type for bsh.  Removed [ final ] - is that legal?
 672  [ LOOKAHEAD(2) Type() ] t=<IDENTIFIER> { jjtThis.name = t.image; }
 673}
 674*/
 675void FormalParameter()                  :
 676{/*@bgen(jjtree) FormalParameter */
 677  BSHFormalParameter jjtn000 = new BSHFormalParameter(JJTFORMALPARAMETER);
 678  boolean jjtc000 = true;
 679  jjtree.openNodeScope(jjtn000);
 680  jjtreeOpenNodeScope(jjtn000);
 681/*@egen*/ Token t; }
 682{/*@bgen(jjtree) FormalParameter */
 683  try {
 684/*@egen*/
 685  // added [] to Type for bsh.  Removed [ final ] - is that legal?
 686  LOOKAHEAD(2) Type() t=<IDENTIFIER>/*@bgen(jjtree)*/
 687                                     {
 688                                       jjtree.closeNodeScope(jjtn000, true);
 689                                       jjtc000 = false;
 690                                       jjtreeCloseNodeScope(jjtn000);
 691                                     }
 692/*@egen*/ { jjtn000.name = t.image; }
 693|
 694  t=<IDENTIFIER>/*@bgen(jjtree)*/
 695                 {
 696                   jjtree.closeNodeScope(jjtn000, true);
 697                   jjtc000 = false;
 698                   jjtreeCloseNodeScope(jjtn000);
 699                 }
 700/*@egen*/ { jjtn000.name = t.image; }/*@bgen(jjtree)*/
 701  } catch (Throwable jjte000) {
 702    if (jjtc000) {
 703      jjtree.clearNodeScope(jjtn000);
 704      jjtc000 = false;
 705    } else {
 706      jjtree.popNode();
 707    }
 708    if (jjte000 instanceof RuntimeException) {
 709      throw (RuntimeException)jjte000;
 710    }
 711    if (jjte000 instanceof ParseException) {
 712      throw (ParseException)jjte000;
 713    }
 714    throw (Error)jjte000;
 715  } finally {
 716    if (jjtc000) {
 717      jjtree.closeNodeScope(jjtn000, true);
 718      jjtreeCloseNodeScope(jjtn000);
 719    }
 720  }
 721/*@egen*/
 722}
 723
 724
 725/*
 726	Type, name and expression syntax follows.
 727*/
 728void Type()       :
 729{/*@bgen(jjtree) Type */
 730  BSHType jjtn000 = new BSHType(JJTTYPE);
 731  boolean jjtc000 = true;
 732  jjtree.openNodeScope(jjtn000);
 733  jjtreeOpenNodeScope(jjtn000);
 734/*@egen*/ }
 735{/*@bgen(jjtree) Type */
 736  try {
 737/*@egen*/
 738	/* 
 739		The embedded lookahead is (was?) necessary to disambiguate for
 740		PrimaryPrefix.  ( )* is a choice point.  It took me a while to
 741		figure out where to put that.  This stuff is annoying.
 742	*/
 743  ( PrimitiveType() | AmbiguousName() ) 
 744	( LOOKAHEAD(2) "[" "]" { jjtn000.addArrayDimension(); } )*/*@bgen(jjtree)*/
 745  } catch (Throwable jjte000) {
 746    if (jjtc000) {
 747      jjtree.clearNodeScope(jjtn000);
 748      jjtc000 = false;
 749    } else {
 750      jjtree.popNode();
 751    }
 752    if (jjte000 instanceof RuntimeException) {
 753      throw (RuntimeException)jjte000;
 754    }
 755    if (jjte000 instanceof ParseException) {
 756      throw (ParseException)jjte000;
 757    }
 758    throw (Error)jjte000;
 759  } finally {
 760    if (jjtc000) {
 761      jjtree.closeNodeScope(jjtn000, true);
 762      jjtreeCloseNodeScope(jjtn000);
 763    }
 764  }
 765/*@egen*/ 
 766}
 767
 768/*
 769	Originally called ResultType in the grammar
 770*/
 771void ReturnType()             :
 772{/*@bgen(jjtree) ReturnType */
 773  BSHReturnType jjtn000 = new BSHReturnType(JJTRETURNTYPE);
 774  boolean jjtc000 = true;
 775  jjtree.openNodeScope(jjtn000);
 776  jjtreeOpenNodeScope(jjtn000);
 777/*@egen*/ }
 778{/*@bgen(jjtree) ReturnType */
 779  try {
 780/*@egen*/
 781  "void"/*@bgen(jjtree)*/
 782         {
 783           jjtree.closeNodeScope(jjtn000, true);
 784           jjtc000 = false;
 785           jjtreeCloseNodeScope(jjtn000);
 786         }
 787/*@egen*/ { jjtn000.isVoid = true; }
 788|
 789  Type()/*@bgen(jjtree)*/
 790  } catch (Throwable jjte000) {
 791    if (jjtc000) {
 792      jjtree.clearNodeScope(jjtn000);
 793      jjtc000 = false;
 794    } else {
 795      jjtree.popNode();
 796    }
 797    if (jjte000 instanceof RuntimeException) {
 798      throw (RuntimeException)jjte000;
 799    }
 800    if (jjte000 instanceof ParseException) {
 801      throw (ParseException)jjte000;
 802    }
 803    throw (Error)jjte000;
 804  } finally {
 805    if (jjtc000) {
 806      jjtree.closeNodeScope(jjtn000, true);
 807      jjtreeCloseNodeScope(jjtn000);
 808    }
 809  }
 810/*@egen*/
 811}
 812
 813void PrimitiveType()                :
 814{/*@bgen(jjtree) PrimitiveType */
 815  BSHPrimitiveType jjtn000 = new BSHPrimitiveType(JJTPRIMITIVETYPE);
 816  boolean jjtc000 = true;
 817  jjtree.openNodeScope(jjtn000);
 818  jjtreeOpenNodeScope(jjtn000);
 819/*@egen*/ } {/*@bgen(jjtree) PrimitiveType */
 820try {
 821/*@egen*/
 822"boolean"/*@bgen(jjtree)*/
 823          {
 824            jjtree.closeNodeScope(jjtn000, true);
 825            jjtc000 = false;
 826            jjtreeCloseNodeScope(jjtn000);
 827          }
 828/*@egen*/ { jjtn000.type = Boolean.TYPE; }
 829| "char"/*@bgen(jjtree)*/
 830         {
 831           jjtree.closeNodeScope(jjtn000, true);
 832           jjtc000 = false;
 833           jjtreeCloseNodeScope(jjtn000);
 834         }
 835/*@egen*/ { jjtn000.type =  Character.TYPE; }
 836| "byte"/*@bgen(jjtree)*/
 837         {
 838           jjtree.closeNodeScope(jjtn000, true);
 839           jjtc000 = false;
 840           jjtreeCloseNodeScope(jjtn000);
 841         }
 842/*@egen*/ { jjtn000.type =  Byte.TYPE; }
 843| "short"/*@bgen(jjtree)*/
 844          {
 845            jjtree.closeNodeScope(jjtn000, true);
 846            jjtc000 = false;
 847            jjtreeCloseNodeScope(jjtn000);
 848          }
 849/*@egen*/ { jjtn000.type =  Short.TYPE; }
 850| "int"/*@bgen(jjtree)*/
 851        {
 852          jjtree.closeNodeScope(jjtn000, true);
 853          jjtc000 = false;
 854          jjtreeCloseNodeScope(jjtn000);
 855        }
 856/*@egen*/ { jjtn000.type =  Integer.TYPE; }
 857| "long"/*@bgen(jjtree)*/
 858         {
 859           jjtree.closeNodeScope(jjtn000, true);
 860           jjtc000 = false;
 861           jjtreeCloseNodeScope(jjtn000);
 862         }
 863/*@egen*/ { jjtn000.type =  Long.TYPE; }
 864| "float"/*@bgen(jjtree)*/
 865          {
 866            jjtree.closeNodeScope(jjtn000, true);
 867            jjtc000 = false;
 868            jjtreeCloseNodeScope(jjtn000);
 869          }
 870/*@egen*/ { jjtn000.type =  Float.TYPE; }
 871| "double"/*@bgen(jjtree)*/
 872           {
 873             jjtree.closeNodeScope(jjtn000, true);
 874             jjtc000 = false;
 875             jjtreeCloseNodeScope(jjtn000);
 876           }
 877/*@egen*/ { jjtn000.type =  Double.TYPE; }/*@bgen(jjtree)*/
 878} finally {
 879  if (jjtc000) {
 880    jjtree.closeNodeScope(jjtn000, true);
 881    jjtreeCloseNodeScope(jjtn000);
 882  }
 883}
 884/*@egen*/
 885}
 886
 887void AmbiguousName()                :
 888/*
 889 * A lookahead of 2 is required below since "Name" can be followed
 890 * by a ".*" when used in the context of an "ImportDeclaration".
 891 */
 892{/*@bgen(jjtree) AmbiguousName */
 893    BSHAmbiguousName jjtn000 = new BSHAmbiguousName(JJTAMBIGUOUSNAME);
 894    boolean jjtc000 = true;
 895    jjtree.openNodeScope(jjtn000);
 896    jjtreeOpenNodeScope(jjtn000);
 897/*@egen*/
 898    Token t;
 899    StringBuffer s;
 900}
 901{/*@bgen(jjtree) AmbiguousName */
 902  try {
 903/*@egen*/
 904  t = <IDENTIFIER> {
 905        s = new StringBuffer(t.image);
 906    }
 907  ( LOOKAHEAD(2) "." t = <IDENTIFIER> {
 908        s.append("."+t.image);
 909    }
 910  )*/*@bgen(jjtree)*/
 911     {
 912       jjtree.closeNodeScope(jjtn000, true);
 913       jjtc000 = false;
 914       jjtreeCloseNodeScope(jjtn000);
 915     }
 916/*@egen*/ {
 917        jjtn000.text = s.toString();
 918    }/*@bgen(jjtree)*/
 919  } finally {
 920    if (jjtc000) {
 921      jjtree.closeNodeScope(jjtn000, true);
 922      jjtreeCloseNodeScope(jjtn000);
 923    }
 924  }
 925/*@egen*/
 926}
 927
 928/*
 929 * Expression syntax follows.
 930 */
 931void Expression() :
 932{ }
 933{
 934	/**
 935		SYNTACTIC_LOOKAHEAD
 936		This is probably expensive.  Can we simplify it somehow?
 937	*/
 938  LOOKAHEAD( LHSPrimaryExpression() AssignmentOperator() )
 939  Assignment()
 940|
 941  ConditionalExpression()
 942}
 943
 944void Assignment()             :
 945{/*@bgen(jjtree) Assignment */
 946  BSHAssignment jjtn000 = new BSHAssignment(JJTASSIGNMENT);
 947  boolean jjtc000 = true;
 948  jjtree.openNodeScope(jjtn000);
 949  jjtreeOpenNodeScope(jjtn000);
 950/*@egen*/ int op ; }
 951{/*@bgen(jjtree) Assignment */
 952  try {
 953/*@egen*/
 954  LHSPrimaryExpression()
 955  op = AssignmentOperator() {
 956    jjtn000.operator = op;
 957  }
 958  Expression()/*@bgen(jjtree)*/
 959  } catch (Throwable jjte000) {
 960    if (jjtc000) {
 961      jjtree.clearNodeScope(jjtn000);
 962      jjtc000 = false;
 963    } else {
 964      jjtree.popNode();
 965    }
 966    if (jjte000 instanceof RuntimeException) {
 967      throw (RuntimeException)jjte000;
 968    }
 969    if (jjte000 instanceof ParseException) {
 970      throw (ParseException)jjte000;
 971    }
 972    throw (Error)jjte000;
 973  } finally {
 974    if (jjtc000) {
 975      jjtree.closeNodeScope(jjtn000, true);
 976      jjtreeCloseNodeScope(jjtn000);
 977    }
 978  }
 979/*@egen*/
 980}
 981
 982int AssignmentOperator() :
 983{ Token t; }
 984{
 985    ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|=" |
 986      "<<=" | "@left_shift_assign" | ">>=" | "@right_shift_assign" |
 987      ">>>=" | "@right_unsigned_shift_assign" )
 988    {
 989        t = getToken(0);
 990        return t.kind;
 991    }
 992}
 993
 994void ConditionalExpression() : 
 995{ }
 996{
 997  ConditionalOrExpression() [ "?" Expression() ":"/*@bgen(jjtree) #TernaryExpression( 3) */
 998                                                   {
 999                                                     BSHTernaryExpression jjtn001 = new BSHTernaryExpression(JJTTERNARYEXPRESSION);
1000                                                     boolean jjtc001 = true;
1001                                                     jjtree.openNodeScope(jjtn001);
1002                                                     jjtreeOpenNodeScope(jjtn001);
1003                                                   }
1004                                                   try {
1005/*@egen*/ ConditionalExpression()/*@bgen(jjtree)*/
1006                                                   } catch (Throwable jjte001) {
1007                                                     if (jjtc001) {
1008                                                       jjtree.clearNodeScope(jjtn001);
1009                                                       jjtc001 = false;
1010                                                     } else {
1011                                                       jjtree.popNode();
1012                                                     }
1013                                                     if (jjte001 instanceof RuntimeException) {
1014                                                       throw (RuntimeException)jjte001;
1015                                                     }
1016                                                     if (jjte001 instanceof ParseException) {
1017                                                       throw (ParseException)jjte001;
1018                                                     }
1019                                                     throw (Error)jjte001;
1020                                                   } finally {
1021                                                     if (jjtc001) {
1022                                                       jjtree.closeNodeScope(jjtn001,  3);
1023                                                       jjtreeCloseNodeScope(jjtn001);
1024                                                     }
1025                                                   }
1026/*@egen*/ ]
1027}
1028
1029void ConditionalOrExpression() :
1030{ Token t=null; }
1031{
1032  ConditionalAndExpression()
1033  ( ( t = "||" | t = "@or" )
1034    ConditionalAndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1035    {
1036      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1037      boolean jjtc001 = true;
1038      jjtree.openNodeScope(jjtn001);
1039      jjtreeOpenNodeScope(jjtn001);
1040    }
1041    try {
1042/*@egen*//*@bgen(jjtree)*/
1043    {
1044      jjtree.closeNodeScope(jjtn001,  2);
1045      jjtc001 = false;
1046      jjtreeCloseNodeScope(jjtn001);
1047    }
1048/*@egen*/
1049    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1050    } finally {
1051      if (jjtc001) {
1052        jjtree.closeNodeScope(jjtn001,  2);
1053        jjtreeCloseNodeScope(jjtn001);
1054      }
1055    }
1056/*@egen*/ )*
1057}
1058
1059void ConditionalAndExpression() :
1060{ Token t=null; }
1061{
1062  InclusiveOrExpression()
1063  ( ( t = "&&" | t = "@and" )
1064    InclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1065    {
1066      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1067      boolean jjtc001 = true;
1068      jjtree.openNodeScope(jjtn001);
1069      jjtreeOpenNodeScope(jjtn001);
1070    }
1071    try {
1072/*@egen*//*@bgen(jjtree)*/
1073    {
1074      jjtree.closeNodeScope(jjtn001,  2);
1075      jjtc001 = false;
1076      jjtreeCloseNodeScope(jjtn001);
1077    }
1078/*@egen*/
1079    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1080    } finally {
1081      if (jjtc001) {
1082        jjtree.closeNodeScope(jjtn001,  2);
1083        jjtreeCloseNodeScope(jjtn001);
1084      }
1085    }
1086/*@egen*/ )*
1087}
1088
1089void InclusiveOrExpression() :
1090{ Token t=null; }
1091{
1092  ExclusiveOrExpression()
1093  ( ( t = "|" | t = "@bitwise_or" )
1094    ExclusiveOrExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1095    {
1096      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1097      boolean jjtc001 = true;
1098      jjtree.openNodeScope(jjtn001);
1099      jjtreeOpenNodeScope(jjtn001);
1100    }
1101    try {
1102/*@egen*//*@bgen(jjtree)*/
1103    {
1104      jjtree.closeNodeScope(jjtn001,  2);
1105      jjtc001 = false;
1106      jjtreeCloseNodeScope(jjtn001);
1107    }
1108/*@egen*/
1109    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1110    } finally {
1111      if (jjtc001) {
1112        jjtree.closeNodeScope(jjtn001,  2);
1113        jjtreeCloseNodeScope(jjtn001);
1114      }
1115    }
1116/*@egen*/ )*
1117}
1118
1119void ExclusiveOrExpression() :
1120{ Token t=null; }
1121{
1122  AndExpression() ( t="^" AndExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1123    {
1124      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1125      boolean jjtc001 = true;
1126      jjtree.openNodeScope(jjtn001);
1127      jjtreeOpenNodeScope(jjtn001);
1128    }
1129    try {
1130/*@egen*//*@bgen(jjtree)*/
1131    {
1132      jjtree.closeNodeScope(jjtn001,  2);
1133      jjtc001 = false;
1134      jjtreeCloseNodeScope(jjtn001);
1135    }
1136/*@egen*/
1137    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1138    } finally {
1139      if (jjtc001) {
1140        jjtree.closeNodeScope(jjtn001,  2);
1141        jjtreeCloseNodeScope(jjtn001);
1142      }
1143    }
1144/*@egen*/ )*
1145}
1146
1147void AndExpression() :
1148{ Token t=null; }
1149{
1150  EqualityExpression()
1151  ( ( t = "&" | t = "@bitwise_and" )
1152    EqualityExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1153    {
1154      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1155      boolean jjtc001 = true;
1156      jjtree.openNodeScope(jjtn001);
1157      jjtreeOpenNodeScope(jjtn001);
1158    }
1159    try {
1160/*@egen*//*@bgen(jjtree)*/
1161    {
1162      jjtree.closeNodeScope(jjtn001,  2);
1163      jjtc001 = false;
1164      jjtreeCloseNodeScope(jjtn001);
1165    }
1166/*@egen*/
1167    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1168    } finally {
1169      if (jjtc001) {
1170        jjtree.closeNodeScope(jjtn001,  2);
1171        jjtreeCloseNodeScope(jjtn001);
1172      }
1173    }
1174/*@egen*/ )*
1175}
1176
1177void EqualityExpression() :
1178{ Token t = null; }
1179{
1180  InstanceOfExpression() ( ( t= "==" | t= "!=" ) InstanceOfExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1181    {
1182      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1183      boolean jjtc001 = true;
1184      jjtree.openNodeScope(jjtn001);
1185      jjtreeOpenNodeScope(jjtn001);
1186    }
1187    try {
1188/*@egen*//*@bgen(jjtree)*/
1189    {
1190      jjtree.closeNodeScope(jjtn001,  2);
1191      jjtc001 = false;
1192      jjtreeCloseNodeScope(jjtn001);
1193    }
1194/*@egen*/
1195    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1196    } finally {
1197      if (jjtc001) {
1198        jjtree.closeNodeScope(jjtn001,  2);
1199        jjtreeCloseNodeScope(jjtn001);
1200      }
1201    }
1202/*@egen*/
1203  )*
1204}
1205
1206void InstanceOfExpression() :
1207{ Token t = null; }
1208{
1209  RelationalExpression()
1210  [ t = "instanceof" Type()/*@bgen(jjtree) #BinaryExpression( 2) */
1211                            {
1212                              BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1213                              boolean jjtc001 = true;
1214                              jjtree.openNodeScope(jjtn001);
1215                              jjtreeOpenNodeScope(jjtn001);
1216                            }
1217                            try {
1218/*@egen*//*@bgen(jjtree)*/
1219                            {
1220                              jjtree.closeNodeScope(jjtn001,  2);
1221                              jjtc001 = false;
1222                              jjtreeCloseNodeScope(jjtn001);
1223                            }
1224/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1225                            } finally {
1226                              if (jjtc001) {
1227                                jjtree.closeNodeScope(jjtn001,  2);
1228                                jjtreeCloseNodeScope(jjtn001);
1229                              }
1230                            }
1231/*@egen*/ ]
1232}
1233
1234void RelationalExpression() :
1235{ Token t = null; }
1236{
1237  ShiftExpression()
1238  ( ( t = "<" | t = "@lt" | t = ">" | t = "@gt" |
1239      t = "<=" | t = "@lteq" | t = ">=" | t = "@gteq" )
1240  ShiftExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1241  {
1242    BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1243    boolean jjtc001 = true;
1244    jjtree.openNodeScope(jjtn001);
1245    jjtreeOpenNodeScope(jjtn001);
1246  }
1247  try {
1248/*@egen*//*@bgen(jjtree)*/
1249  {
1250    jjtree.closeNodeScope(jjtn001,  2);
1251    jjtc001 = false;
1252    jjtreeCloseNodeScope(jjtn001);
1253  }
1254/*@egen*/
1255  { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1256  } finally {
1257    if (jjtc001) {
1258      jjtree.closeNodeScope(jjtn001,  2);
1259      jjtreeCloseNodeScope(jjtn001);
1260    }
1261  }
1262/*@egen*/ )*
1263}
1264
1265void ShiftExpression() :
1266{ Token t = null; }
1267{
1268  AdditiveExpression()
1269  ( ( t = "<<" | t = "@left_shift" | t = ">>" | t = "@right_shift" |
1270      t = ">>>" | t = "@right_unsigned_shift" )
1271  AdditiveExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1272  {
1273    BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1274    boolean jjtc001 = true;
1275    jjtree.openNodeScope(jjtn001);
1276    jjtreeOpenNodeScope(jjtn001);
1277  }
1278  try {
1279/*@egen*//*@bgen(jjtree)*/
1280  {
1281    jjtree.closeNodeScope(jjtn001,  2);
1282    jjtc001 = false;
1283    jjtreeCloseNodeScope(jjtn001);
1284  }
1285/*@egen*/
1286  { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1287  } finally {
1288    if (jjtc001) {
1289      jjtree.closeNodeScope(jjtn001,  2);
1290      jjtreeCloseNodeScope(jjtn001);
1291    }
1292  }
1293/*@egen*/ )*
1294}
1295
1296void AdditiveExpression() :
1297{ Token t = null; }
1298{
1299  MultiplicativeExpression()
1300  ( ( t= "+" | t= "-" ) MultiplicativeExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1301                                                   {
1302                                                     BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1303                                                     boolean jjtc001 = true;
1304                                                     jjtree.openNodeScope(jjtn001);
1305                                                     jjtreeOpenNodeScope(jjtn001);
1306                                                   }
1307                                                   try {
1308/*@egen*//*@bgen(jjtree)*/
1309                                                   {
1310                                                     jjtree.closeNodeScope(jjtn001,  2);
1311                                                     jjtc001 = false;
1312                                                     jjtreeCloseNodeScope(jjtn001);
1313                                                   }
1314/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1315                                                   } finally {
1316                                                     if (jjtc001) {
1317                                                       jjtree.closeNodeScope(jjtn001,  2);
1318                                                       jjtreeCloseNodeScope(jjtn001);
1319                                                     }
1320                                                   }
1321/*@egen*/
1322  )*
1323}
1324
1325void MultiplicativeExpression() :
1326{ Token t = null; }
1327{
1328  UnaryExpression() ( ( t= "*" | t= "/" | t= "%" )
1329  UnaryExpression()/*@bgen(jjtree) #BinaryExpression( 2) */
1330                    {
1331                      BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
1332                      boolean jjtc001 = true;
1333                      jjtree.openNodeScope(jjtn001);
1334                      jjtreeOpenNodeScope(jjtn001);
1335                    }
1336                    try {
1337/*@egen*//*@bgen(jjtree)*/
1338                    {
1339                      jjtree.closeNodeScope(jjtn001,  2);
1340                      jjtc001 = false;
1341                      jjtreeCloseNodeScope(jjtn001);
1342                    }
1343/*@egen*/ { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1344                    } finally {
1345                      if (jjtc001) {
1346                        jjtree.closeNodeScope(jjtn001,  2);
1347                        jjtreeCloseNodeScope(jjtn001);
1348                      }
1349                    }
1350/*@egen*/ )*
1351}
1352
1353void UnaryExpression() :
1354{ Token t = null; }
1355{
1356  ( t="+" | t="-" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1357    {
1358      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1359      boolean jjtc001 = true;
1360      jjtree.openNodeScope(jjtn001);
1361      jjtreeOpenNodeScope(jjtn001);
1362    }
1363    try {
1364/*@egen*//*@bgen(jjtree)*/
1365    {
1366      jjtree.closeNodeScope(jjtn001,  1);
1367      jjtc001 = false;
1368      jjtreeCloseNodeScope(jjtn001);
1369    }
1370/*@egen*/
1371    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1372    } finally {
1373      if (jjtc001) {
1374        jjtree.closeNodeScope(jjtn001,  1);
1375        jjtreeCloseNodeScope(jjtn001);
1376      }
1377    }
1378/*@egen*/
1379|
1380  PreIncrementExpression()
1381|
1382  PreDecrementExpression()
1383|
1384  UnaryExpressionNotPlusMinus()
1385}
1386
1387void PreIncrementExpression() :
1388{ Token t = null; }
1389{
1390  t="++" LHSPrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1391    {
1392      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1393      boolean jjtc001 = true;
1394      jjtree.openNodeScope(jjtn001);
1395      jjtreeOpenNodeScope(jjtn001);
1396    }
1397    try {
1398/*@egen*//*@bgen(jjtree)*/
1399    {
1400      jjtree.closeNodeScope(jjtn001,  1);
1401      jjtc001 = false;
1402      jjtreeCloseNodeScope(jjtn001);
1403    }
1404/*@egen*/
1405    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1406    } finally {
1407      if (jjtc001) {
1408        jjtree.closeNodeScope(jjtn001,  1);
1409        jjtreeCloseNodeScope(jjtn001);
1410      }
1411    }
1412/*@egen*/
1413}
1414
1415void PreDecrementExpression() :
1416{ Token t = null; }
1417{
1418  t="--" LHSPrimaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1419    {
1420      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1421      boolean jjtc001 = true;
1422      jjtree.openNodeScope(jjtn001);
1423      jjtreeOpenNodeScope(jjtn001);
1424    }
1425    try {
1426/*@egen*//*@bgen(jjtree)*/
1427    {
1428      jjtree.closeNodeScope(jjtn001,  1);
1429      jjtc001 = false;
1430      jjtreeCloseNodeScope(jjtn001);
1431    }
1432/*@egen*/
1433    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1434    } finally {
1435      if (jjtc001) {
1436        jjtree.closeNodeScope(jjtn001,  1);
1437        jjtreeCloseNodeScope(jjtn001);
1438      }
1439    }
1440/*@egen*/
1441}
1442
1443void UnaryExpressionNotPlusMinus() :
1444{ Token t = null; }
1445{
1446  ( t="~" | t="!" ) UnaryExpression()/*@bgen(jjtree) #UnaryExpression( 1) */
1447    {
1448      BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1449      boolean jjtc001 = true;
1450      jjtree.openNodeScope(jjtn001);
1451      jjtreeOpenNodeScope(jjtn001);
1452    }
1453    try {
1454/*@egen*//*@bgen(jjtree)*/
1455    {
1456      jjtree.closeNodeScope(jjtn001,  1);
1457      jjtc001 = false;
1458      jjtreeCloseNodeScope(jjtn001);
1459    }
1460/*@egen*/
1461    { jjtn001.kind = t.kind; }/*@bgen(jjtree)*/
1462    } finally {
1463      if (jjtc001) {
1464        jjtree.closeNodeScope(jjtn001,  1);
1465        jjtreeCloseNodeScope(jjtn001);
1466      }
1467    }
1468/*@egen*/
1469|
1470	// SYNTACTIC_LOOKAHEAD
1471  LOOKAHEAD( CastLookahead() ) CastExpression()
1472|
1473  PostfixExpression()
1474}
1475
1476// This production is to determine lookahead only.
1477void CastLookahead() : { }
1478{
1479  LOOKAHEAD(2) "(" PrimitiveType()
1480|
1481// SYNTACTIC_LOOKAHEAD
1482  LOOKAHEAD( "(" AmbiguousName() "[" ) "(" AmbiguousName() "[" "]"
1483|
1484  "(" AmbiguousName() ")" ( "~" | "!" | "(" | <IDENTIFIER> | /* "this" | "super" | */ "new" | Literal() )
1485}
1486
1487void PostfixExpression() :
1488{ Token t = null; }
1489{
1490// SYNTACTIC_LOOKAHEAD
1491  LOOKAHEAD( LHSPrimaryExpression() ("++"|"--") )
1492  LHSPrimaryExpression()
1493	  ( t="++" | t="--" )/*@bgen(jjtree) #UnaryExpression( 1) */
1494                              {
1495                                BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
1496                                boolean jjtc001 = true;
1497                                jjtree.openNodeScope(jjtn001);
1498                                jjtreeOpenNodeScope(jjtn001);
1499                              }
1500                              try {
1501/*@egen*//*@bgen(jjtree)*/
1502                              {
1503                                jjtree.closeNodeScope(jjtn001,  1);
1504                                jjtc001 = false;
1505                                jjtreeCloseNodeScope(jjtn001);
1506                              }
1507/*@egen*/ { 
1508		jjtn001.kind = t.kind; jjtn001.postfix = true; }/*@bgen(jjtree)*/
1509                              } finally {
1510                                if (jjtc001) {
1511                                  jjtree.closeNodeScope(jjtn001,  1);
1512                                  jjtreeCloseNodeScope(jjtn001);
1513                                }
1514                              }
1515/*@egen*/
1516|
1517  PrimaryExpression()
1518}
1519
1520void CastExpression()                 :
1521{/*@bgen(jjtree) CastExpression */
1522  BSHCastExpression jjtn000 = new BSHCastExpression(JJTCASTEXPRESSION);
1523  boolean jjtc000 = true;
1524  jjtree.openNodeScope(jjtn000);
1525  jjtreeOpenNodeScope(jjtn000);
1526/*@egen*/ }
1527{/*@bgen(jjtree) CastExpression */
1528  try {
1529/*@egen*/
1530// SYNTACTIC_LOOKAHEAD
1531  LOOKAHEAD( "(" PrimitiveType() ) "(" Type() ")" UnaryExpression()
1532|
1533  "(" Type() ")" UnaryExpressionNotPlusMinus()/*@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 PrimaryExpression()                    : {/*@bgen(jjtree) PrimaryExpression */
1558  BSHPrimaryExpression jjtn000 = new BSHPrimaryExpression(JJTPRIMARYEXPRESSION);
1559  boolean jjtc000 = true;
1560  jjtree.openNodeScope(jjtn000);
1561  jjtreeOpenNodeScope(jjtn000);
1562/*@egen*/ }
1563{/*@bgen(jjtree) PrimaryExpression */
1564  try {
1565/*@egen*/
1566  PrimaryPrefix() ( PrimarySuffix() )*/*@bgen(jjtree)*/
1567  } catch (Throwable jjte000) {
1568    if (jjtc000) {
1569      jjtree.clearNodeScope(jjtn000);
1570      jjtc000 = false;
1571    } else {
1572      jjtree.popNode();
1573    }
1574    if (jjte000 instanceof RuntimeException) {
1575      throw (RuntimeException)jjte000;
1576    }
1577    if (jjte000 instanceof ParseException) {
1578      throw (ParseException)jjte000;
1579    }
1580    throw (Error)jjte000;
1581  } finally {
1582    if (jjtc000) {
1583      jjtree.closeNodeScope(jjtn000, true);
1584      jjtreeCloseNodeScope(jjtn000);
1585    }
1586  }
1587/*@egen*/
1588}
1589
1590void MethodInvocation()                   : {/*@bgen(jjtree) MethodInvocation */
1591  BSHMethodInvocation jjtn000 = new BSHMethodInvocation(JJTMETHODINVOCATION);
1592  boolean jjtc000 = true;
1593  jjtree.openNodeScope(jjtn000);
1594  jjtreeOpenNodeScope(jjtn000);
1595/*@egen*/ }
1596{/*@bgen(jjtree) MethodInvocation */
1597   try {
1598/*@egen*/
1599   AmbiguousName() Arguments()/*@bgen(jjtree)*/
1600   } catch (Throwable jjte000) {
1601     if (jjtc000) {
1602       jjtree.clearNodeScope(jjtn000);
1603       jjtc000 = false;
1604     } else {
1605       jjtree.popNode();
1606     }
1607     if (jjte000 instanceof RuntimeException) {
1608       throw (RuntimeException)jjte000;
1609     }
1610     if (jjte000 instanceof ParseException) {
1611       throw (ParseException)jjte000;
1612     }
1613     throw (Error)jjte000;
1614   } finally {
1615     if (jjtc000) {
1616       jjtree.closeNodeScope(jjtn000, true);
1617       jjtreeCloseNodeScope(jjtn000);
1618     }
1619   }
1620/*@egen*/ 
1621}
1622
1623void PrimaryPrefix() : { }
1624{
1625  Literal()
1626|
1627  "(" Expression() ")"
1628|
1629  AllocationExpression()
1630|
1631 // SYNTACTIC_LOOKAHEAD
1632 LOOKAHEAD( MethodInvocation() ) MethodInvocation()
1633|
1634   LOOKAHEAD( Type() "." "class" ) 
1635   Type()
1636|
1637  AmbiguousName()
1638
1639/*
1640|
1641  LOOKAHEAD( "void" "." "class" )
1642*/
1643}
1644
1645void PrimarySuffix()                :
1646{/*@bgen(jjtree) PrimarySuffix */
1647    BSHPrimarySuffix jjtn000 = new BSHPrimarySuffix(JJTPRIMARYSUFFIX);
1648    boolean jjtc000 = true;
1649    jjtree.openNodeScope(jjtn000);
1650    jjtreeOpenNodeScope(jjtn000);
1651/*@egen*/
1652    Token t = null;
1653}
1654{/*@bgen(jjtree) PrimarySuffix */
1655  try {
1656/*@egen*/
1657  LOOKAHEAD(2)
1658  "." "class"/*@bgen(jjtree)*/
1659              {
1660                jjtree.closeNodeScope(jjtn000, true);
1661                jjtc000 = false;
1662                jjtreeCloseNodeScope(jjtn000);
1663              }
1664/*@egen*/ {
1665        jjtn000.operation = BSHPrimarySuffix.CLASS;
1666    }
1667|
1668  "[" Expression() "]"/*@bgen(jjtree)*/
1669                       {
1670                         jjtree.closeNodeScope(jjtn000, true);
1671                         jjtc000 = false;
1672                         jjtreeCloseNodeScope(jjtn000);
1673                       }
1674/*@egen*/ {
1675        jjtn000.operation = BSHPrimarySuffix.INDEX;
1676    }
1677|
1678    // Field access or method invocation
1679  "." t = <IDENTIFIER> [ Arguments() ]/*@bgen(jjtree)*/
1680                                       {
1681                                         jjtree.closeNodeScope(jjtn000, true);
1682                                         jjtc000 = false;
1683                                         jjtreeCloseNodeScope(jjtn000);
1684                                       }
1685/*@egen*/ {
1686        jjtn000.operation = BSHPrimarySuffix.NAME;
1687        jjtn000.field = t.image;
1688    }
1689|
1690  "{" Expression() "}"/*@bgen(jjtree)*/
1691                       {
1692                         jjtree.closeNodeScope(jjtn000, true);
1693                         jjtc000 = false;
1694                         jjtreeCloseNodeScope(jjtn000);
1695                       }
1696/*@egen*/ {
1697        jjtn000.operation = BSHPrimarySuffix.PROPERTY;
1698    }/*@bgen(jjtree)*/
1699  } catch (Throwable jjte000) {
1700    if (jjtc000) {
1701      jjtree.clearNodeScope(jjtn000);
1702      jjtc000 = false;
1703    } else {
1704      jjtree.popNode();
1705    }
1706    if (jjte000 instanceof RuntimeException) {
1707      throw (RuntimeException)jjte000;
1708    }
1709    if (jjte000 instanceof ParseException) {
1710      throw (ParseException)jjte000;
1711    }
1712    throw (Error)jjte000;
1713  } finally {
1714    if (jjtc000) {
1715      jjtree.closeNodeScope(jjtn000, true);
1716      jjtreeCloseNodeScope(jjtn000);
1717    }
1718  }
1719/*@egen*/
1720/*
1721    For inner classes
1722|
1723  LOOKAHEAD(2)
1724  "." AllocationExpression()
1725*/
1726}
1727
1728
1729/*
1730	Begin LHS part of the grammar --
1731
1732	The reason this stuff is duplicated (e.g. LHSPrimaryPrefix and 
1733	PrimaryPrefix) is that the whole grammar splits based on whether we 
1734	are preparig to do an assignment or not.  This is an important issue 
1735	to revisit in the future.
1736*/
1737/**
1738	The method invocation is here to force this to an object type in order 
1739	to simplify the suffix processing.  
1740*/
1741void LHSPrimaryPrefix() : { }
1742{
1743/*
1744  // SYNTACTIC_LOOKAHEAD
1745  LOOKAHEAD( MethodInvocation() )
1746  MethodInvocation()
1747|
1748*/
1749  AmbiguousName()
1750}
1751
1752void LHSPrimaryExpression()                       : {/*@bgen(jjtree) LHSPrimaryExpression */
1753  BSHLHSPrimaryExpression jjtn000 = new BSHLHSPrimaryExpression(JJTLHSPRIMARYEXPRESSION);
1754  boolean jjtc000 = true;
1755  jjtree.openNodeScope(jjtn000);
1756  jjtreeOpenNodeScope(jjtn000);
1757/*@egen*/ }
1758{/*@bgen(jjtree) LHSPrimaryExpression */
1759  try {
1760/*@egen*/
1761  LHSPrimaryPrefix() ( LHSPrimarySuffix( ) )*/*@bgen(jjtree)*/
1762  } catch (Throwable jjte000) {
1763    if (jjtc000) {
1764      jjtree.clearNodeScope(jjtn000);
1765      jjtc000 = false;
1766    } else {
1767      jjtree.popNode();
1768    }
1769    if (jjte000 instanceof RuntimeException) {
1770      throw (RuntimeException)jjte000;
1771    }
1772    if (jjte000 instanceof ParseException) {
1773      throw (ParseException)jjte000;
1774    }
1775    throw (Error)jjte000;
1776  } finally {
1777    if (jjtc000) {
1778      jjtree.closeNodeScope(jjtn000, true);
1779      jjtreeCloseNodeScope(jjtn000);
1780    }
1781  }
1782/*@egen*/
1783}
1784
1785void LHSPrimarySuffix()                   :
1786{/*@bgen(jjtree) LHSPrimarySuffix */
1787    BSHLHSPrimarySuffix jjtn000 = new BSHLHSPrimarySuffix(JJTLHSPRIMARYSUFFIX);
1788    boolean jjtc000 = true;
1789    jjtree.openNodeScope(jjtn000);
1790    jjtreeOpenNodeScope(jjtn000);
1791/*@egen*/
1792    Token t=null, t1, t2 = null;
1793}
1794{/*@bgen(jjtree) LHSPrimarySuffix */
1795  try {
1796/*@egen*/
1797    // Indexed to a field
1798  "[" Expression() "]"/*@bgen(jjtree)*/
1799                       {
1800                         jjtree.closeNodeScope(jjtn000, true);
1801                         jjtc000 = false;
1802                         jjtreeCloseNodeScope(jjtn000);
1803                       }
1804/*@egen*/ {
1805        jjtn000.operation = BSHLHSPrimarySuffix.INDEX;
1806    }
1807|
1808/*
1809	Broken - return to this...
1810	Look at PrimarySuffix... why can't we do it right, as there?
1811	See BSHLHSPrimarySuffix.java
1812*/
1813    // Field access or method invocation followed by field access
1814  "." t1 = <IDENTIFIER> [ Arguments() "." t2 = <IDENTIFIER> ]/*@bgen(jjtree)*/
1815                                                              {
1816                                                                jjtree.closeNodeScope(jjtn000, true);
1817                                                                jjtc000 = false;
1818                                                                jjtreeCloseNodeScope(jjtn000);
1819                                                              }
1820/*@egen*/ {
1821        jjtn000.operation = BSHLHSPrimarySuffix.NAME;
1822        if ( t2 == null )
1823            jjtn000.field = t1.image;
1824        else {
1825            jjtn000.method = t1.image;
1826            jjtn000.field = t2.image;
1827        }
1828    }
1829|
1830  "{" Expression() "}"/*@bgen(jjtree)*/
1831                       {
1832                         jjtree.closeNodeScope(jjtn000, true);
1833                         jjtc000 = false;
1834                         jjtreeCloseNodeScope(jjtn000);
1835                       }
1836/*@egen*/ {
1837        jjtn000.operation = BSHLHSPrimarySuffix.PROPERTY;
1838    }/*@bgen(jjtree)*/
1839  } catch (Throwable jjte000) {
1840    if (jjtc000) {
1841      jjtree.clearNodeScope(jjtn000);
1842      jjtc000 = false;
1843    } else {
1844      jjtree.popNode();
1845    }
1846    if (jjte000 instanceof RuntimeException) {
1847      throw (RuntimeException)jjte000;
1848    }
1849    if (jjte000 instanceof ParseException) {
1850      throw (ParseException)jjte000;
1851    }
1852    throw (Error)jjte000;
1853  } finally {
1854    if (jjtc000) {
1855      jjtree.closeNodeScope(jjtn000, true);
1856      jjtreeCloseNodeScope(jjtn000);
1857    }
1858  }
1859/*@egen*/
1860}
1861
1862/*
1863	-- End LHS part of the grammar
1864*/
1865
1866void Literal()          :
1867{/*@bgen(jjtree) Literal */
1868    BSHLiteral jjtn000 = new BSHLiteral(JJTLITERAL);
1869    boolean jjtc000 = true;
1870    jjtree.openNodeScope(jjtn000);
1871    jjtreeOpenNodeScope(jjtn000);
1872/*@egen*/
1873    Token x;
1874    boolean b;
1875    String literal;
1876    char ch;
1877}
1878{/*@bgen(jjtree) Literal */
1879  try {
1880/*@egen*/
1881  x = <INTEGER_LITERAL>/*@bgen(jjtree)*/
1882  {
1883    jjtree.closeNodeScope(jjtn000, true);
1884    jjtc000 = false;
1885    jjtreeCloseNodeScope(jjtn000);
1886  }
1887/*@egen*/
1888  {
1889    literal = x.image;
1890    ch = literal.charAt(literal.length()-1);
1891    if(ch == 'l' || ch == 'L')
1892    {
1893        literal = literal.substring(0,literal.length()-1);
1894
1895        // This really should be Long.decode, but there isn't one. As a result,
1896        // hex and octal literals ending in 'l' or 'L' don't work.
1897        jjtn000.value = new Primitive( new Long( literal ) );
1898    }
1899    else
1900        jjtn000.value = new Primitive( Integer.decode( literal ) );
1901  }
1902|
1903  x = <FLOATING_POINT_LITERAL>/*@bgen(jjtree)*/
1904  {
1905    jjtree.closeNodeScope(jjtn000, true);
1906    jjtc000 = false;
1907    jjtreeCloseNodeScope(jjtn000);
1908  }
1909/*@egen*/
1910  {
1911    literal = x.image;
1912    ch = literal.charAt(literal.length()-1);
1913    if(ch == 'f' || ch == 'F')
1914    {
1915        literal = literal.substring(0,literal.length()-1);
1916        jjtn000.value = new Primitive( new Float( literal ) );
1917    }
1918    else
1919    {
1920        if(ch == 'd' || ch == 'D')
1921            literal = literal.substring(0,literal.length()-1);
1922
1923        jjtn000.value = new Primitive( new Double( literal ) );
1924    }
1925  }
1926|
1927  x = <CHARACTER_LITERAL>/*@bgen(jjtree)*/
1928                          {
1929                            jjtree.closeNodeScope(jjtn000, true);
1930                            jjtc000 = false;
1931                            jjtreeCloseNodeScope(jjtn000);
1932                          }
1933/*@egen*/ {
1934		try {
1935    		jjtn000.charSetup( x.image.substring(1, x.image.length() - 1) );
1936		} catch ( Exception e ) {
1937			throw new ParseException("Error parsing character: "+x.image);
1938		}
1939    }
1940|
1941  x = <STRING_LITERAL>/*@bgen(jjtree)*/
1942                       {
1943                         jjtree.closeNodeScope(jjtn000, true);
1944                         jjtc000 = false;
1945                         jjtreeCloseNodeScope(jjtn000);
1946                       }
1947/*@egen*/ {
1948		try {
1949			jjtn000.stringSetup( x.image.substring(1, x.image.length() - 1) );
1950		} catch ( Exception e ) {
1951			throw new ParseException("Error parsing string: "+x.image);
1952		}
1953    }
1954|
1955  b = BooleanLiteral()/*@bgen(jjtree)*/
1956                        {
1957                          jjtree.closeNodeScope(jjtn000, true);
1958                          jjtc000 = false;
1959                          jjtreeCloseNodeScope(jjtn000);
1960                        }
1961/*@egen*/  {
1962    jjtn000.value = new Primitive( new Boolean(b) ); }
1963|
1964  NullLiteral()/*@bgen(jjtree)*/
1965                {
1966                  jjtree.closeNodeScope(jjtn000, true);
1967                  jjtc000 = false;
1968                  jjtreeCloseNodeScope(jjtn000);
1969                }
1970/*@egen*/ {
1971    jjtn000.value = Primitive.NULL; 
1972}
1973|
1974 VoidLiteral()/*@bgen(jjtree)*/
1975               {
1976                 jjtree.closeNodeScope(jjtn000, true);
1977                 jjtc000 = false;
1978                 jjtreeCloseNodeScope(jjtn000);
1979               }
1980/*@egen*/ {
1981    jjtn000.value = Primitive.VOID; }/*@bgen(jjtree)*/
1982  } catch (Throwable jjte000) {
1983    if (jjtc000) {
1984      jjtree.clearNodeScope(jjtn000);
1985      jjtc000 = false;
1986    } else {
1987      jjtree.popNode();
1988    }
1989    if (jjte000 instanceof RuntimeException) {
1990      throw (RuntimeException)jjte000;
1991    }
1992    if (jjte000 instanceof ParseException) {
1993      throw (ParseException)jjte000;
1994    }
1995    throw (Error)jjte000;
1996  } finally {
1997    if (jjtc000) {
1998      jjtree.closeNodeScope(jjtn000, true);
1999      jjtreeCloseNodeScope(jjtn000);
2000    }
2001  }
2002/*@egen*/
2003}
2004
2005boolean BooleanLiteral() :
2006{}
2007{
2008  "true" { return true; }
2009|
2010  "false" { return false; }
2011}
2012
2013void NullLiteral() :
2014{}
2015{
2016  "null"
2017}
2018
2019void VoidLiteral() :
2020{}
2021{
2022  "void"
2023}
2024
2025void Arguments()            :
2026{/*@bgen(jjtree) Arguments */
2027  BSHArguments jjtn000 = new BSHArguments(JJTARGUMENTS);
2028  boolean jjtc000 = true;
2029  jjtree.openNodeScope(jjtn000);
2030  jjtreeOpenNodeScope(jjtn000);
2031/*@egen*/ }
2032{/*@bgen(jjtree) Arguments */
2033  try {
2034/*@egen*/
2035  "(" [ ArgumentList()  ]  ")"/*@bgen(jjtree)*/
2036  } catch (Throwable jjte000) {
2037    if (jjtc000) {
2038      jjtree.clearNodeScope(jjtn000);
2039      jjtc000 = false;
2040    } else {
2041      jjtree.popNode();
2042    }
2043    if (jjte000 instanceof RuntimeException) {
2044      throw (RuntimeException)jjte000;
2045    }
2046    if (jjte000 instanceof ParseException) {
2047      throw (ParseException)jjte000;
2048    }
2049    throw (Error)jjte000;
2050  } finally {
2051    if (jjtc000) {
2052      jjtree.closeNodeScope(jjtn000, true);
2053      jjtreeCloseNodeScope(jjtn000);
2054    }
2055  }
2056/*@egen*/
2057}
2058
2059// leave these on the stack for Arguments() to handle
2060void ArgumentList() :
2061{ }
2062{
2063  Expression()
2064  ( "," Expression() )*
2065}
2066
2067void AllocationExpression()                       :
2068{/*@bgen(jjtree) AllocationExpression */
2069  BSHAllocationExpression jjtn000 = new BSHAllocationExpression(JJTALLOCATIONEXPRESSION);
2070  boolean jjtc000 = true;
2071  jjtree.openNodeScope(jjtn000);
2072  jjtreeOpenNodeScope(jjtn000);
2073/*@egen*/ }
2074{/*@bgen(jjtree) AllocationExpression */
2075  try {
2076/*@egen*/
2077  LOOKAHEAD(2)
2078  "new" PrimitiveType() ArrayDimensions()
2079|
2080  "new" AmbiguousName() 
2081	( 
2082		ArrayDimensions() 
2083	| 
2084		// SYNTACTIC_LOOKAHEAD
2085		Arguments() [ LOOKAHEAD(2) Block() ]
2086	)/*@bgen(jjtree)*/
2087  } catch (Throwable jjte000) {
2088    if (jjtc000) {
2089      jjtree.clearNodeScope(jjtn000);
2090      jjtc000 = false;
2091    } else {
2092      jjtree.popNode();
2093    }
2094    if (jjte000 instanceof RuntimeException) {
2095      throw (RuntimeException)jjte000;
2096    }
2097    if (jjte000 instanceof ParseException) {
2098      throw (ParseException)jjte000;
2099    }
2100    throw (Error)jjte000;
2101  } finally {
2102    if (jjtc000) {
2103      jjtree.closeNodeScope(jjtn000, true);
2104      jjtreeCloseNodeScope(jjtn000);
2105    }
2106  }
2107/*@egen*/
2108}
2109
2110void ArrayDimensions()                  :
2111{/*@bgen(jjtree) ArrayDimensions */
2112  BSHArrayDimensions jjtn000 = new BSHArrayDimensions(JJTARRAYDIMENSIONS);
2113  boolean jjtc000 = true;
2114  jjtree.openNodeScope(jjtn000);
2115  jjtreeOpenNodeScope(jjtn000);
2116/*@egen*/}
2117{/*@bgen(jjtree) ArrayDimensions */
2118  try {
2119/*@egen*/
2120  LOOKAHEAD(2)
2121  ( LOOKAHEAD(2) "[" Expression() "]" { jjtn000.addArrayDimension(); } )+
2122  // Removed trailing "[]" identifiers.  Specify array dims fully.
2123|
2124  ( "[" "]" { jjtn000.addArrayDimension(); } )+ ArrayInitializer()/*@bgen(jjtree)*/
2125  } catch (Throwable jjte000) {
2126    if (jjtc000) {
2127      jjtree.clearNodeScope(jjtn000);
2128      jjtc000 = false;
2129    } else {
2130      jjtree.popNode();
2131    }
2132    if (jjte000 instanceof RuntimeException) {
2133      throw (RuntimeException)jjte000;
2134    }
2135    if (jjte000 instanceof ParseException) {
2136      throw (ParseException)jjte000;
2137    }
2138    throw (Error)jjte000;
2139  } finally {
2140    if (jjtc000) {
2141      jjtree.closeNodeScope(jjtn000, true);
2142      jjtreeCloseNodeScope(jjtn000);
2143    }
2144  }
2145/*@egen*/
2146}
2147
2148
2149/*
2150 * Statement syntax follows.
2151 */
2152
2153void Statement() : { }
2154{
2155  LOOKAHEAD(2)
2156  LabeledStatement()
2157|
2158  Block()
2159|
2160  EmptyStatement()
2161|
2162  StatementExpression() ";"
2163|
2164  SwitchStatement()
2165|
2166  IfStatement()
2167|
2168  WhileStatement()
2169|
2170  DoStatement()
2171|
2172  ForStatement()
2173|
2174  BreakStatement()
2175|
2176  ContinueStatement()
2177|
2178  ReturnStatement()
2179|
2180  ThrowStatement()
2181|
2182  TryStatement()
2183}
2184
2185void LabeledStatement() :
2186{}
2187{
2188  <IDENTIFIER> ":" Statement()
2189}
2190
2191void Block()        :
2192{/*@bgen(jjtree) Block */
2193  BSHBlock jjtn000 = new BSHBlock(JJTBLOCK);
2194  boolean jjtc000 = true;
2195  jjtree.openNodeScope(jjtn000);
2196  jjtreeOpenNodeScope(jjtn000);
2197/*@egen*/}
2198{/*@bgen(jjtree) Block */
2199  try {
2200/*@egen*/
2201  "{" ( BlockStatement() )* "}"/*@bgen(jjtree)*/
2202  } catch (Throwable jjte000) {
2203    if (jjtc000) {
2204      jjtree.clearNodeScope(jjtn000);
2205      jjtc000 = false;
2206    } else {
2207      jjtree.popNode();
2208    }
2209    if (jjte000 instanceof RuntimeException) {
2210      throw (RuntimeException)jjte000;
2211    }
2212    if (jjte000 instanceof ParseException) {
2213      throw (ParseException)jjte000;
2214    }
2215    throw (Error)jjte000;
2216  } finally {
2217    if (jjtc000) {
2218      jjtree.closeNodeScope(jjtn000, true);
2219      jjtreeCloseNodeScope(jjtn000);
2220    }
2221  }
2222/*@egen*/
2223}
2224
2225void BlockStatement() :
2226{
2227}
2228{
2229// SYNTACTIC_LOOKAHEAD
2230  LOOKAHEAD( MethodDeclarationLookahead() ) MethodDeclaration()
2231|
2232// SYNTACTIC_LOOKAHEAD
2233  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
2234  TypedVariableDeclaration() ";"
2235|
2236  Statement()
2237
2238/* end */ // ??
2239
2240|  
2241  // Allow BeanShell imports in any block
2242  ImportDeclaration()
2243|
2244  FormalComment()
2245}
2246
2247void FormalComment()                                  :
2248{/*@bgen(jjtree) #FormalComment( retainComments) */
2249        BSHFormalComment jjtn000 = new BSHFormalComment(JJTFORMALCOMMENT);
2250        boolean jjtc000 = true;
2251        jjtree.openNodeScope(jjtn000);
2252        jjtreeOpenNodeScope(jjtn000);
2253/*@egen*/
2254	Token t;
2255}
2256{/*@bgen(jjtree) #FormalComment( retainComments) */
2257        try {
2258/*@egen*/
2259	t=<FORMAL_COMMENT>/*@bgen(jjtree)*/
2260                            {
2261                              jjtree.closeNodeScope(jjtn000,  retainComments);
2262                              jjtc000 = false;
2263                              jjtreeCloseNodeScope(jjtn000);
2264                            }
2265/*@egen*/  {
2266		jjtn000.text=t.image;
2267	}/*@bgen(jjtree)*/
2268        } finally {
2269          if (jjtc000) {
2270            jjtree.closeNodeScope(jjtn000,  retainComments);
2271            jjtreeCloseNodeScope(jjtn000);
2272          }
2273        }
2274/*@egen*/
2275}
2276
2277void EmptyStatement() :
2278{}
2279{
2280  ";"
2281}
2282
2283void StatementExpression() :
2284/*
2285 * The last expansion of this production accepts more than the legal
2286 * Java expansions for StatementExpression.
2287 */
2288{ }
2289{
2290  PreIncrementExpression()
2291|
2292  PreDecrementExpression()
2293|
2294// SYNTACTIC_LOOKAHEAD
2295  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
2296  Assignment() { }
2297|
2298  PostfixExpression()
2299}
2300
2301void SwitchStatement()                  :
2302{/*@bgen(jjtree) SwitchStatement */
2303  BSHSwitchStatement jjtn000 = new BSHSwitchStatement(JJTSWITCHSTATEMENT);
2304  boolean jjtc000 = true;
2305  jjtree.openNodeScope(jjtn000);
2306  jjtreeOpenNodeScope(jjtn000);
2307/*@egen*/}
2308{/*@bgen(jjtree) SwitchStatement */
2309  try {
2310/*@egen*/
2311  "switch" "(" Expression() ")" "{"
2312    ( SwitchLabel() ( BlockStatement() )* )*
2313  "}"/*@bgen(jjtree)*/
2314  } catch (Throwable jjte000) {
2315    if (jjtc000) {
2316      jjtree.clearNodeScope(jjtn000);
2317      jjtc000 = false;
2318    } else {
2319      jjtree.popNode();
2320    }
2321    if (jjte000 instanceof RuntimeException) {
2322      throw (RuntimeException)jjte000;
2323    }
2324    if (jjte000 instanceof ParseException) {
2325      throw (ParseException)jjte000;
2326    }
2327    throw (Error)jjte000;
2328  } finally {
2329    if (jjtc000) {
2330      jjtree.closeNodeScope(jjtn000, true);
2331      jjtreeCloseNodeScope(jjtn000);
2332    }
2333  }
2334/*@egen*/
2335}
2336
2337void SwitchLabel()              :
2338{/*@bgen(jjtree) SwitchLabel */
2339  BSHSwitchLabel jjtn000 = new BSHSwitchLabel(JJTSWITCHLABEL);
2340  boolean jjtc000 = true;
2341  jjtree.openNodeScope(jjtn000);
2342  jjtreeOpenNodeScope(jjtn000);
2343/*@egen*/}
2344{/*@bgen(jjtree) SwitchLabel */
2345  try {
2346/*@egen*/
2347  "case" Expression() ":"
2348|
2349  "default" ":"/*@bgen(jjtree)*/
2350                {
2351                  jjtree.closeNodeScope(jjtn000, true);
2352                  jjtc000 = false;
2353                  jjtreeCloseNodeScope(jjtn000);
2354                }
2355/*@egen*/ { jjtn000.isDefault = true; }/*@bgen(jjtree)*/
2356  } catch (Throwable jjte000) {
2357    if (jjtc000) {
2358      jjtree.clearNodeScope(jjtn000);
2359      jjtc000 = false;
2360    } else {
2361      jjtree.popNode();
2362    }
2363    if (jjte000 instanceof RuntimeException) {
2364      throw (RuntimeException)jjte000;
2365    }
2366    if (jjte000 instanceof ParseException) {
2367      throw (ParseException)jjte000;
2368    }
2369    throw (Error)jjte000;
2370  } finally {
2371    if (jjtc000) {
2372      jjtree.closeNodeScope(jjtn000, true);
2373      jjtreeCloseNodeScope(jjtn000);
2374    }
2375  }
2376/*@egen*/
2377}
2378
2379void IfStatement()              :
2380/*
2381 * The disambiguating algorithm of JavaCC automatically binds dangling
2382 * else's to the innermost if statement.  The LOOKAHEAD specification
2383 * is to tell JavaCC that we know what we are doing.
2384 */
2385{/*@bgen(jjtree) IfStatement */
2386  BSHIfStatement jjtn000 = new BSHIfStatement(JJTIFSTATEMENT);
2387  boolean jjtc000 = true;
2388  jjtree.openNodeScope(jjtn000);
2389  jjtreeOpenNodeScope(jjtn000);
2390/*@egen*/}
2391{/*@bgen(jjtree) IfStatement */
2392  try {
2393/*@egen*/
2394  "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]/*@bgen(jjtree)*/
2395  } catch (Throwable jjte000) {
2396    if (jjtc000) {
2397      jjtree.clearNodeScope(jjtn000);
2398      jjtc000 = false;
2399    } else {
2400      jjtree.popNode();
2401    }
2402    if (jjte000 instanceof RuntimeException) {
2403      throw (RuntimeException)jjte000;
2404    }
2405    if (jjte000 instanceof ParseException) {
2406      throw (ParseException)jjte000;
2407    }
2408    throw (Error)jjte000;
2409  } finally {
2410    if (jjtc000) {
2411      jjtree.closeNodeScope(jjtn000, true);
2412      jjtreeCloseNodeScope(jjtn000);
2413    }
2414  }
2415/*@egen*/
2416}
2417
2418void WhileStatement()                 :
2419{/*@bgen(jjtree) WhileStatement */
2420  BSHWhileStatement jjtn000 = new BSHWhileStatement(JJTWHILESTATEMENT);
2421  boolean jjtc000 = true;
2422  jjtree.openNodeScope(jjtn000);
2423  jjtreeOpenNodeScope(jjtn000);
2424/*@egen*/}
2425{/*@bgen(jjtree) WhileStatement */
2426  try {
2427/*@egen*/
2428  "while" "(" Expression() ")" Statement()/*@bgen(jjtree)*/
2429  } catch (Throwable jjte000) {
2430    if (jjtc000) {
2431      jjtree.clearNodeScope(jjtn