PageRenderTime 486ms CodeModel.GetById 241ms app.highlight 162ms RepoModel.GetById 40ms app.codeStats 0ms

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

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

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