/jEdit/tags/jedit-4-2-pre4/bsh/Parser.java
# · Java · 2298 lines · 2096 code · 62 blank · 140 comment · 265 complexity · 5bf1ebd4005fc0aade8cb6d68d86bf40 MD5 · raw file
- /* Generated By:JJTree&JavaCC: Do not edit this line. Parser.java */
- package bsh;
- import java.io.*;
- import java.util.Vector;
- /**
- This is the BeanShell parser. It is used internally by the Interpreter
- class (which is probably what you are looking for). The parser knows
- only how to parse the structure of the language, it does not understand
- names, commands, etc.
- <p>
- You can use the Parser from the command line to do basic structural
- validation of BeanShell files without actually executing them. e.g.
- <code><pre>
- java bsh.Parser [ -p ] file [ file ] [ ... ]
- </pre></code>
- <p>
- The -p option causes the abstract syntax to be printed.
- <p>
- From code you'd use the Parser like this:
- <p
- <code><pre>
- Parser parser = new Parser(in);
- while( !(eof=parser.Line()) ) {
- SimpleNode node = parser.popNode();
- // use the node, etc. (See bsh.BSH* classes)
- }
- </pre></code>
- */
- public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants {/*@bgen(jjtree)*/
- protected JJTParserState jjtree = new JJTParserState();boolean retainComments = false;
- public void setRetainComments( boolean b ) {
- retainComments = b;
- }
- void jjtreeOpenNodeScope(Node n) {
- ((SimpleNode)n).firstToken = getToken(1);
- }
- void jjtreeCloseNodeScope(Node n) {
- ((SimpleNode)n).lastToken = getToken(0);
- }
- /**
- Re-initialize the input stream and token source.
- */
- void reInitInput( Reader in ) {
- ReInit(in);
- }
- public SimpleNode popNode()
- {
- if ( jjtree.nodeArity() > 0) // number of child nodes
- return (SimpleNode)jjtree.popNode();
- else
- return null;
- }
- /**
- Explicitly re-initialize just the token reader.
- This seems to be necessary to avoid certain looping errors when
- reading bogus input. See Interpreter.
- */
- void reInitTokenInput( Reader in ) {
- jj_input_stream.ReInit( in,
- jj_input_stream.getEndLine(),
- jj_input_stream.getEndColumn() );
- }
- public static void main( String [] args )
- throws IOException, ParseException
- {
- boolean print = false;
- int i=0;
- if ( args[0].equals("-p") ) {
- i++;
- print=true;
- }
- for(; i< args.length; i++) {
- Reader in = new FileReader(args[i]);
- Parser parser = new Parser(in);
- parser.setRetainComments(true);
- while( !parser.Line()/*eof*/ )
- if ( print )
- System.out.println( parser.popNode() );
- }
- }
- /**
- Lookahead for the enhanced for statement.
- Expect "for" "(" and then see whether we hit ":" or a ";" first.
- */
- boolean isRegularForStatement()
- {
- int curTok = 1;
- Token tok;
- tok = getToken(curTok++);
- if ( tok.kind != FOR ) return false;
- tok = getToken(curTok++);
- if ( tok.kind != LPAREN ) return false;
- while (true)
- {
- tok = getToken(curTok++);
- switch (tok.kind) {
- case COLON:
- return false;
- case SEMICOLON:
- return true;
- case EOF:
- return false;
- }
- }
- }
- /**
- Lookahead to determine whether a method has a return type.
- // Case 1 - primitive or void
- [ void, boolean, char, ... ] foo() { }
- byte [] foo() { }
- // Case 2 - simple type name
- Foo foo () { }
- Foo [] foo () { }
- // Case 3 - compound type name
- foo.Foo foo () { }
- foo.Foo [] foo () { }
- // Case 4 - Parameterized return type?
- // ??
- // Case N - no type
- foo () { }
- */
- /*
- Note: it's important not to read ahead tokens (e.g. tok2) unless
- previous ones match. We're used in lookaheads and if we have to wait
- for tokens that couldn't match it messes up interactivity on the
- command line.
- */
- boolean methodHasReturnType()
- {
- Token tok1 = getToken(1), tok2=null;
- // Case 1
- if ( tok1.kind == VOID || tok1.kind == BOOLEAN || tok1.kind == CHAR
- || tok1.kind == BYTE || tok1.kind == SHORT || tok1.kind == INT
- || tok1.kind == LONG || tok1.kind == FLOAT || tok1.kind == DOUBLE
- )
- return true;
- // Case 2
- if ( tok1.kind == IDENTIFIER && (tok2=getToken(2)).kind == LBRACKET )
- return true;
- if ( tok1.kind == IDENTIFIER && tok2.kind == IDENTIFIER
- && getToken(3).kind == LPAREN )
- return true;
- // Case 3
- if ( tok1.kind == IDENTIFIER && tok2.kind == DOT )
- return true;
- // Case N
- return false;
- }
- /**
- Generate a ParseException with the specified message, pointing to the
- current token.
- The auto-generated Parser.generateParseException() method does not
- provide line number info, therefore we do this.
- */
- ParseException createParseException( String message )
- {
- Token errortok = token;
- int line = errortok.beginLine, column = errortok.beginColumn;
- String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
- return new ParseException( "Parse error at line " + line
- + ", column " + column + " : " + message );
- }
- /*
- Thanks to Sreenivasa Viswanadha for suggesting how to get rid of expensive
- lookahead here.
- */
- final public boolean Line() throws ParseException {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 0:
- jj_consume_token(0);
- Interpreter.debug("End of File!");
- {if (true) return true;}
- break;
- default:
- if (jj_2_1(1)) {
- BlockStatement();
- {if (true) return false;}
- } else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- throw new Error("Missing return statement in function");
- }
- /*****************************************
- * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
- *****************************************/
- /*
- Gather modifiers for a class, method, or field.
- I lookahead is true then we are being called as part of a lookahead and we
- should not enforce any rules. Otherwise we validate based on context
- (field, method, class)
- */
- final public Modifiers Modifiers(int context, boolean lookahead) throws ParseException {
- Modifiers mods = null;
- label_1:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ABSTRACT:
- case FINAL:
- case NATIVE:
- case PRIVATE:
- case PROTECTED:
- case PUBLIC:
- case STATIC:
- case STRICTFP:
- case SYNCHRONIZED:
- case TRANSIENT:
- case VOLATILE:
- ;
- break;
- default:
- break label_1;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PRIVATE:
- jj_consume_token(PRIVATE);
- break;
- case PROTECTED:
- jj_consume_token(PROTECTED);
- break;
- case PUBLIC:
- jj_consume_token(PUBLIC);
- break;
- case SYNCHRONIZED:
- jj_consume_token(SYNCHRONIZED);
- break;
- case FINAL:
- jj_consume_token(FINAL);
- break;
- case NATIVE:
- jj_consume_token(NATIVE);
- break;
- case TRANSIENT:
- jj_consume_token(TRANSIENT);
- break;
- case VOLATILE:
- jj_consume_token(VOLATILE);
- break;
- case ABSTRACT:
- jj_consume_token(ABSTRACT);
- break;
- case STATIC:
- jj_consume_token(STATIC);
- break;
- case STRICTFP:
- jj_consume_token(STRICTFP);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- if ( !lookahead )
- try {
- if ( mods == null ) mods = new Modifiers();
- mods.addModifier( context, getToken(0).image );
- } catch ( IllegalStateException e ) {
- {if (true) throw createParseException( e.getMessage() );}
- }
- }
- {if (true) return mods;}
- throw new Error("Missing return statement in function");
- }
- /**
- */
- final public void ClassDeclaration() throws ParseException {
- /*@bgen(jjtree) ClassDeclaration */
- BSHClassDeclaration jjtn000 = new BSHClassDeclaration(JJTCLASSDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Modifiers mods;
- Token t;
- int numInterfaces;
- try {
- mods = Modifiers(Modifiers.CLASS, false);
- jj_consume_token(CLASS);
- t = jj_consume_token(IDENTIFIER);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case EXTENDS:
- jj_consume_token(EXTENDS);
- AmbiguousName();
- jjtn000.extend = true;
- break;
- default:
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IMPLEMENTS:
- jj_consume_token(IMPLEMENTS);
- numInterfaces = NameList();
- jjtn000.numInterfaces=numInterfaces;
- break;
- default:
- ;
- }
- Block();
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.modifiers = mods;
- jjtn000.name = t.image;
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void MethodDeclaration() throws ParseException {
- /*@bgen(jjtree) MethodDeclaration */
- BSHMethodDeclaration jjtn000 = new BSHMethodDeclaration(JJTMETHODDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t = null;
- Modifiers mods;
- int count;
- try {
- mods = Modifiers(Modifiers.METHOD, false);
- jjtn000.modifiers = mods;
- if (methodHasReturnType()) {
- ReturnType();
- } else {
- ;
- }
- t = jj_consume_token(IDENTIFIER);
- jjtn000.name = t.image;
- FormalParameters();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case THROWS:
- jj_consume_token(THROWS);
- count = NameList();
- jjtn000.numThrows=count;
- break;
- default:
- ;
- }
- Block();
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- /**
- It's tempting to collapse this to one like like so:
- [ LOOKAHEAD( { methodHasReturnType() } ) ReturnType() ]
- <IDENTIFIER> FormalParameters() "{"
- However this doesn't work because nested lookaheads are not evaluated
- during lookahead!
- http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq.htm#tth_sEc4.9
- */
- final public void MethodDeclarationLookahead() throws ParseException {
- Modifiers(Modifiers.METHOD, true);
- if (methodHasReturnType()) {
- ReturnType();
- jj_consume_token(IDENTIFIER);
- FormalParameters();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case THROWS:
- jj_consume_token(THROWS);
- NameList();
- break;
- default:
- ;
- }
- jj_consume_token(LBRACE);
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- jj_consume_token(IDENTIFIER);
- FormalParameters();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case THROWS:
- jj_consume_token(THROWS);
- NameList();
- break;
- default:
- ;
- }
- jj_consume_token(LBRACE);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- final public void ImportDeclaration() throws ParseException {
- /*@bgen(jjtree) ImportDeclaration */
- BSHImportDeclaration jjtn000 = new BSHImportDeclaration(JJTIMPORTDECLARATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t = null;
- try {
- if (jj_2_2(2)) {
- jj_consume_token(IMPORT);
- AmbiguousName();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DOT:
- t = jj_consume_token(DOT);
- jj_consume_token(STAR);
- break;
- default:
- ;
- }
- jj_consume_token(SEMICOLON);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- if ( t != null )
- jjtn000.importPackage = true;
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IMPORT:
- jj_consume_token(IMPORT);
- jj_consume_token(STAR);
- jj_consume_token(SEMICOLON);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.superImport = true;
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void VariableDeclarator() throws ParseException {
- /*@bgen(jjtree) VariableDeclarator */
- BSHVariableDeclarator jjtn000 = new BSHVariableDeclarator(JJTVARIABLEDECLARATOR);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t;
- Modifiers mods;
- try {
- t = jj_consume_token(IDENTIFIER);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ASSIGN:
- jj_consume_token(ASSIGN);
- VariableInitializer();
- break;
- default:
- ;
- }
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.name = t.image;
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- /*
- Can get rid of this if we ignore postfix array dimensions in declarations.
- I don't like them and I don't want to deal with them right now.
- void VariableDeclaratorId() #VariableDeclaratorId :
- { Token t; }
- {
- t=<IDENTIFIER> { jjtThis.name = t.image; }
- ( "[" "]" { jjtThis.addUndefinedDimension(); } )*
- }
- */
- final public void VariableInitializer() throws ParseException {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- ArrayInitializer();
- break;
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- case BANG:
- case TILDE:
- case INCR:
- case DECR:
- case PLUS:
- case MINUS:
- Expression();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- final public void ArrayInitializer() throws ParseException {
- /*@bgen(jjtree) ArrayInitializer */
- BSHArrayInitializer jjtn000 = new BSHArrayInitializer(JJTARRAYINITIALIZER);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- jj_consume_token(LBRACE);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- case LBRACE:
- case BANG:
- case TILDE:
- case INCR:
- case DECR:
- case PLUS:
- case MINUS:
- VariableInitializer();
- label_2:
- while (true) {
- if (jj_2_3(2)) {
- ;
- } else {
- break label_2;
- }
- jj_consume_token(COMMA);
- VariableInitializer();
- }
- break;
- default:
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- jj_consume_token(COMMA);
- break;
- default:
- ;
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void FormalParameters() throws ParseException {
- /*@bgen(jjtree) FormalParameters */
- BSHFormalParameters jjtn000 = new BSHFormalParameters(JJTFORMALPARAMETERS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- jj_consume_token(LPAREN);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FLOAT:
- case INT:
- case LONG:
- case SHORT:
- case IDENTIFIER:
- FormalParameter();
- label_3:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- break label_3;
- }
- jj_consume_token(COMMA);
- FormalParameter();
- }
- break;
- default:
- ;
- }
- jj_consume_token(RPAREN);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void FormalParameter() throws ParseException {
- /*@bgen(jjtree) FormalParameter */
- BSHFormalParameter jjtn000 = new BSHFormalParameter(JJTFORMALPARAMETER);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t;
- try {
- if (jj_2_4(2)) {
- Type();
- t = jj_consume_token(IDENTIFIER);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.name = t.image;
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- t = jj_consume_token(IDENTIFIER);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.name = t.image;
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- /*
- Type, name and expression syntax follows.
- */
- final public void Type() throws ParseException {
- /*@bgen(jjtree) Type */
- BSHType jjtn000 = new BSHType(JJTTYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FLOAT:
- case INT:
- case LONG:
- case SHORT:
- PrimitiveType();
- break;
- case IDENTIFIER:
- AmbiguousName();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- label_4:
- while (true) {
- if (jj_2_5(2)) {
- ;
- } else {
- break label_4;
- }
- jj_consume_token(LBRACKET);
- jj_consume_token(RBRACKET);
- jjtn000.addArrayDimension();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- /*
- Originally called ResultType in the grammar
- */
- final public void ReturnType() throws ParseException {
- /*@bgen(jjtree) ReturnType */
- BSHReturnType jjtn000 = new BSHReturnType(JJTRETURNTYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case VOID:
- jj_consume_token(VOID);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.isVoid = true;
- break;
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FLOAT:
- case INT:
- case LONG:
- case SHORT:
- case IDENTIFIER:
- Type();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void PrimitiveType() throws ParseException {
- /*@bgen(jjtree) PrimitiveType */
- BSHPrimitiveType jjtn000 = new BSHPrimitiveType(JJTPRIMITIVETYPE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- jj_consume_token(BOOLEAN);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Boolean.TYPE;
- break;
- case CHAR:
- jj_consume_token(CHAR);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Character.TYPE;
- break;
- case BYTE:
- jj_consume_token(BYTE);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Byte.TYPE;
- break;
- case SHORT:
- jj_consume_token(SHORT);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Short.TYPE;
- break;
- case INT:
- jj_consume_token(INT);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Integer.TYPE;
- break;
- case LONG:
- jj_consume_token(LONG);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Long.TYPE;
- break;
- case FLOAT:
- jj_consume_token(FLOAT);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Float.TYPE;
- break;
- case DOUBLE:
- jj_consume_token(DOUBLE);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.type = Double.TYPE;
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void AmbiguousName() throws ParseException {
- /*@bgen(jjtree) AmbiguousName */
- BSHAmbiguousName jjtn000 = new BSHAmbiguousName(JJTAMBIGUOUSNAME);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t;
- StringBuffer s;
- try {
- t = jj_consume_token(IDENTIFIER);
- s = new StringBuffer(t.image);
- label_5:
- while (true) {
- if (jj_2_6(2)) {
- ;
- } else {
- break label_5;
- }
- jj_consume_token(DOT);
- t = jj_consume_token(IDENTIFIER);
- s.append("."+t.image);
- }
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.text = s.toString();
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public int NameList() throws ParseException {
- int count = 0;
- AmbiguousName();
- ++count;
- label_6:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- break label_6;
- }
- jj_consume_token(COMMA);
- AmbiguousName();
- ++count;
- }
- {if (true) return count;}
- throw new Error("Missing return statement in function");
- }
- /*
- * Expression syntax follows.
- */
- final public void Expression() throws ParseException {
- if (jj_2_7(2147483647)) {
- Assignment();
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- case BANG:
- case TILDE:
- case INCR:
- case DECR:
- case PLUS:
- case MINUS:
- ConditionalExpression();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- final public void Assignment() throws ParseException {
- /*@bgen(jjtree) Assignment */
- BSHAssignment jjtn000 = new BSHAssignment(JJTASSIGNMENT);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);int op ;
- try {
- PrimaryExpression();
- op = AssignmentOperator();
- jjtn000.operator = op;
- Expression();
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public int AssignmentOperator() throws ParseException {
- Token t;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ASSIGN:
- jj_consume_token(ASSIGN);
- break;
- case STARASSIGN:
- jj_consume_token(STARASSIGN);
- break;
- case SLASHASSIGN:
- jj_consume_token(SLASHASSIGN);
- break;
- case MODASSIGN:
- jj_consume_token(MODASSIGN);
- break;
- case PLUSASSIGN:
- jj_consume_token(PLUSASSIGN);
- break;
- case MINUSASSIGN:
- jj_consume_token(MINUSASSIGN);
- break;
- case ANDASSIGN:
- jj_consume_token(ANDASSIGN);
- break;
- case XORASSIGN:
- jj_consume_token(XORASSIGN);
- break;
- case ORASSIGN:
- jj_consume_token(ORASSIGN);
- break;
- case LSHIFTASSIGN:
- jj_consume_token(LSHIFTASSIGN);
- break;
- case LSHIFTASSIGNX:
- jj_consume_token(LSHIFTASSIGNX);
- break;
- case RSIGNEDSHIFTASSIGN:
- jj_consume_token(RSIGNEDSHIFTASSIGN);
- break;
- case RSIGNEDSHIFTASSIGNX:
- jj_consume_token(RSIGNEDSHIFTASSIGNX);
- break;
- case RUNSIGNEDSHIFTASSIGN:
- jj_consume_token(RUNSIGNEDSHIFTASSIGN);
- break;
- case RUNSIGNEDSHIFTASSIGNX:
- jj_consume_token(RUNSIGNEDSHIFTASSIGNX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- t = getToken(0);
- {if (true) return t.kind;}
- throw new Error("Missing return statement in function");
- }
- final public void ConditionalExpression() throws ParseException {
- ConditionalOrExpression();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case HOOK:
- jj_consume_token(HOOK);
- Expression();
- jj_consume_token(COLON);
- BSHTernaryExpression jjtn001 = new BSHTernaryExpression(JJTTERNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- ConditionalExpression();
- } catch (Throwable jjte001) {
- if (jjtc001) {
- jjtree.clearNodeScope(jjtn001);
- jjtc001 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte001 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte001;}
- }
- if (jjte001 instanceof ParseException) {
- {if (true) throw (ParseException)jjte001;}
- }
- {if (true) throw (Error)jjte001;}
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 3);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- break;
- default:
- ;
- }
- }
- final public void ConditionalOrExpression() throws ParseException {
- Token t=null;
- ConditionalAndExpression();
- label_7:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOL_OR:
- case BOOL_ORX:
- ;
- break;
- default:
- break label_7;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOL_OR:
- t = jj_consume_token(BOOL_OR);
- break;
- case BOOL_ORX:
- t = jj_consume_token(BOOL_ORX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- ConditionalAndExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void ConditionalAndExpression() throws ParseException {
- Token t=null;
- InclusiveOrExpression();
- label_8:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOL_AND:
- case BOOL_ANDX:
- ;
- break;
- default:
- break label_8;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOL_AND:
- t = jj_consume_token(BOOL_AND);
- break;
- case BOOL_ANDX:
- t = jj_consume_token(BOOL_ANDX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- InclusiveOrExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void InclusiveOrExpression() throws ParseException {
- Token t=null;
- ExclusiveOrExpression();
- label_9:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BIT_OR:
- case BIT_ORX:
- ;
- break;
- default:
- break label_9;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BIT_OR:
- t = jj_consume_token(BIT_OR);
- break;
- case BIT_ORX:
- t = jj_consume_token(BIT_ORX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- ExclusiveOrExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void ExclusiveOrExpression() throws ParseException {
- Token t=null;
- AndExpression();
- label_10:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case XOR:
- ;
- break;
- default:
- break label_10;
- }
- t = jj_consume_token(XOR);
- AndExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void AndExpression() throws ParseException {
- Token t=null;
- EqualityExpression();
- label_11:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BIT_AND:
- case BIT_ANDX:
- ;
- break;
- default:
- break label_11;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BIT_AND:
- t = jj_consume_token(BIT_AND);
- break;
- case BIT_ANDX:
- t = jj_consume_token(BIT_ANDX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- EqualityExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void EqualityExpression() throws ParseException {
- Token t = null;
- InstanceOfExpression();
- label_12:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case EQ:
- case NE:
- ;
- break;
- default:
- break label_12;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case EQ:
- t = jj_consume_token(EQ);
- break;
- case NE:
- t = jj_consume_token(NE);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- InstanceOfExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void InstanceOfExpression() throws ParseException {
- Token t = null;
- RelationalExpression();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case INSTANCEOF:
- t = jj_consume_token(INSTANCEOF);
- Type();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- break;
- default:
- ;
- }
- }
- final public void RelationalExpression() throws ParseException {
- Token t = null;
- ShiftExpression();
- label_13:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case GT:
- case GTX:
- case LT:
- case LTX:
- case LE:
- case LEX:
- case GE:
- case GEX:
- ;
- break;
- default:
- break label_13;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LT:
- t = jj_consume_token(LT);
- break;
- case LTX:
- t = jj_consume_token(LTX);
- break;
- case GT:
- t = jj_consume_token(GT);
- break;
- case GTX:
- t = jj_consume_token(GTX);
- break;
- case LE:
- t = jj_consume_token(LE);
- break;
- case LEX:
- t = jj_consume_token(LEX);
- break;
- case GE:
- t = jj_consume_token(GE);
- break;
- case GEX:
- t = jj_consume_token(GEX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- ShiftExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void ShiftExpression() throws ParseException {
- Token t = null;
- AdditiveExpression();
- label_14:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LSHIFT:
- case LSHIFTX:
- case RSIGNEDSHIFT:
- case RSIGNEDSHIFTX:
- case RUNSIGNEDSHIFT:
- case RUNSIGNEDSHIFTX:
- ;
- break;
- default:
- break label_14;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LSHIFT:
- t = jj_consume_token(LSHIFT);
- break;
- case LSHIFTX:
- t = jj_consume_token(LSHIFTX);
- break;
- case RSIGNEDSHIFT:
- t = jj_consume_token(RSIGNEDSHIFT);
- break;
- case RSIGNEDSHIFTX:
- t = jj_consume_token(RSIGNEDSHIFTX);
- break;
- case RUNSIGNEDSHIFT:
- t = jj_consume_token(RUNSIGNEDSHIFT);
- break;
- case RUNSIGNEDSHIFTX:
- t = jj_consume_token(RUNSIGNEDSHIFTX);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- AdditiveExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void AdditiveExpression() throws ParseException {
- Token t = null;
- MultiplicativeExpression();
- label_15:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- case MINUS:
- ;
- break;
- default:
- break label_15;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- t = jj_consume_token(PLUS);
- break;
- case MINUS:
- t = jj_consume_token(MINUS);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- MultiplicativeExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void MultiplicativeExpression() throws ParseException {
- Token t = null;
- UnaryExpression();
- label_16:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case STAR:
- case SLASH:
- case MOD:
- ;
- break;
- default:
- break label_16;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case STAR:
- t = jj_consume_token(STAR);
- break;
- case SLASH:
- t = jj_consume_token(SLASH);
- break;
- case MOD:
- t = jj_consume_token(MOD);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- UnaryExpression();
- BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 2);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- }
- final public void UnaryExpression() throws ParseException {
- Token t = null;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- case MINUS:
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case PLUS:
- t = jj_consume_token(PLUS);
- break;
- case MINUS:
- t = jj_consume_token(MINUS);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- UnaryExpression();
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- break;
- case INCR:
- PreIncrementExpression();
- break;
- case DECR:
- PreDecrementExpression();
- break;
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- case BANG:
- case TILDE:
- UnaryExpressionNotPlusMinus();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- final public void PreIncrementExpression() throws ParseException {
- Token t = null;
- t = jj_consume_token(INCR);
- PrimaryExpression();
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- final public void PreDecrementExpression() throws ParseException {
- Token t = null;
- t = jj_consume_token(DECR);
- PrimaryExpression();
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- }
- final public void UnaryExpressionNotPlusMinus() throws ParseException {
- Token t = null;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BANG:
- case TILDE:
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case TILDE:
- t = jj_consume_token(TILDE);
- break;
- case BANG:
- t = jj_consume_token(BANG);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- UnaryExpression();
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- break;
- default:
- if (jj_2_8(2147483647)) {
- CastExpression();
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- PostfixExpression();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- }
- // This production is to determine lookahead only.
- final public void CastLookahead() throws ParseException {
- if (jj_2_9(2)) {
- jj_consume_token(LPAREN);
- PrimitiveType();
- } else if (jj_2_10(2147483647)) {
- jj_consume_token(LPAREN);
- AmbiguousName();
- jj_consume_token(LBRACKET);
- jj_consume_token(RBRACKET);
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LPAREN:
- jj_consume_token(LPAREN);
- AmbiguousName();
- jj_consume_token(RPAREN);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case TILDE:
- jj_consume_token(TILDE);
- break;
- case BANG:
- jj_consume_token(BANG);
- break;
- case LPAREN:
- jj_consume_token(LPAREN);
- break;
- case IDENTIFIER:
- jj_consume_token(IDENTIFIER);
- break;
- case NEW:
- jj_consume_token(NEW);
- break;
- case FALSE:
- case NULL:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- Literal();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- final public void PostfixExpression() throws ParseException {
- Token t = null;
- if (jj_2_11(2147483647)) {
- PrimaryExpression();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case INCR:
- t = jj_consume_token(INCR);
- break;
- case DECR:
- t = jj_consume_token(DECR);
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- BSHUnaryExpression jjtn001 = new BSHUnaryExpression(JJTUNARYEXPRESSION);
- boolean jjtc001 = true;
- jjtree.openNodeScope(jjtn001);
- jjtreeOpenNodeScope(jjtn001);
- try {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtc001 = false;
- jjtreeCloseNodeScope(jjtn001);
- jjtn001.kind = t.kind; jjtn001.postfix = true;
- } finally {
- if (jjtc001) {
- jjtree.closeNodeScope(jjtn001, 1);
- jjtreeCloseNodeScope(jjtn001);
- }
- }
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case BOOLEAN:
- case BYTE:
- case CHAR:
- case DOUBLE:
- case FALSE:
- case FLOAT:
- case INT:
- case LONG:
- case NEW:
- case NULL:
- case SHORT:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- case IDENTIFIER:
- case LPAREN:
- PrimaryExpression();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- final public void CastExpression() throws ParseException {
- /*@bgen(jjtree) CastExpression */
- BSHCastExpression jjtn000 = new BSHCastExpression(JJTCASTEXPRESSION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- if (jj_2_12(2147483647)) {
- jj_consume_token(LPAREN);
- Type();
- jj_consume_token(RPAREN);
- UnaryExpression();
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LPAREN:
- jj_consume_token(LPAREN);
- Type();
- jj_consume_token(RPAREN);
- UnaryExpressionNotPlusMinus();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void PrimaryExpression() throws ParseException {
- /*@bgen(jjtree) PrimaryExpression */
- BSHPrimaryExpression jjtn000 = new BSHPrimaryExpression(JJTPRIMARYEXPRESSION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- PrimaryPrefix();
- label_17:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- case LBRACKET:
- case DOT:
- ;
- break;
- default:
- break label_17;
- }
- PrimarySuffix();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void MethodInvocation() throws ParseException {
- /*@bgen(jjtree) MethodInvocation */
- BSHMethodInvocation jjtn000 = new BSHMethodInvocation(JJTMETHODINVOCATION);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);
- try {
- AmbiguousName();
- Arguments();
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void PrimaryPrefix() throws ParseException {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case FALSE:
- case NULL:
- case TRUE:
- case VOID:
- case INTEGER_LITERAL:
- case FLOATING_POINT_LITERAL:
- case CHARACTER_LITERAL:
- case STRING_LITERAL:
- Literal();
- break;
- case LPAREN:
- jj_consume_token(LPAREN);
- Expression();
- jj_consume_token(RPAREN);
- break;
- case NEW:
- AllocationExpression();
- break;
- default:
- if (jj_2_13(2147483647)) {
- MethodInvocation();
- } else if (jj_2_14(2147483647)) {
- Type();
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- AmbiguousName();
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- }
- final public void PrimarySuffix() throws ParseException {
- /*@bgen(jjtree) PrimarySuffix */
- BSHPrimarySuffix jjtn000 = new BSHPrimarySuffix(JJTPRIMARYSUFFIX);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token t = null;
- try {
- if (jj_2_15(2)) {
- jj_consume_token(DOT);
- jj_consume_token(CLASS);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.operation = BSHPrimarySuffix.CLASS;
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACKET:
- jj_consume_token(LBRACKET);
- Expression();
- jj_consume_token(RBRACKET);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.operation = BSHPrimarySuffix.INDEX;
- break;
- case DOT:
- jj_consume_token(DOT);
- t = jj_consume_token(IDENTIFIER);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LPAREN:
- Arguments();
- break;
- default:
- ;
- }
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.operation = BSHPrimarySuffix.NAME;
- jjtn000.field = t.image;
- break;
- case LBRACE:
- jj_consume_token(LBRACE);
- Expression();
- jj_consume_token(RBRACE);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- jjtn000.operation = BSHPrimarySuffix.PROPERTY;
- break;
- default:
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- jjtreeCloseNodeScope(jjtn000);
- }
- }
- }
- final public void Literal() throws ParseException {
- /*@bgen(jjtree) Literal */
- BSHLiteral jjtn000 = new BSHLiteral(JJTLITERAL);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- jjtreeOpenNodeScope(jjtn000);Token x;
- boolean b;
- String literal;
- char ch;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case INTEGER_LITERAL:
- x = jj_consume_token(INTEGER_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- literal = x.image;
- ch = literal.charAt(literal.length()-1);
- if(ch == 'l' || ch == 'L')
- {
- literal = literal.substring(0,literal.length()-1);
- // This really should be Long.decode, but there isn't one. As a result,
- // hex and octal literals ending in 'l' or 'L' don't work.
- jjtn000.value = new Primitive( new Long( literal ) );
- }
- else
- try {
- jjtn000.value = new Primitive( Integer.decode( literal ) );
- } catch ( NumberFormatException e ) {
- {if (true) throw createParseException(
- "Error or number too big for integer type: "+ literal );}
- }
- break;
- case FLOATING_POINT_LITERAL:
- x = jj_consume_token(FLOATING_POINT_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- literal = x.image;
- ch = literal.charAt(literal.length()-1);
- if(ch == 'f' || ch == 'F')
- {
- literal = literal.substring(0,literal.length()-1);
- jjtn000.value = new Primitive( new Float( literal ) );
- }
- else
- {
- if(ch == 'd' || ch == 'D')
- literal = literal.substring(0,literal.length()-1);
- jjtn000.value = new Primitive( new Double( literal ) );
- }
- break;
- case CHARACTER_LITERAL:
- x = jj_consume_token(CHARACTER_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- try {
- jjtn000.charSetup( x.image.substring(1, x.image.length() - 1) );
- } catch ( Exception e ) {
- {if (true) throw createParseException("Error parsing character: "+x.image);}
- }
- break;
- case STRING_LITERAL:
- x = jj_consume_token(STRING_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- try {
- jjtn000.stringSetup( x.image.substring(1, x.image.length() - 1) );
- } catch ( Exception e ) {
- {if (true) throw createParseException("Error parsing string: "+x.imag