Source Code Cross Referenced for ExpressionRecognizer.java in  » J2EE » hgcommons » biz » hammurapi » eval » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » hgcommons » biz.hammurapi.eval 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // $ANTLR 2.7.5 (20050128): "expression.g" -> "ExpressionRecognizer.java"$
0002:
0003:        package biz.hammurapi.eval;
0004:
0005:        import antlr.TokenBuffer;
0006:        import antlr.TokenStreamException;
0007:        import antlr.TokenStreamIOException;
0008:        import antlr.ANTLRException;
0009:        import antlr.LLkParser;
0010:        import antlr.Token;
0011:        import antlr.TokenStream;
0012:        import antlr.RecognitionException;
0013:        import antlr.NoViableAltException;
0014:        import antlr.MismatchedTokenException;
0015:        import antlr.SemanticException;
0016:        import antlr.ParserSharedInputState;
0017:        import antlr.collections.impl.BitSet;
0018:        import antlr.collections.AST;
0019:        import java.util.Hashtable;
0020:        import antlr.ASTFactory;
0021:        import antlr.ASTPair;
0022:        import antlr.collections.impl.ASTArray;
0023:
0024:        /** Java 1.3 Recognizer
0025:         *
0026:         * Run 'java Main [-showtree] directory-full-of-java-files'
0027:         *
0028:         * [The -showtree option pops up a Swing frame that shows
0029:         *  the AST constructed from the parser.]
0030:         *
0031:         * Run 'java Main <directory full of java files>'
0032:         *
0033:         * Contributing authors:
0034:         *		John Mitchell		johnm@non.net
0035:         *		Terence Parr		parrt@magelang.com
0036:         *		John Lilley			jlilley@empathy.com
0037:         *		Scott Stanchfield	thetick@magelang.com
0038:         *		Markus Mohnen       mohnen@informatik.rwth-aachen.de
0039:         *      Peter Williams      pete.williams@sun.com
0040:         *      Allan Jacobs        Allan.Jacobs@eng.sun.com
0041:         *      Steve Messick       messick@redhills.com
0042:         *      John Pybus			john@pybus.org
0043:         *
0044:         * Version 1.00 December 9, 1997 -- initial release
0045:         * Version 1.01 December 10, 1997
0046:         *		fixed bug in octal def (0..7 not 0..8)
0047:         * Version 1.10 August 1998 (parrt)
0048:         *		added tree construction
0049:         *		fixed definition of WS,comments for mac,pc,unix newlines
0050:         *		added unary plus
0051:         * Version 1.11 (Nov 20, 1998)
0052:         *		Added "shutup" option to turn off last ambig warning.
0053:         *		Fixed inner class def to allow named class defs as statements
0054:         *		synchronized requires compound not simple statement
0055:         *		add [] after builtInType DOT class in primaryExpression
0056:         *		"const" is reserved but not valid..removed from modifiers
0057:         * Version 1.12 (Feb 2, 1999)
0058:         *		Changed LITERAL_xxx to xxx in tree grammar.
0059:         *		Updated java.g to use tokens {...} now for 2.6.0 (new feature).
0060:         *
0061:         * Version 1.13 (Apr 23, 1999)
0062:         *		Didn't have (stat)? for else clause in tree parser.
0063:         *		Didn't gen ASTs for interface extends.  Updated tree parser too.
0064:         *		Updated to 2.6.0.
0065:         * Version 1.14 (Jun 20, 1999)
0066:         *		Allowed final/abstract on local classes.
0067:         *		Removed local interfaces from methods
0068:         *		Put instanceof precedence where it belongs...in relationalExpr
0069:         *			It also had expr not type as arg; fixed it.
0070:         *		Missing ! on SEMI in classBlock
0071:         *		fixed: (expr) + "string" was parsed incorrectly (+ as unary plus).
0072:         *		fixed: didn't like Object[].class in parser or tree parser
0073:         * Version 1.15 (Jun 26, 1999)
0074:         *		Screwed up rule with instanceof in it. :(  Fixed.
0075:         *		Tree parser didn't like (expr).something; fixed.
0076:         *		Allowed multiple inheritance in tree grammar. oops.
0077:         * Version 1.16 (August 22, 1999)
0078:         *		Extending an interface built a wacky tree: had extra EXTENDS.
0079:         *		Tree grammar didn't allow multiple superinterfaces.
0080:         *		Tree grammar didn't allow empty var initializer: {}
0081:         * Version 1.17 (October 12, 1999)
0082:         *		ESC lexer rule allowed 399 max not 377 max.
0083:         *		java.tree.g didn't handle the expression of synchronized
0084:         *		statements.
0085:         * Version 1.18 (August 12, 2001)
0086:         *      	Terence updated to Java 2 Version 1.3 by
0087:         *		observing/combining work of Allan Jacobs and Steve
0088:         *		Messick.  Handles 1.3 src.  Summary:
0089:         *		o  primary didn't include boolean.class kind of thing
0090:         *      	o  constructor calls parsed explicitly now:
0091:         * 		   see explicitConstructorInvocation
0092:         *		o  add strictfp modifier
0093:         *      	o  missing objBlock after new expression in tree grammar
0094:         *		o  merged local class definition alternatives, moved after declaration
0095:         *		o  fixed problem with ClassName.super.field
0096:         *      	o  reordered some alternatives to make things more efficient
0097:         *		o  long and double constants were not differentiated from int/float
0098:         *		o  whitespace rule was inefficient: matched only one char
0099:         *		o  add an examples directory with some nasty 1.3 cases
0100:         *		o  made Main.java use buffered IO and a Reader for Unicode support
0101:         *		o  supports UNICODE?
0102:         *		   Using Unicode charVocabulay makes code file big, but only
0103:         *		   in the bitsets at the end. I need to make ANTLR generate
0104:         *		   unicode bitsets more efficiently.
0105:         * Version 1.19 (April 25, 2002)
0106:         *		Terence added in nice fixes by John Pybus concerning floating
0107:         *		constants and problems with super() calls.  John did a nice
0108:         *		reorg of the primary/postfix expression stuff to read better
0109:         *		and makes f.g.super() parse properly (it was METHOD_CALL not
0110:         *		a SUPER_CTOR_CALL).  Also:
0111:         *
0112:         *		o  "finally" clause was a root...made it a child of "try"
0113:         *		o  Added stuff for asserts too for Java 1.4, but *commented out*
0114:         *		   as it is not backward compatible.
0115:         *
0116:         * Version 1.20 (October 27, 2002)
0117:         *
0118:         *      Terence ended up reorging John Pybus' stuff to
0119:         *      remove some nondeterminisms and some syntactic predicates.
0120:         *      Note that the grammar is stricter now; e.g., this(...) must
0121:         *	be the first statement.
0122:         *
0123:         *      Trinary ?: operator wasn't working as array name:
0124:         *          (isBig ? bigDigits : digits)[i];
0125:         *
0126:         *      Checked parser/tree parser on source for
0127:         *          Resin-2.0.5, jive-2.1.1, jdk 1.3.1, Lucene, antlr 2.7.2a4,
0128:         *	    and the 110k-line jGuru server source.
0129:         *
0130:         * This grammar is in the PUBLIC DOMAIN
0131:         */
0132:        public class ExpressionRecognizer extends antlr.LLkParser implements 
0133:                ExpressionTokenTypes {
0134:
0135:            protected ExpressionRecognizer(TokenBuffer tokenBuf, int k) {
0136:                super (tokenBuf, k);
0137:                tokenNames = _tokenNames;
0138:                buildTokenTypeASTClassMap();
0139:                astFactory = new ASTFactory(getTokenTypeToASTClassMap());
0140:            }
0141:
0142:            public ExpressionRecognizer(TokenBuffer tokenBuf) {
0143:                this (tokenBuf, 3);
0144:            }
0145:
0146:            protected ExpressionRecognizer(TokenStream lexer, int k) {
0147:                super (lexer, k);
0148:                tokenNames = _tokenNames;
0149:                buildTokenTypeASTClassMap();
0150:                astFactory = new ASTFactory(getTokenTypeToASTClassMap());
0151:            }
0152:
0153:            public ExpressionRecognizer(TokenStream lexer) {
0154:                this (lexer, 3);
0155:            }
0156:
0157:            public ExpressionRecognizer(ParserSharedInputState state) {
0158:                super (state, 3);
0159:                tokenNames = _tokenNames;
0160:                buildTokenTypeASTClassMap();
0161:                astFactory = new ASTFactory(getTokenTypeToASTClassMap());
0162:            }
0163:
0164:            public final void expression() throws RecognitionException,
0165:                    TokenStreamException {
0166:
0167:                returnAST = null;
0168:                ASTPair currentAST = new ASTPair();
0169:                AST expression_AST = null;
0170:
0171:                unaryExpression();
0172:                astFactory.addASTChild(currentAST, returnAST);
0173:                match(Token.EOF_TYPE);
0174:                expression_AST = (AST) currentAST.root;
0175:                returnAST = expression_AST;
0176:            }
0177:
0178:            public final void unaryExpression() throws RecognitionException,
0179:                    TokenStreamException {
0180:
0181:                returnAST = null;
0182:                ASTPair currentAST = new ASTPair();
0183:                AST unaryExpression_AST = null;
0184:
0185:                switch (LA(1)) {
0186:                case MINUS: {
0187:                    AST tmp2_AST = null;
0188:                    tmp2_AST = astFactory.create(LT(1));
0189:                    astFactory.makeASTRoot(currentAST, tmp2_AST);
0190:                    match(MINUS);
0191:                    unaryExpression();
0192:                    astFactory.addASTChild(currentAST, returnAST);
0193:                    unaryExpression_AST = (AST) currentAST.root;
0194:                    break;
0195:                }
0196:                case PLUS: {
0197:                    AST tmp3_AST = null;
0198:                    tmp3_AST = astFactory.create(LT(1));
0199:                    astFactory.makeASTRoot(currentAST, tmp3_AST);
0200:                    match(PLUS);
0201:                    unaryExpression();
0202:                    astFactory.addASTChild(currentAST, returnAST);
0203:                    unaryExpression_AST = (AST) currentAST.root;
0204:                    break;
0205:                }
0206:                case LNOT:
0207:                case LPAREN:
0208:                case IDENT:
0209:                case LITERAL_true:
0210:                case LITERAL_false:
0211:                case LITERAL_null:
0212:                case NUM_INT:
0213:                case CHAR_LITERAL:
0214:                case STRING_LITERAL:
0215:                case NUM_FLOAT:
0216:                case NUM_LONG:
0217:                case NUM_DOUBLE: {
0218:                    unaryExpressionNotPlusMinus();
0219:                    astFactory.addASTChild(currentAST, returnAST);
0220:                    unaryExpression_AST = (AST) currentAST.root;
0221:                    break;
0222:                }
0223:                default: {
0224:                    throw new NoViableAltException(LT(1), getFilename());
0225:                }
0226:                }
0227:                returnAST = unaryExpression_AST;
0228:            }
0229:
0230:            public final void unaryExpressionNotPlusMinus()
0231:                    throws RecognitionException, TokenStreamException {
0232:
0233:                returnAST = null;
0234:                ASTPair currentAST = new ASTPair();
0235:                AST unaryExpressionNotPlusMinus_AST = null;
0236:                Token lpb = null;
0237:                AST lpb_AST = null;
0238:                Token lp = null;
0239:                AST lp_AST = null;
0240:
0241:                switch (LA(1)) {
0242:                case LNOT: {
0243:                    AST tmp4_AST = null;
0244:                    tmp4_AST = astFactory.create(LT(1));
0245:                    astFactory.makeASTRoot(currentAST, tmp4_AST);
0246:                    match(LNOT);
0247:                    unaryExpression();
0248:                    astFactory.addASTChild(currentAST, returnAST);
0249:                    unaryExpressionNotPlusMinus_AST = (AST) currentAST.root;
0250:                    break;
0251:                }
0252:                case LPAREN:
0253:                case IDENT:
0254:                case LITERAL_true:
0255:                case LITERAL_false:
0256:                case LITERAL_null:
0257:                case NUM_INT:
0258:                case CHAR_LITERAL:
0259:                case STRING_LITERAL:
0260:                case NUM_FLOAT:
0261:                case NUM_LONG:
0262:                case NUM_DOUBLE: {
0263:                    {
0264:                        if ((LA(1) == LPAREN)
0265:                                && (LA(2) == LPAREN)
0266:                                && ((LA(3) >= LITERAL_boolean && LA(3) <= LITERAL_double))) {
0267:                            lpb = LT(1);
0268:                            lpb_AST = astFactory.create(lpb);
0269:                            astFactory.makeASTRoot(currentAST, lpb_AST);
0270:                            match(LPAREN);
0271:                            if (inputState.guessing == 0) {
0272:                                lpb_AST.setType(TYPECAST);
0273:                            }
0274:                            builtInTypeSpecification(true);
0275:                            astFactory.addASTChild(currentAST, returnAST);
0276:                            match(RPAREN);
0277:                            unaryExpression();
0278:                            astFactory.addASTChild(currentAST, returnAST);
0279:                        } else {
0280:                            boolean synPredMatched6 = false;
0281:                            if (((LA(1) == LPAREN) && (LA(2) == LPAREN) && (LA(3) == IDENT))) {
0282:                                int _m6 = mark();
0283:                                synPredMatched6 = true;
0284:                                inputState.guessing++;
0285:                                try {
0286:                                    {
0287:                                        match(LPAREN);
0288:                                        classTypeSpecification(true);
0289:                                        match(RPAREN);
0290:                                        unaryExpressionNotPlusMinus();
0291:                                    }
0292:                                } catch (RecognitionException pe) {
0293:                                    synPredMatched6 = false;
0294:                                }
0295:                                rewind(_m6);
0296:                                inputState.guessing--;
0297:                            }
0298:                            if (synPredMatched6) {
0299:                                lp = LT(1);
0300:                                lp_AST = astFactory.create(lp);
0301:                                astFactory.makeASTRoot(currentAST, lp_AST);
0302:                                match(LPAREN);
0303:                                if (inputState.guessing == 0) {
0304:                                    lp_AST.setType(TYPECAST);
0305:                                }
0306:                                classTypeSpecification(true);
0307:                                astFactory.addASTChild(currentAST, returnAST);
0308:                                match(RPAREN);
0309:                                unaryExpressionNotPlusMinus();
0310:                                astFactory.addASTChild(currentAST, returnAST);
0311:                            } else if ((_tokenSet_0.member(LA(1)))) {
0312:                                postfixExpression();
0313:                                astFactory.addASTChild(currentAST, returnAST);
0314:                            } else {
0315:                                throw new NoViableAltException(LT(1),
0316:                                        getFilename());
0317:                            }
0318:                        }
0319:                    }
0320:                    unaryExpressionNotPlusMinus_AST = (AST) currentAST.root;
0321:                    break;
0322:                }
0323:                default: {
0324:                    throw new NoViableAltException(LT(1), getFilename());
0325:                }
0326:                }
0327:                returnAST = unaryExpressionNotPlusMinus_AST;
0328:            }
0329:
0330:            public final void builtInTypeSpecification(boolean addImagNode)
0331:                    throws RecognitionException, TokenStreamException {
0332:
0333:                returnAST = null;
0334:                ASTPair currentAST = new ASTPair();
0335:                AST builtInTypeSpecification_AST = null;
0336:                Token lb = null;
0337:                AST lb_AST = null;
0338:
0339:                match(LPAREN);
0340:                builtInType();
0341:                astFactory.addASTChild(currentAST, returnAST);
0342:                {
0343:                    _loop31: do {
0344:                        if ((LA(1) == LBRACK)) {
0345:                            lb = LT(1);
0346:                            lb_AST = astFactory.create(lb);
0347:                            astFactory.makeASTRoot(currentAST, lb_AST);
0348:                            match(LBRACK);
0349:                            if (inputState.guessing == 0) {
0350:                                lb_AST.setType(ARRAY_DECLARATOR);
0351:                            }
0352:                            match(RBRACK);
0353:                        } else {
0354:                            break _loop31;
0355:                        }
0356:
0357:                    } while (true);
0358:                }
0359:                match(RPAREN);
0360:                if (inputState.guessing == 0) {
0361:                    builtInTypeSpecification_AST = (AST) currentAST.root;
0362:
0363:                    if (addImagNode) {
0364:                        builtInTypeSpecification_AST = (AST) astFactory
0365:                                .make((new ASTArray(2)).add(
0366:                                        astFactory.create(TYPE, "TYPE")).add(
0367:                                        builtInTypeSpecification_AST));
0368:                    }
0369:
0370:                    currentAST.root = builtInTypeSpecification_AST;
0371:                    currentAST.child = builtInTypeSpecification_AST != null
0372:                            && builtInTypeSpecification_AST.getFirstChild() != null ? builtInTypeSpecification_AST
0373:                            .getFirstChild()
0374:                            : builtInTypeSpecification_AST;
0375:                    currentAST.advanceChildToEnd();
0376:                }
0377:                builtInTypeSpecification_AST = (AST) currentAST.root;
0378:                returnAST = builtInTypeSpecification_AST;
0379:            }
0380:
0381:            public final void classTypeSpecification(boolean addImagNode)
0382:                    throws RecognitionException, TokenStreamException {
0383:
0384:                returnAST = null;
0385:                ASTPair currentAST = new ASTPair();
0386:                AST classTypeSpecification_AST = null;
0387:                Token lb = null;
0388:                AST lb_AST = null;
0389:
0390:                match(LPAREN);
0391:                identifier();
0392:                astFactory.addASTChild(currentAST, returnAST);
0393:                {
0394:                    _loop28: do {
0395:                        if ((LA(1) == LBRACK)) {
0396:                            lb = LT(1);
0397:                            lb_AST = astFactory.create(lb);
0398:                            astFactory.makeASTRoot(currentAST, lb_AST);
0399:                            match(LBRACK);
0400:                            if (inputState.guessing == 0) {
0401:                                lb_AST.setType(ARRAY_DECLARATOR);
0402:                            }
0403:                            match(RBRACK);
0404:                        } else {
0405:                            break _loop28;
0406:                        }
0407:
0408:                    } while (true);
0409:                }
0410:                match(RPAREN);
0411:                if (inputState.guessing == 0) {
0412:                    classTypeSpecification_AST = (AST) currentAST.root;
0413:
0414:                    if (addImagNode) {
0415:                        classTypeSpecification_AST = (AST) astFactory
0416:                                .make((new ASTArray(2)).add(
0417:                                        astFactory.create(TYPE, "TYPE")).add(
0418:                                        classTypeSpecification_AST));
0419:                    }
0420:
0421:                    currentAST.root = classTypeSpecification_AST;
0422:                    currentAST.child = classTypeSpecification_AST != null
0423:                            && classTypeSpecification_AST.getFirstChild() != null ? classTypeSpecification_AST
0424:                            .getFirstChild()
0425:                            : classTypeSpecification_AST;
0426:                    currentAST.advanceChildToEnd();
0427:                }
0428:                classTypeSpecification_AST = (AST) currentAST.root;
0429:                returnAST = classTypeSpecification_AST;
0430:            }
0431:
0432:            public final void postfixExpression() throws RecognitionException,
0433:                    TokenStreamException {
0434:
0435:                returnAST = null;
0436:                ASTPair currentAST = new ASTPair();
0437:                AST postfixExpression_AST = null;
0438:                Token lp = null;
0439:                AST lp_AST = null;
0440:                Token lb = null;
0441:                AST lb_AST = null;
0442:
0443:                primaryExpression();
0444:                astFactory.addASTChild(currentAST, returnAST);
0445:                {
0446:                    _loop10: do {
0447:                        switch (LA(1)) {
0448:                        case DOT: {
0449:                            AST tmp13_AST = null;
0450:                            tmp13_AST = astFactory.create(LT(1));
0451:                            astFactory.makeASTRoot(currentAST, tmp13_AST);
0452:                            match(DOT);
0453:                            AST tmp14_AST = null;
0454:                            tmp14_AST = astFactory.create(LT(1));
0455:                            astFactory.addASTChild(currentAST, tmp14_AST);
0456:                            match(IDENT);
0457:                            {
0458:                                switch (LA(1)) {
0459:                                case LPAREN: {
0460:                                    lp = LT(1);
0461:                                    lp_AST = astFactory.create(lp);
0462:                                    astFactory.makeASTRoot(currentAST, lp_AST);
0463:                                    match(LPAREN);
0464:                                    if (inputState.guessing == 0) {
0465:                                        lp_AST.setType(METHOD_CALL);
0466:                                    }
0467:                                    argList();
0468:                                    astFactory.addASTChild(currentAST,
0469:                                            returnAST);
0470:                                    match(RPAREN);
0471:                                    break;
0472:                                }
0473:                                case EOF:
0474:                                case RPAREN:
0475:                                case DOT:
0476:                                case LBRACK:
0477:                                case RBRACK:
0478:                                case COMMA: {
0479:                                    break;
0480:                                }
0481:                                default: {
0482:                                    throw new NoViableAltException(LT(1),
0483:                                            getFilename());
0484:                                }
0485:                                }
0486:                            }
0487:                            break;
0488:                        }
0489:                        case LBRACK: {
0490:                            lb = LT(1);
0491:                            lb_AST = astFactory.create(lb);
0492:                            astFactory.makeASTRoot(currentAST, lb_AST);
0493:                            match(LBRACK);
0494:                            if (inputState.guessing == 0) {
0495:                                lb_AST.setType(INDEX_OP);
0496:                            }
0497:                            postfixExpression();
0498:                            astFactory.addASTChild(currentAST, returnAST);
0499:                            match(RBRACK);
0500:                            break;
0501:                        }
0502:                        default: {
0503:                            break _loop10;
0504:                        }
0505:                        }
0506:                    } while (true);
0507:                }
0508:                postfixExpression_AST = (AST) currentAST.root;
0509:                returnAST = postfixExpression_AST;
0510:            }
0511:
0512:            public final void primaryExpression() throws RecognitionException,
0513:                    TokenStreamException {
0514:
0515:                returnAST = null;
0516:                ASTPair currentAST = new ASTPair();
0517:                AST primaryExpression_AST = null;
0518:
0519:                switch (LA(1)) {
0520:                case IDENT: {
0521:                    identPrimary();
0522:                    astFactory.addASTChild(currentAST, returnAST);
0523:                    primaryExpression_AST = (AST) currentAST.root;
0524:                    break;
0525:                }
0526:                case NUM_INT:
0527:                case CHAR_LITERAL:
0528:                case STRING_LITERAL:
0529:                case NUM_FLOAT:
0530:                case NUM_LONG:
0531:                case NUM_DOUBLE: {
0532:                    constant();
0533:                    astFactory.addASTChild(currentAST, returnAST);
0534:                    primaryExpression_AST = (AST) currentAST.root;
0535:                    break;
0536:                }
0537:                case LITERAL_true: {
0538:                    AST tmp17_AST = null;
0539:                    tmp17_AST = astFactory.create(LT(1));
0540:                    astFactory.addASTChild(currentAST, tmp17_AST);
0541:                    match(LITERAL_true);
0542:                    primaryExpression_AST = (AST) currentAST.root;
0543:                    break;
0544:                }
0545:                case LITERAL_false: {
0546:                    AST tmp18_AST = null;
0547:                    tmp18_AST = astFactory.create(LT(1));
0548:                    astFactory.addASTChild(currentAST, tmp18_AST);
0549:                    match(LITERAL_false);
0550:                    primaryExpression_AST = (AST) currentAST.root;
0551:                    break;
0552:                }
0553:                case LITERAL_null: {
0554:                    AST tmp19_AST = null;
0555:                    tmp19_AST = astFactory.create(LT(1));
0556:                    astFactory.addASTChild(currentAST, tmp19_AST);
0557:                    match(LITERAL_null);
0558:                    primaryExpression_AST = (AST) currentAST.root;
0559:                    break;
0560:                }
0561:                default: {
0562:                    throw new NoViableAltException(LT(1), getFilename());
0563:                }
0564:                }
0565:                returnAST = primaryExpression_AST;
0566:            }
0567:
0568:            public final void argList() throws RecognitionException,
0569:                    TokenStreamException {
0570:
0571:                returnAST = null;
0572:                ASTPair currentAST = new ASTPair();
0573:                AST argList_AST = null;
0574:
0575:                {
0576:                    switch (LA(1)) {
0577:                    case MINUS:
0578:                    case PLUS:
0579:                    case LNOT:
0580:                    case LPAREN:
0581:                    case IDENT:
0582:                    case LITERAL_true:
0583:                    case LITERAL_false:
0584:                    case LITERAL_null:
0585:                    case NUM_INT:
0586:                    case CHAR_LITERAL:
0587:                    case STRING_LITERAL:
0588:                    case NUM_FLOAT:
0589:                    case NUM_LONG:
0590:                    case NUM_DOUBLE: {
0591:                        expressionList();
0592:                        astFactory.addASTChild(currentAST, returnAST);
0593:                        break;
0594:                    }
0595:                    case RPAREN: {
0596:                        if (inputState.guessing == 0) {
0597:                            argList_AST = (AST) currentAST.root;
0598:                            argList_AST = astFactory.create(ELIST, "ELIST");
0599:                            currentAST.root = argList_AST;
0600:                            currentAST.child = argList_AST != null
0601:                                    && argList_AST.getFirstChild() != null ? argList_AST
0602:                                    .getFirstChild()
0603:                                    : argList_AST;
0604:                            currentAST.advanceChildToEnd();
0605:                        }
0606:                        break;
0607:                    }
0608:                    default: {
0609:                        throw new NoViableAltException(LT(1), getFilename());
0610:                    }
0611:                    }
0612:                }
0613:                argList_AST = (AST) currentAST.root;
0614:                returnAST = argList_AST;
0615:            }
0616:
0617:            /** Match a, a.b.c refs, a.b.c(...) refs, a.b.c[], a.b.c[].class,
0618:             *  and a.b.c.class refs.  Also this(...) and super(...).  Match
0619:             *  this or super.
0620:             */
0621:            public final void identPrimary() throws RecognitionException,
0622:                    TokenStreamException {
0623:
0624:                returnAST = null;
0625:                ASTPair currentAST = new ASTPair();
0626:                AST identPrimary_AST = null;
0627:                Token lp = null;
0628:                AST lp_AST = null;
0629:                Token lbc = null;
0630:                AST lbc_AST = null;
0631:
0632:                AST tmp20_AST = null;
0633:                tmp20_AST = astFactory.create(LT(1));
0634:                astFactory.addASTChild(currentAST, tmp20_AST);
0635:                match(IDENT);
0636:                {
0637:                    _loop14: do {
0638:                        if ((LA(1) == DOT) && (LA(2) == IDENT)
0639:                                && (_tokenSet_1.member(LA(3)))) {
0640:                            AST tmp21_AST = null;
0641:                            tmp21_AST = astFactory.create(LT(1));
0642:                            astFactory.makeASTRoot(currentAST, tmp21_AST);
0643:                            match(DOT);
0644:                            AST tmp22_AST = null;
0645:                            tmp22_AST = astFactory.create(LT(1));
0646:                            astFactory.addASTChild(currentAST, tmp22_AST);
0647:                            match(IDENT);
0648:                        } else {
0649:                            break _loop14;
0650:                        }
0651:
0652:                    } while (true);
0653:                }
0654:                {
0655:                    if ((LA(1) == LPAREN)) {
0656:                        {
0657:                            lp = LT(1);
0658:                            lp_AST = astFactory.create(lp);
0659:                            astFactory.makeASTRoot(currentAST, lp_AST);
0660:                            match(LPAREN);
0661:                            if (inputState.guessing == 0) {
0662:                                lp_AST.setType(METHOD_CALL);
0663:                            }
0664:                            argList();
0665:                            astFactory.addASTChild(currentAST, returnAST);
0666:                            match(RPAREN);
0667:                        }
0668:                    } else if ((LA(1) == LBRACK) && (LA(2) == RBRACK)
0669:                            && (_tokenSet_2.member(LA(3)))) {
0670:                        {
0671:                            int _cnt18 = 0;
0672:                            _loop18: do {
0673:                                if ((LA(1) == LBRACK) && (LA(2) == RBRACK)
0674:                                        && (_tokenSet_2.member(LA(3)))) {
0675:                                    lbc = LT(1);
0676:                                    lbc_AST = astFactory.create(lbc);
0677:                                    astFactory.makeASTRoot(currentAST, lbc_AST);
0678:                                    match(LBRACK);
0679:                                    if (inputState.guessing == 0) {
0680:                                        lbc_AST.setType(ARRAY_DECLARATOR);
0681:                                    }
0682:                                    match(RBRACK);
0683:                                } else {
0684:                                    if (_cnt18 >= 1) {
0685:                                        break _loop18;
0686:                                    } else {
0687:                                        throw new NoViableAltException(LT(1),
0688:                                                getFilename());
0689:                                    }
0690:                                }
0691:
0692:                                _cnt18++;
0693:                            } while (true);
0694:                        }
0695:                    } else if ((_tokenSet_2.member(LA(1)))
0696:                            && (_tokenSet_3.member(LA(2)))
0697:                            && (_tokenSet_3.member(LA(3)))) {
0698:                    } else {
0699:                        throw new NoViableAltException(LT(1), getFilename());
0700:                    }
0701:
0702:                }
0703:                identPrimary_AST = (AST) currentAST.root;
0704:                returnAST = identPrimary_AST;
0705:            }
0706:
0707:            public final void constant() throws RecognitionException,
0708:                    TokenStreamException {
0709:
0710:                returnAST = null;
0711:                ASTPair currentAST = new ASTPair();
0712:                AST constant_AST = null;
0713:
0714:                switch (LA(1)) {
0715:                case NUM_INT: {
0716:                    AST tmp25_AST = null;
0717:                    tmp25_AST = astFactory.create(LT(1));
0718:                    astFactory.addASTChild(currentAST, tmp25_AST);
0719:                    match(NUM_INT);
0720:                    constant_AST = (AST) currentAST.root;
0721:                    break;
0722:                }
0723:                case CHAR_LITERAL: {
0724:                    AST tmp26_AST = null;
0725:                    tmp26_AST = astFactory.create(LT(1));
0726:                    astFactory.addASTChild(currentAST, tmp26_AST);
0727:                    match(CHAR_LITERAL);
0728:                    constant_AST = (AST) currentAST.root;
0729:                    break;
0730:                }
0731:                case STRING_LITERAL: {
0732:                    AST tmp27_AST = null;
0733:                    tmp27_AST = astFactory.create(LT(1));
0734:                    astFactory.addASTChild(currentAST, tmp27_AST);
0735:                    match(STRING_LITERAL);
0736:                    constant_AST = (AST) currentAST.root;
0737:                    break;
0738:                }
0739:                case NUM_FLOAT: {
0740:                    AST tmp28_AST = null;
0741:                    tmp28_AST = astFactory.create(LT(1));
0742:                    astFactory.addASTChild(currentAST, tmp28_AST);
0743:                    match(NUM_FLOAT);
0744:                    constant_AST = (AST) currentAST.root;
0745:                    break;
0746:                }
0747:                case NUM_LONG: {
0748:                    AST tmp29_AST = null;
0749:                    tmp29_AST = astFactory.create(LT(1));
0750:                    astFactory.addASTChild(currentAST, tmp29_AST);
0751:                    match(NUM_LONG);
0752:                    constant_AST = (AST) currentAST.root;
0753:                    break;
0754:                }
0755:                case NUM_DOUBLE: {
0756:                    AST tmp30_AST = null;
0757:                    tmp30_AST = astFactory.create(LT(1));
0758:                    astFactory.addASTChild(currentAST, tmp30_AST);
0759:                    match(NUM_DOUBLE);
0760:                    constant_AST = (AST) currentAST.root;
0761:                    break;
0762:                }
0763:                default: {
0764:                    throw new NoViableAltException(LT(1), getFilename());
0765:                }
0766:                }
0767:                returnAST = constant_AST;
0768:            }
0769:
0770:            public final void expressionList() throws RecognitionException,
0771:                    TokenStreamException {
0772:
0773:                returnAST = null;
0774:                ASTPair currentAST = new ASTPair();
0775:                AST expressionList_AST = null;
0776:
0777:                unaryExpression();
0778:                astFactory.addASTChild(currentAST, returnAST);
0779:                {
0780:                    _loop23: do {
0781:                        if ((LA(1) == COMMA)) {
0782:                            match(COMMA);
0783:                            unaryExpression();
0784:                            astFactory.addASTChild(currentAST, returnAST);
0785:                        } else {
0786:                            break _loop23;
0787:                        }
0788:
0789:                    } while (true);
0790:                }
0791:                if (inputState.guessing == 0) {
0792:                    expressionList_AST = (AST) currentAST.root;
0793:                    expressionList_AST = (AST) astFactory
0794:                            .make((new ASTArray(2)).add(
0795:                                    astFactory.create(ELIST, "ELIST")).add(
0796:                                    expressionList_AST));
0797:                    currentAST.root = expressionList_AST;
0798:                    currentAST.child = expressionList_AST != null
0799:                            && expressionList_AST.getFirstChild() != null ? expressionList_AST
0800:                            .getFirstChild()
0801:                            : expressionList_AST;
0802:                    currentAST.advanceChildToEnd();
0803:                }
0804:                expressionList_AST = (AST) currentAST.root;
0805:                returnAST = expressionList_AST;
0806:            }
0807:
0808:            public final void typeSpecification(boolean addImagNode)
0809:                    throws RecognitionException, TokenStreamException {
0810:
0811:                returnAST = null;
0812:                ASTPair currentAST = new ASTPair();
0813:                AST typeSpecification_AST = null;
0814:
0815:                if ((LA(1) == LPAREN) && (LA(2) == IDENT)) {
0816:                    classTypeSpecification(addImagNode);
0817:                    astFactory.addASTChild(currentAST, returnAST);
0818:                    typeSpecification_AST = (AST) currentAST.root;
0819:                } else if ((LA(1) == LPAREN)
0820:                        && ((LA(2) >= LITERAL_boolean && LA(2) <= LITERAL_double))) {
0821:                    builtInTypeSpecification(addImagNode);
0822:                    astFactory.addASTChild(currentAST, returnAST);
0823:                    typeSpecification_AST = (AST) currentAST.root;
0824:                } else {
0825:                    throw new NoViableAltException(LT(1), getFilename());
0826:                }
0827:
0828:                returnAST = typeSpecification_AST;
0829:            }
0830:
0831:            public final void identifier() throws RecognitionException,
0832:                    TokenStreamException {
0833:
0834:                returnAST = null;
0835:                ASTPair currentAST = new ASTPair();
0836:                AST identifier_AST = null;
0837:
0838:                AST tmp32_AST = null;
0839:                tmp32_AST = astFactory.create(LT(1));
0840:                astFactory.addASTChild(currentAST, tmp32_AST);
0841:                match(IDENT);
0842:                {
0843:                    _loop36: do {
0844:                        if ((LA(1) == DOT)) {
0845:                            AST tmp33_AST = null;
0846:                            tmp33_AST = astFactory.create(LT(1));
0847:                            astFactory.makeASTRoot(currentAST, tmp33_AST);
0848:                            match(DOT);
0849:                            AST tmp34_AST = null;
0850:                            tmp34_AST = astFactory.create(LT(1));
0851:                            astFactory.addASTChild(currentAST, tmp34_AST);
0852:                            match(IDENT);
0853:                        } else {
0854:                            break _loop36;
0855:                        }
0856:
0857:                    } while (true);
0858:                }
0859:                identifier_AST = (AST) currentAST.root;
0860:                returnAST = identifier_AST;
0861:            }
0862:
0863:            public final void builtInType() throws RecognitionException,
0864:                    TokenStreamException {
0865:
0866:                returnAST = null;
0867:                ASTPair currentAST = new ASTPair();
0868:                AST builtInType_AST = null;
0869:
0870:                switch (LA(1)) {
0871:                case LITERAL_boolean: {
0872:                    AST tmp35_AST = null;
0873:                    tmp35_AST = astFactory.create(LT(1));
0874:                    astFactory.addASTChild(currentAST, tmp35_AST);
0875:                    match(LITERAL_boolean);
0876:                    builtInType_AST = (AST) currentAST.root;
0877:                    break;
0878:                }
0879:                case LITERAL_byte: {
0880:                    AST tmp36_AST = null;
0881:                    tmp36_AST = astFactory.create(LT(1));
0882:                    astFactory.addASTChild(currentAST, tmp36_AST);
0883:                    match(LITERAL_byte);
0884:                    builtInType_AST = (AST) currentAST.root;
0885:                    break;
0886:                }
0887:                case LITERAL_char: {
0888:                    AST tmp37_AST = null;
0889:                    tmp37_AST = astFactory.create(LT(1));
0890:                    astFactory.addASTChild(currentAST, tmp37_AST);
0891:                    match(LITERAL_char);
0892:                    builtInType_AST = (AST) currentAST.root;
0893:                    break;
0894:                }
0895:                case LITERAL_short: {
0896:                    AST tmp38_AST = null;
0897:                    tmp38_AST = astFactory.create(LT(1));
0898:                    astFactory.addASTChild(currentAST, tmp38_AST);
0899:                    match(LITERAL_short);
0900:                    builtInType_AST = (AST) currentAST.root;
0901:                    break;
0902:                }
0903:                case LITERAL_int: {
0904:                    AST tmp39_AST = null;
0905:                    tmp39_AST = astFactory.create(LT(1));
0906:                    astFactory.addASTChild(currentAST, tmp39_AST);
0907:                    match(LITERAL_int);
0908:                    builtInType_AST = (AST) currentAST.root;
0909:                    break;
0910:                }
0911:                case LITERAL_float: {
0912:                    AST tmp40_AST = null;
0913:                    tmp40_AST = astFactory.create(LT(1));
0914:                    astFactory.addASTChild(currentAST, tmp40_AST);
0915:                    match(LITERAL_float);
0916:                    builtInType_AST = (AST) currentAST.root;
0917:                    break;
0918:                }
0919:                case LITERAL_long: {
0920:                    AST tmp41_AST = null;
0921:                    tmp41_AST = astFactory.create(LT(1));
0922:                    astFactory.addASTChild(currentAST, tmp41_AST);
0923:                    match(LITERAL_long);
0924:                    builtInType_AST = (AST) currentAST.root;
0925:                    break;
0926:                }
0927:                case LITERAL_double: {
0928:                    AST tmp42_AST = null;
0929:                    tmp42_AST = astFactory.create(LT(1));
0930:                    astFactory.addASTChild(currentAST, tmp42_AST);
0931:                    match(LITERAL_double);
0932:                    builtInType_AST = (AST) currentAST.root;
0933:                    break;
0934:                }
0935:                default: {
0936:                    throw new NoViableAltException(LT(1), getFilename());
0937:                }
0938:                }
0939:                returnAST = builtInType_AST;
0940:            }
0941:
0942:            public final void type() throws RecognitionException,
0943:                    TokenStreamException {
0944:
0945:                returnAST = null;
0946:                ASTPair currentAST = new ASTPair();
0947:                AST type_AST = null;
0948:
0949:                switch (LA(1)) {
0950:                case IDENT: {
0951:                    identifier();
0952:                    astFactory.addASTChild(currentAST, returnAST);
0953:                    type_AST = (AST) currentAST.root;
0954:                    break;
0955:                }
0956:                case LITERAL_boolean:
0957:                case LITERAL_byte:
0958:                case LITERAL_char:
0959:                case LITERAL_short:
0960:                case LITERAL_int:
0961:                case LITERAL_float:
0962:                case LITERAL_long:
0963:                case LITERAL_double: {
0964:                    builtInType();
0965:                    astFactory.addASTChild(currentAST, returnAST);
0966:                    type_AST = (AST) currentAST.root;
0967:                    break;
0968:                }
0969:                default: {
0970:                    throw new NoViableAltException(LT(1), getFilename());
0971:                }
0972:                }
0973:                returnAST = type_AST;
0974:            }
0975:
0976:            public final void declaratorBrackets(AST typ)
0977:                    throws RecognitionException, TokenStreamException {
0978:
0979:                returnAST = null;
0980:                ASTPair currentAST = new ASTPair();
0981:                AST declaratorBrackets_AST = null;
0982:                Token lb = null;
0983:                AST lb_AST = null;
0984:
0985:                if (inputState.guessing == 0) {
0986:                    declaratorBrackets_AST = (AST) currentAST.root;
0987:                    declaratorBrackets_AST = typ;
0988:                    currentAST.root = declaratorBrackets_AST;
0989:                    currentAST.child = declaratorBrackets_AST != null
0990:                            && declaratorBrackets_AST.getFirstChild() != null ? declaratorBrackets_AST
0991:                            .getFirstChild()
0992:                            : declaratorBrackets_AST;
0993:                    currentAST.advanceChildToEnd();
0994:                }
0995:                {
0996:                    _loop39: do {
0997:                        if ((LA(1) == LBRACK)) {
0998:                            lb = LT(1);
0999:                            lb_AST = astFactory.create(lb);
1000:                            astFactory.makeASTRoot(currentAST, lb_AST);
1001:                            match(LBRACK);
1002:                            if (inputState.guessing == 0) {
1003:                                lb_AST.setType(ARRAY_DECLARATOR);
1004:                            }
1005:                            match(RBRACK);
1006:                        } else {
1007:                            break _loop39;
1008:                        }
1009:
1010:                    } while (true);
1011:                }
1012:                declaratorBrackets_AST = (AST) currentAST.root;
1013:                returnAST = declaratorBrackets_AST;
1014:            }
1015:
1016:            public static final String[] _tokenNames = { "<0>", "EOF", "<2>",
1017:                    "NULL_TREE_LOOKAHEAD", "PARAMETERS", "PARAMETER_DEF",
1018:                    "TYPE", "ARRAY_DECLARATOR", "TYPECAST", "METHOD_CALL",
1019:                    "INDEX_OP", "ELIST", "MINUS", "PLUS", "LNOT", "LPAREN",
1020:                    "RPAREN", "DOT", "IDENT", "LBRACK", "RBRACK", "\"true\"",
1021:                    "\"false\"", "\"null\"", "COMMA", "NUM_INT",
1022:                    "CHAR_LITERAL", "STRING_LITERAL", "NUM_FLOAT", "NUM_LONG",
1023:                    "NUM_DOUBLE", "\"boolean\"", "\"byte\"", "\"char\"",
1024:                    "\"short\"", "\"int\"", "\"float\"", "\"long\"",
1025:                    "\"double\"", "COLON", "WS", "ESC", "HEX_DIGIT", "VOCAB",
1026:                    "EXPONENT", "FLOAT_SUFFIX" };
1027:
1028:            protected void buildTokenTypeASTClassMap() {
1029:                tokenTypeToASTClassMap = null;
1030:            };
1031:
1032:            private static final long[] mk_tokenSet_0() {
1033:                long[] data = { 2128871424L, 0L };
1034:                return data;
1035:            }
1036:
1037:            public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
1038:
1039:            private static final long[] mk_tokenSet_1() {
1040:                long[] data = { 18579458L, 0L };
1041:                return data;
1042:            }
1043:
1044:            public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
1045:
1046:            private static final long[] mk_tokenSet_2() {
1047:                long[] data = { 18546690L, 0L };
1048:                return data;
1049:            }
1050:
1051:            public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
1052:
1053:            private static final long[] mk_tokenSet_3() {
1054:                long[] data = { 2147479554L, 0L };
1055:                return data;
1056:            }
1057:
1058:            public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
1059:
1060:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.