PageRenderTime 379ms CodeModel.GetById 81ms app.highlight 225ms RepoModel.GetById 36ms app.codeStats 1ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/bsh/bsh.jj

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

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