Source Code Cross Referenced for ANTLRTreePrinter.java in  » Parser » antlr-3.0.1 » org » antlr » tool » 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 » Parser » antlr 3.0.1 » org.antlr.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // $ANTLR 2.7.7 (2006-01-29): "antlr.print.g" -> "ANTLRTreePrinter.java"$
0002:
0003:        /*
0004:         [The "BSD licence"]
0005:         Copyright (c) 2005-2006 Terence Parr
0006:         All rights reserved.
0007:
0008:         Redistribution and use in source and binary forms, with or without
0009:         modification, are permitted provided that the following conditions
0010:         are met:
0011:         1. Redistributions of source code must retain the above copyright
0012:         notice, this list of conditions and the following disclaimer.
0013:         2. Redistributions in binary form must reproduce the above copyright
0014:         notice, this list of conditions and the following disclaimer in the
0015:         documentation and/or other materials provided with the distribution.
0016:         3. The name of the author may not be used to endorse or promote products
0017:         derived from this software without specific prior written permission.
0018:
0019:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0020:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0021:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0022:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0023:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0024:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0025:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0026:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0027:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0028:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0029:         */
0030:        package org.antlr.tool;
0031:
0032:        import java.util.*;
0033:
0034:        import antlr.TreeParser;
0035:        import antlr.Token;
0036:        import antlr.collections.AST;
0037:        import antlr.RecognitionException;
0038:        import antlr.ANTLRException;
0039:        import antlr.NoViableAltException;
0040:        import antlr.MismatchedTokenException;
0041:        import antlr.SemanticException;
0042:        import antlr.collections.impl.BitSet;
0043:        import antlr.ASTPair;
0044:        import antlr.collections.impl.ASTArray;
0045:
0046:        /** Print out a grammar (no pretty printing).
0047:         *
0048:         *  Terence Parr
0049:         *  University of San Francisco
0050:         *  August 19, 2003
0051:         */
0052:        public class ANTLRTreePrinter extends antlr.TreeParser implements 
0053:                ANTLRTreePrinterTokenTypes {
0054:
0055:            protected Grammar grammar;
0056:            protected boolean showActions;
0057:            protected StringBuffer buf = new StringBuffer(300);
0058:
0059:            public void out(String s) {
0060:                buf.append(s);
0061:            }
0062:
0063:            public void reportError(RecognitionException ex) {
0064:                Token token = null;
0065:                if (ex instanceof  MismatchedTokenException) {
0066:                    token = ((MismatchedTokenException) ex).token;
0067:                } else if (ex instanceof  NoViableAltException) {
0068:                    token = ((NoViableAltException) ex).token;
0069:                }
0070:                ErrorManager.syntaxError(ErrorManager.MSG_SYNTAX_ERROR,
0071:                        grammar, token, "antlr.print: " + ex.toString(), ex);
0072:            }
0073:
0074:            /** Normalize a grammar print out by removing all double spaces
0075:             *  and trailing/beginning stuff.  FOr example, convert
0076:             *
0077:             *  ( A  |  B  |  C )*
0078:             *
0079:             *  to
0080:             *
0081:             *  ( A | B | C )*
0082:             */
0083:            public static String normalize(String g) {
0084:                StringTokenizer st = new StringTokenizer(g, " ", false);
0085:                StringBuffer buf = new StringBuffer();
0086:                while (st.hasMoreTokens()) {
0087:                    String w = st.nextToken();
0088:                    buf.append(w);
0089:                    buf.append(" ");
0090:                }
0091:                return buf.toString().trim();
0092:            }
0093:
0094:            public ANTLRTreePrinter() {
0095:                tokenNames = _tokenNames;
0096:            }
0097:
0098:            /** Call this to figure out how to print */
0099:            public final String toString(AST _t, Grammar g, boolean showActions)
0100:                    throws RecognitionException {
0101:                String s = null;
0102:
0103:                GrammarAST toString_AST_in = (_t == ASTNULL) ? null
0104:                        : (GrammarAST) _t;
0105:
0106:                grammar = g;
0107:                this .showActions = showActions;
0108:
0109:                try { // for error handling
0110:                    {
0111:                        if (_t == null)
0112:                            _t = ASTNULL;
0113:                        switch (_t.getType()) {
0114:                        case LEXER_GRAMMAR:
0115:                        case PARSER_GRAMMAR:
0116:                        case TREE_GRAMMAR:
0117:                        case COMBINED_GRAMMAR: {
0118:                            grammar(_t);
0119:                            _t = _retTree;
0120:                            break;
0121:                        }
0122:                        case RULE: {
0123:                            rule(_t);
0124:                            _t = _retTree;
0125:                            break;
0126:                        }
0127:                        case ALT: {
0128:                            alternative(_t);
0129:                            _t = _retTree;
0130:                            break;
0131:                        }
0132:                        case BLOCK:
0133:                        case OPTIONAL:
0134:                        case CLOSURE:
0135:                        case POSITIVE_CLOSURE:
0136:                        case SYNPRED:
0137:                        case RANGE:
0138:                        case CHAR_RANGE:
0139:                        case EPSILON:
0140:                        case LABEL:
0141:                        case GATED_SEMPRED:
0142:                        case SYN_SEMPRED:
0143:                        case BACKTRACK_SEMPRED:
0144:                        case ACTION:
0145:                        case ASSIGN:
0146:                        case STRING_LITERAL:
0147:                        case CHAR_LITERAL:
0148:                        case TOKEN_REF:
0149:                        case BANG:
0150:                        case PLUS_ASSIGN:
0151:                        case SEMPRED:
0152:                        case ROOT:
0153:                        case RULE_REF:
0154:                        case NOT:
0155:                        case TREE_BEGIN:
0156:                        case WILDCARD: {
0157:                            element(_t);
0158:                            _t = _retTree;
0159:                            break;
0160:                        }
0161:                        case REWRITE: {
0162:                            single_rewrite(_t);
0163:                            _t = _retTree;
0164:                            break;
0165:                        }
0166:                        case EOR: {
0167:                            GrammarAST tmp1_AST_in = (GrammarAST) _t;
0168:                            match(_t, EOR);
0169:                            _t = _t.getNextSibling();
0170:                            s = "EOR";
0171:                            break;
0172:                        }
0173:                        default: {
0174:                            throw new NoViableAltException(_t);
0175:                        }
0176:                        }
0177:                    }
0178:                    return normalize(buf.toString());
0179:                } catch (RecognitionException ex) {
0180:                    reportError(ex);
0181:                    if (_t != null) {
0182:                        _t = _t.getNextSibling();
0183:                    }
0184:                }
0185:                _retTree = _t;
0186:                return s;
0187:            }
0188:
0189:            public final void grammar(AST _t) throws RecognitionException {
0190:
0191:                GrammarAST grammar_AST_in = (_t == ASTNULL) ? null
0192:                        : (GrammarAST) _t;
0193:
0194:                try { // for error handling
0195:                    {
0196:                        if (_t == null)
0197:                            _t = ASTNULL;
0198:                        switch (_t.getType()) {
0199:                        case LEXER_GRAMMAR: {
0200:                            AST __t5 = _t;
0201:                            GrammarAST tmp2_AST_in = (GrammarAST) _t;
0202:                            match(_t, LEXER_GRAMMAR);
0203:                            _t = _t.getFirstChild();
0204:                            grammarSpec(_t, "lexer ");
0205:                            _t = _retTree;
0206:                            _t = __t5;
0207:                            _t = _t.getNextSibling();
0208:                            break;
0209:                        }
0210:                        case PARSER_GRAMMAR: {
0211:                            AST __t6 = _t;
0212:                            GrammarAST tmp3_AST_in = (GrammarAST) _t;
0213:                            match(_t, PARSER_GRAMMAR);
0214:                            _t = _t.getFirstChild();
0215:                            grammarSpec(_t, "parser ");
0216:                            _t = _retTree;
0217:                            _t = __t6;
0218:                            _t = _t.getNextSibling();
0219:                            break;
0220:                        }
0221:                        case TREE_GRAMMAR: {
0222:                            AST __t7 = _t;
0223:                            GrammarAST tmp4_AST_in = (GrammarAST) _t;
0224:                            match(_t, TREE_GRAMMAR);
0225:                            _t = _t.getFirstChild();
0226:                            grammarSpec(_t, "tree ");
0227:                            _t = _retTree;
0228:                            _t = __t7;
0229:                            _t = _t.getNextSibling();
0230:                            break;
0231:                        }
0232:                        case COMBINED_GRAMMAR: {
0233:                            AST __t8 = _t;
0234:                            GrammarAST tmp5_AST_in = (GrammarAST) _t;
0235:                            match(_t, COMBINED_GRAMMAR);
0236:                            _t = _t.getFirstChild();
0237:                            grammarSpec(_t, "");
0238:                            _t = _retTree;
0239:                            _t = __t8;
0240:                            _t = _t.getNextSibling();
0241:                            break;
0242:                        }
0243:                        default: {
0244:                            throw new NoViableAltException(_t);
0245:                        }
0246:                        }
0247:                    }
0248:                } catch (RecognitionException ex) {
0249:                    reportError(ex);
0250:                    if (_t != null) {
0251:                        _t = _t.getNextSibling();
0252:                    }
0253:                }
0254:                _retTree = _t;
0255:            }
0256:
0257:            public final void rule(AST _t) throws RecognitionException {
0258:
0259:                GrammarAST rule_AST_in = (_t == ASTNULL) ? null
0260:                        : (GrammarAST) _t;
0261:                GrammarAST id = null;
0262:                GrammarAST arg = null;
0263:                GrammarAST ret = null;
0264:                GrammarAST b = null;
0265:
0266:                try { // for error handling
0267:                    AST __t42 = _t;
0268:                    GrammarAST tmp6_AST_in = (GrammarAST) _t;
0269:                    match(_t, RULE);
0270:                    _t = _t.getFirstChild();
0271:                    id = (GrammarAST) _t;
0272:                    match(_t, ID);
0273:                    _t = _t.getNextSibling();
0274:                    {
0275:                        if (_t == null)
0276:                            _t = ASTNULL;
0277:                        switch (_t.getType()) {
0278:                        case FRAGMENT:
0279:                        case LITERAL_protected:
0280:                        case LITERAL_public:
0281:                        case LITERAL_private: {
0282:                            modifier(_t);
0283:                            _t = _retTree;
0284:                            break;
0285:                        }
0286:                        case ARG: {
0287:                            break;
0288:                        }
0289:                        default: {
0290:                            throw new NoViableAltException(_t);
0291:                        }
0292:                        }
0293:                    }
0294:                    out(id.getText());
0295:                    AST __t44 = _t;
0296:                    GrammarAST tmp7_AST_in = (GrammarAST) _t;
0297:                    match(_t, ARG);
0298:                    _t = _t.getFirstChild();
0299:                    {
0300:                        if (_t == null)
0301:                            _t = ASTNULL;
0302:                        switch (_t.getType()) {
0303:                        case ARG_ACTION: {
0304:                            arg = (GrammarAST) _t;
0305:                            match(_t, ARG_ACTION);
0306:                            _t = _t.getNextSibling();
0307:                            out("[" + arg.getText() + "]");
0308:                            break;
0309:                        }
0310:                        case 3: {
0311:                            break;
0312:                        }
0313:                        default: {
0314:                            throw new NoViableAltException(_t);
0315:                        }
0316:                        }
0317:                    }
0318:                    _t = __t44;
0319:                    _t = _t.getNextSibling();
0320:                    AST __t46 = _t;
0321:                    GrammarAST tmp8_AST_in = (GrammarAST) _t;
0322:                    match(_t, RET);
0323:                    _t = _t.getFirstChild();
0324:                    {
0325:                        if (_t == null)
0326:                            _t = ASTNULL;
0327:                        switch (_t.getType()) {
0328:                        case ARG_ACTION: {
0329:                            ret = (GrammarAST) _t;
0330:                            match(_t, ARG_ACTION);
0331:                            _t = _t.getNextSibling();
0332:                            out(" returns [" + ret.getText() + "]");
0333:                            break;
0334:                        }
0335:                        case 3: {
0336:                            break;
0337:                        }
0338:                        default: {
0339:                            throw new NoViableAltException(_t);
0340:                        }
0341:                        }
0342:                    }
0343:                    _t = __t46;
0344:                    _t = _t.getNextSibling();
0345:                    {
0346:                        if (_t == null)
0347:                            _t = ASTNULL;
0348:                        switch (_t.getType()) {
0349:                        case OPTIONS: {
0350:                            optionsSpec(_t);
0351:                            _t = _retTree;
0352:                            break;
0353:                        }
0354:                        case BLOCK:
0355:                        case SCOPE:
0356:                        case AMPERSAND: {
0357:                            break;
0358:                        }
0359:                        default: {
0360:                            throw new NoViableAltException(_t);
0361:                        }
0362:                        }
0363:                    }
0364:                    {
0365:                        if (_t == null)
0366:                            _t = ASTNULL;
0367:                        switch (_t.getType()) {
0368:                        case SCOPE: {
0369:                            ruleScopeSpec(_t);
0370:                            _t = _retTree;
0371:                            break;
0372:                        }
0373:                        case BLOCK:
0374:                        case AMPERSAND: {
0375:                            break;
0376:                        }
0377:                        default: {
0378:                            throw new NoViableAltException(_t);
0379:                        }
0380:                        }
0381:                    }
0382:                    {
0383:                        _loop51: do {
0384:                            if (_t == null)
0385:                                _t = ASTNULL;
0386:                            if ((_t.getType() == AMPERSAND)) {
0387:                                ruleAction(_t);
0388:                                _t = _retTree;
0389:                            } else {
0390:                                break _loop51;
0391:                            }
0392:
0393:                        } while (true);
0394:                    }
0395:                    out(" : ");
0396:                    b = _t == ASTNULL ? null : (GrammarAST) _t;
0397:                    block(_t, false);
0398:                    _t = _retTree;
0399:                    {
0400:                        if (_t == null)
0401:                            _t = ASTNULL;
0402:                        switch (_t.getType()) {
0403:                        case LITERAL_catch:
0404:                        case LITERAL_finally: {
0405:                            exceptionGroup(_t);
0406:                            _t = _retTree;
0407:                            break;
0408:                        }
0409:                        case EOR: {
0410:                            break;
0411:                        }
0412:                        default: {
0413:                            throw new NoViableAltException(_t);
0414:                        }
0415:                        }
0416:                    }
0417:                    GrammarAST tmp9_AST_in = (GrammarAST) _t;
0418:                    match(_t, EOR);
0419:                    _t = _t.getNextSibling();
0420:                    out(";\n");
0421:                    _t = __t42;
0422:                    _t = _t.getNextSibling();
0423:                } catch (RecognitionException ex) {
0424:                    reportError(ex);
0425:                    if (_t != null) {
0426:                        _t = _t.getNextSibling();
0427:                    }
0428:                }
0429:                _retTree = _t;
0430:            }
0431:
0432:            public final void alternative(AST _t) throws RecognitionException {
0433:
0434:                GrammarAST alternative_AST_in = (_t == ASTNULL) ? null
0435:                        : (GrammarAST) _t;
0436:
0437:                try { // for error handling
0438:                    AST __t74 = _t;
0439:                    GrammarAST tmp10_AST_in = (GrammarAST) _t;
0440:                    match(_t, ALT);
0441:                    _t = _t.getFirstChild();
0442:                    {
0443:                        int _cnt76 = 0;
0444:                        _loop76: do {
0445:                            if (_t == null)
0446:                                _t = ASTNULL;
0447:                            if ((_t.getType() == BLOCK
0448:                                    || _t.getType() == OPTIONAL
0449:                                    || _t.getType() == CLOSURE
0450:                                    || _t.getType() == POSITIVE_CLOSURE
0451:                                    || _t.getType() == SYNPRED
0452:                                    || _t.getType() == RANGE
0453:                                    || _t.getType() == CHAR_RANGE
0454:                                    || _t.getType() == EPSILON
0455:                                    || _t.getType() == LABEL
0456:                                    || _t.getType() == GATED_SEMPRED
0457:                                    || _t.getType() == SYN_SEMPRED
0458:                                    || _t.getType() == BACKTRACK_SEMPRED
0459:                                    || _t.getType() == ACTION
0460:                                    || _t.getType() == ASSIGN
0461:                                    || _t.getType() == STRING_LITERAL
0462:                                    || _t.getType() == CHAR_LITERAL
0463:                                    || _t.getType() == TOKEN_REF
0464:                                    || _t.getType() == BANG
0465:                                    || _t.getType() == PLUS_ASSIGN
0466:                                    || _t.getType() == SEMPRED
0467:                                    || _t.getType() == ROOT
0468:                                    || _t.getType() == RULE_REF
0469:                                    || _t.getType() == NOT
0470:                                    || _t.getType() == TREE_BEGIN || _t
0471:                                    .getType() == WILDCARD)) {
0472:                                element(_t);
0473:                                _t = _retTree;
0474:                            } else {
0475:                                if (_cnt76 >= 1) {
0476:                                    break _loop76;
0477:                                } else {
0478:                                    throw new NoViableAltException(_t);
0479:                                }
0480:                            }
0481:
0482:                            _cnt76++;
0483:                        } while (true);
0484:                    }
0485:                    GrammarAST tmp11_AST_in = (GrammarAST) _t;
0486:                    match(_t, EOA);
0487:                    _t = _t.getNextSibling();
0488:                    _t = __t74;
0489:                    _t = _t.getNextSibling();
0490:                } catch (RecognitionException ex) {
0491:                    reportError(ex);
0492:                    if (_t != null) {
0493:                        _t = _t.getNextSibling();
0494:                    }
0495:                }
0496:                _retTree = _t;
0497:            }
0498:
0499:            public final void element(AST _t) throws RecognitionException {
0500:
0501:                GrammarAST element_AST_in = (_t == ASTNULL) ? null
0502:                        : (GrammarAST) _t;
0503:                GrammarAST id = null;
0504:                GrammarAST id2 = null;
0505:                GrammarAST a = null;
0506:                GrammarAST pred = null;
0507:                GrammarAST spred = null;
0508:                GrammarAST gpred = null;
0509:
0510:                try { // for error handling
0511:                    if (_t == null)
0512:                        _t = ASTNULL;
0513:                    switch (_t.getType()) {
0514:                    case ROOT: {
0515:                        AST __t101 = _t;
0516:                        GrammarAST tmp12_AST_in = (GrammarAST) _t;
0517:                        match(_t, ROOT);
0518:                        _t = _t.getFirstChild();
0519:                        element(_t);
0520:                        _t = _retTree;
0521:                        _t = __t101;
0522:                        _t = _t.getNextSibling();
0523:                        break;
0524:                    }
0525:                    case BANG: {
0526:                        AST __t102 = _t;
0527:                        GrammarAST tmp13_AST_in = (GrammarAST) _t;
0528:                        match(_t, BANG);
0529:                        _t = _t.getFirstChild();
0530:                        element(_t);
0531:                        _t = _retTree;
0532:                        _t = __t102;
0533:                        _t = _t.getNextSibling();
0534:                        break;
0535:                    }
0536:                    case LABEL:
0537:                    case STRING_LITERAL:
0538:                    case CHAR_LITERAL:
0539:                    case TOKEN_REF:
0540:                    case RULE_REF:
0541:                    case WILDCARD: {
0542:                        atom(_t);
0543:                        _t = _retTree;
0544:                        break;
0545:                    }
0546:                    case NOT: {
0547:                        AST __t103 = _t;
0548:                        GrammarAST tmp14_AST_in = (GrammarAST) _t;
0549:                        match(_t, NOT);
0550:                        _t = _t.getFirstChild();
0551:                        out("~");
0552:                        element(_t);
0553:                        _t = _retTree;
0554:                        _t = __t103;
0555:                        _t = _t.getNextSibling();
0556:                        break;
0557:                    }
0558:                    case RANGE: {
0559:                        AST __t104 = _t;
0560:                        GrammarAST tmp15_AST_in = (GrammarAST) _t;
0561:                        match(_t, RANGE);
0562:                        _t = _t.getFirstChild();
0563:                        atom(_t);
0564:                        _t = _retTree;
0565:                        out("..");
0566:                        atom(_t);
0567:                        _t = _retTree;
0568:                        _t = __t104;
0569:                        _t = _t.getNextSibling();
0570:                        break;
0571:                    }
0572:                    case CHAR_RANGE: {
0573:                        AST __t105 = _t;
0574:                        GrammarAST tmp16_AST_in = (GrammarAST) _t;
0575:                        match(_t, CHAR_RANGE);
0576:                        _t = _t.getFirstChild();
0577:                        atom(_t);
0578:                        _t = _retTree;
0579:                        out("..");
0580:                        atom(_t);
0581:                        _t = _retTree;
0582:                        _t = __t105;
0583:                        _t = _t.getNextSibling();
0584:                        break;
0585:                    }
0586:                    case ASSIGN: {
0587:                        AST __t106 = _t;
0588:                        GrammarAST tmp17_AST_in = (GrammarAST) _t;
0589:                        match(_t, ASSIGN);
0590:                        _t = _t.getFirstChild();
0591:                        id = (GrammarAST) _t;
0592:                        match(_t, ID);
0593:                        _t = _t.getNextSibling();
0594:                        out(id.getText() + "=");
0595:                        element(_t);
0596:                        _t = _retTree;
0597:                        _t = __t106;
0598:                        _t = _t.getNextSibling();
0599:                        break;
0600:                    }
0601:                    case PLUS_ASSIGN: {
0602:                        AST __t107 = _t;
0603:                        GrammarAST tmp18_AST_in = (GrammarAST) _t;
0604:                        match(_t, PLUS_ASSIGN);
0605:                        _t = _t.getFirstChild();
0606:                        id2 = (GrammarAST) _t;
0607:                        match(_t, ID);
0608:                        _t = _t.getNextSibling();
0609:                        out(id2.getText() + "+=");
0610:                        element(_t);
0611:                        _t = _retTree;
0612:                        _t = __t107;
0613:                        _t = _t.getNextSibling();
0614:                        break;
0615:                    }
0616:                    case BLOCK:
0617:                    case OPTIONAL:
0618:                    case CLOSURE:
0619:                    case POSITIVE_CLOSURE: {
0620:                        ebnf(_t);
0621:                        _t = _retTree;
0622:                        break;
0623:                    }
0624:                    case TREE_BEGIN: {
0625:                        tree(_t);
0626:                        _t = _retTree;
0627:                        break;
0628:                    }
0629:                    case SYNPRED: {
0630:                        AST __t108 = _t;
0631:                        GrammarAST tmp19_AST_in = (GrammarAST) _t;
0632:                        match(_t, SYNPRED);
0633:                        _t = _t.getFirstChild();
0634:                        block(_t, true);
0635:                        _t = _retTree;
0636:                        _t = __t108;
0637:                        _t = _t.getNextSibling();
0638:                        out("=>");
0639:                        break;
0640:                    }
0641:                    case ACTION: {
0642:                        a = (GrammarAST) _t;
0643:                        match(_t, ACTION);
0644:                        _t = _t.getNextSibling();
0645:                        if (showActions) {
0646:                            out("{");
0647:                            out(a.getText());
0648:                            out("}");
0649:                        }
0650:                        break;
0651:                    }
0652:                    case SEMPRED: {
0653:                        pred = (GrammarAST) _t;
0654:                        match(_t, SEMPRED);
0655:                        _t = _t.getNextSibling();
0656:
0657:                        if (showActions) {
0658:                            out("{");
0659:                            out(pred.getText());
0660:                            out("}?");
0661:                        } else {
0662:                            out("{...}?");
0663:                        }
0664:
0665:                        break;
0666:                    }
0667:                    case SYN_SEMPRED: {
0668:                        spred = (GrammarAST) _t;
0669:                        match(_t, SYN_SEMPRED);
0670:                        _t = _t.getNextSibling();
0671:
0672:                        String name = spred.getText();
0673:                        GrammarAST predAST = grammar
0674:                                .getSyntacticPredicate(name);
0675:                        block(predAST, true);
0676:                        out("=>");
0677:
0678:                        break;
0679:                    }
0680:                    case BACKTRACK_SEMPRED: {
0681:                        GrammarAST tmp20_AST_in = (GrammarAST) _t;
0682:                        match(_t, BACKTRACK_SEMPRED);
0683:                        _t = _t.getNextSibling();
0684:                        break;
0685:                    }
0686:                    case GATED_SEMPRED: {
0687:                        gpred = (GrammarAST) _t;
0688:                        match(_t, GATED_SEMPRED);
0689:                        _t = _t.getNextSibling();
0690:
0691:                        if (showActions) {
0692:                            out("{");
0693:                            out(gpred.getText());
0694:                            out("}? =>");
0695:                        } else {
0696:                            out("{...}? =>");
0697:                        }
0698:
0699:                        break;
0700:                    }
0701:                    case EPSILON: {
0702:                        GrammarAST tmp21_AST_in = (GrammarAST) _t;
0703:                        match(_t, EPSILON);
0704:                        _t = _t.getNextSibling();
0705:                        break;
0706:                    }
0707:                    default: {
0708:                        throw new NoViableAltException(_t);
0709:                    }
0710:                    }
0711:                } catch (RecognitionException ex) {
0712:                    reportError(ex);
0713:                    if (_t != null) {
0714:                        _t = _t.getNextSibling();
0715:                    }
0716:                }
0717:                _retTree = _t;
0718:            }
0719:
0720:            public final void single_rewrite(AST _t)
0721:                    throws RecognitionException {
0722:
0723:                GrammarAST single_rewrite_AST_in = (_t == ASTNULL) ? null
0724:                        : (GrammarAST) _t;
0725:
0726:                try { // for error handling
0727:                    AST __t86 = _t;
0728:                    GrammarAST tmp22_AST_in = (GrammarAST) _t;
0729:                    match(_t, REWRITE);
0730:                    _t = _t.getFirstChild();
0731:                    out(" ->");
0732:                    {
0733:                        if (_t == null)
0734:                            _t = ASTNULL;
0735:                        switch (_t.getType()) {
0736:                        case SEMPRED: {
0737:                            GrammarAST tmp23_AST_in = (GrammarAST) _t;
0738:                            match(_t, SEMPRED);
0739:                            _t = _t.getNextSibling();
0740:                            out(" {" + tmp23_AST_in.getText() + "}?");
0741:                            break;
0742:                        }
0743:                        case ALT:
0744:                        case TEMPLATE:
0745:                        case ACTION: {
0746:                            break;
0747:                        }
0748:                        default: {
0749:                            throw new NoViableAltException(_t);
0750:                        }
0751:                        }
0752:                    }
0753:                    {
0754:                        if (_t == null)
0755:                            _t = ASTNULL;
0756:                        switch (_t.getType()) {
0757:                        case ALT: {
0758:                            alternative(_t);
0759:                            _t = _retTree;
0760:                            break;
0761:                        }
0762:                        case TEMPLATE: {
0763:                            rewrite_template(_t);
0764:                            _t = _retTree;
0765:                            break;
0766:                        }
0767:                        case ACTION: {
0768:                            GrammarAST tmp24_AST_in = (GrammarAST) _t;
0769:                            match(_t, ACTION);
0770:                            _t = _t.getNextSibling();
0771:                            out(" {" + tmp24_AST_in.getText() + "}");
0772:                            break;
0773:                        }
0774:                        default: {
0775:                            throw new NoViableAltException(_t);
0776:                        }
0777:                        }
0778:                    }
0779:                    _t = __t86;
0780:                    _t = _t.getNextSibling();
0781:                } catch (RecognitionException ex) {
0782:                    reportError(ex);
0783:                    if (_t != null) {
0784:                        _t = _t.getNextSibling();
0785:                    }
0786:                }
0787:                _retTree = _t;
0788:            }
0789:
0790:            public final void grammarSpec(AST _t, String gtype)
0791:                    throws RecognitionException {
0792:
0793:                GrammarAST grammarSpec_AST_in = (_t == ASTNULL) ? null
0794:                        : (GrammarAST) _t;
0795:                GrammarAST id = null;
0796:                GrammarAST cmt = null;
0797:
0798:                try { // for error handling
0799:                    id = (GrammarAST) _t;
0800:                    match(_t, ID);
0801:                    _t = _t.getNextSibling();
0802:                    out(gtype + "grammar " + id.getText());
0803:                    {
0804:                        if (_t == null)
0805:                            _t = ASTNULL;
0806:                        switch (_t.getType()) {
0807:                        case DOC_COMMENT: {
0808:                            cmt = (GrammarAST) _t;
0809:                            match(_t, DOC_COMMENT);
0810:                            _t = _t.getNextSibling();
0811:                            out(cmt.getText() + "\n");
0812:                            break;
0813:                        }
0814:                        case OPTIONS:
0815:                        case TOKENS:
0816:                        case RULE:
0817:                        case SCOPE:
0818:                        case AMPERSAND: {
0819:                            break;
0820:                        }
0821:                        default: {
0822:                            throw new NoViableAltException(_t);
0823:                        }
0824:                        }
0825:                    }
0826:                    {
0827:                        if (_t == null)
0828:                            _t = ASTNULL;
0829:                        switch (_t.getType()) {
0830:                        case OPTIONS: {
0831:                            optionsSpec(_t);
0832:                            _t = _retTree;
0833:                            break;
0834:                        }
0835:                        case TOKENS:
0836:                        case RULE:
0837:                        case SCOPE:
0838:                        case AMPERSAND: {
0839:                            break;
0840:                        }
0841:                        default: {
0842:                            throw new NoViableAltException(_t);
0843:                        }
0844:                        }
0845:                    }
0846:                    out(";\n");
0847:                    {
0848:                        if (_t == null)
0849:                            _t = ASTNULL;
0850:                        switch (_t.getType()) {
0851:                        case TOKENS: {
0852:                            tokensSpec(_t);
0853:                            _t = _retTree;
0854:                            break;
0855:                        }
0856:                        case RULE:
0857:                        case SCOPE:
0858:                        case AMPERSAND: {
0859:                            break;
0860:                        }
0861:                        default: {
0862:                            throw new NoViableAltException(_t);
0863:                        }
0864:                        }
0865:                    }
0866:                    {
0867:                        _loop16: do {
0868:                            if (_t == null)
0869:                                _t = ASTNULL;
0870:                            if ((_t.getType() == SCOPE)) {
0871:                                attrScope(_t);
0872:                                _t = _retTree;
0873:                            } else {
0874:                                break _loop16;
0875:                            }
0876:
0877:                        } while (true);
0878:                    }
0879:                    {
0880:                        if (_t == null)
0881:                            _t = ASTNULL;
0882:                        switch (_t.getType()) {
0883:                        case AMPERSAND: {
0884:                            actions(_t);
0885:                            _t = _retTree;
0886:                            break;
0887:                        }
0888:                        case RULE: {
0889:                            break;
0890:                        }
0891:                        default: {
0892:                            throw new NoViableAltException(_t);
0893:                        }
0894:                        }
0895:                    }
0896:                    rules(_t);
0897:                    _t = _retTree;
0898:                } catch (RecognitionException ex) {
0899:                    reportError(ex);
0900:                    if (_t != null) {
0901:                        _t = _t.getNextSibling();
0902:                    }
0903:                }
0904:                _retTree = _t;
0905:            }
0906:
0907:            public final void attrScope(AST _t) throws RecognitionException {
0908:
0909:                GrammarAST attrScope_AST_in = (_t == ASTNULL) ? null
0910:                        : (GrammarAST) _t;
0911:
0912:                try { // for error handling
0913:                    AST __t10 = _t;
0914:                    GrammarAST tmp25_AST_in = (GrammarAST) _t;
0915:                    match(_t, SCOPE);
0916:                    _t = _t.getFirstChild();
0917:                    GrammarAST tmp26_AST_in = (GrammarAST) _t;
0918:                    match(_t, ID);
0919:                    _t = _t.getNextSibling();
0920:                    GrammarAST tmp27_AST_in = (GrammarAST) _t;
0921:                    match(_t, ACTION);
0922:                    _t = _t.getNextSibling();
0923:                    _t = __t10;
0924:                    _t = _t.getNextSibling();
0925:                } catch (RecognitionException ex) {
0926:                    reportError(ex);
0927:                    if (_t != null) {
0928:                        _t = _t.getNextSibling();
0929:                    }
0930:                }
0931:                _retTree = _t;
0932:            }
0933:
0934:            public final void optionsSpec(AST _t) throws RecognitionException {
0935:
0936:                GrammarAST optionsSpec_AST_in = (_t == ASTNULL) ? null
0937:                        : (GrammarAST) _t;
0938:
0939:                try { // for error handling
0940:                    AST __t25 = _t;
0941:                    GrammarAST tmp28_AST_in = (GrammarAST) _t;
0942:                    match(_t, OPTIONS);
0943:                    _t = _t.getFirstChild();
0944:                    out(" options {");
0945:                    {
0946:                        int _cnt27 = 0;
0947:                        _loop27: do {
0948:                            if (_t == null)
0949:                                _t = ASTNULL;
0950:                            if ((_t.getType() == ASSIGN)) {
0951:                                option(_t);
0952:                                _t = _retTree;
0953:                                out("; ");
0954:                            } else {
0955:                                if (_cnt27 >= 1) {
0956:                                    break _loop27;
0957:                                } else {
0958:                                    throw new NoViableAltException(_t);
0959:                                }
0960:                            }
0961:
0962:                            _cnt27++;
0963:                        } while (true);
0964:                    }
0965:                    out("} ");
0966:                    _t = __t25;
0967:                    _t = _t.getNextSibling();
0968:                } catch (RecognitionException ex) {
0969:                    reportError(ex);
0970:                    if (_t != null) {
0971:                        _t = _t.getNextSibling();
0972:                    }
0973:                }
0974:                _retTree = _t;
0975:            }
0976:
0977:            public final void tokensSpec(AST _t) throws RecognitionException {
0978:
0979:                GrammarAST tokensSpec_AST_in = (_t == ASTNULL) ? null
0980:                        : (GrammarAST) _t;
0981:
0982:                try { // for error handling
0983:                    AST __t32 = _t;
0984:                    GrammarAST tmp29_AST_in = (GrammarAST) _t;
0985:                    match(_t, TOKENS);
0986:                    _t = _t.getFirstChild();
0987:                    {
0988:                        int _cnt34 = 0;
0989:                        _loop34: do {
0990:                            if (_t == null)
0991:                                _t = ASTNULL;
0992:                            if ((_t.getType() == ASSIGN || _t.getType() == TOKEN_REF)) {
0993:                                tokenSpec(_t);
0994:                                _t = _retTree;
0995:                            } else {
0996:                                if (_cnt34 >= 1) {
0997:                                    break _loop34;
0998:                                } else {
0999:                                    throw new NoViableAltException(_t);
1000:                                }
1001:                            }
1002:
1003:                            _cnt34++;
1004:                        } while (true);
1005:                    }
1006:                    _t = __t32;
1007:                    _t = _t.getNextSibling();
1008:                } catch (RecognitionException ex) {
1009:                    reportError(ex);
1010:                    if (_t != null) {
1011:                        _t = _t.getNextSibling();
1012:                    }
1013:                }
1014:                _retTree = _t;
1015:            }
1016:
1017:            public final void actions(AST _t) throws RecognitionException {
1018:
1019:                GrammarAST actions_AST_in = (_t == ASTNULL) ? null
1020:                        : (GrammarAST) _t;
1021:
1022:                try { // for error handling
1023:                    {
1024:                        int _cnt20 = 0;
1025:                        _loop20: do {
1026:                            if (_t == null)
1027:                                _t = ASTNULL;
1028:                            if ((_t.getType() == AMPERSAND)) {
1029:                                action(_t);
1030:                                _t = _retTree;
1031:                            } else {
1032:                                if (_cnt20 >= 1) {
1033:                                    break _loop20;
1034:                                } else {
1035:                                    throw new NoViableAltException(_t);
1036:                                }
1037:                            }
1038:
1039:                            _cnt20++;
1040:                        } while (true);
1041:                    }
1042:                } catch (RecognitionException ex) {
1043:                    reportError(ex);
1044:                    if (_t != null) {
1045:                        _t = _t.getNextSibling();
1046:                    }
1047:                }
1048:                _retTree = _t;
1049:            }
1050:
1051:            public final void rules(AST _t) throws RecognitionException {
1052:
1053:                GrammarAST rules_AST_in = (_t == ASTNULL) ? null
1054:                        : (GrammarAST) _t;
1055:
1056:                try { // for error handling
1057:                    {
1058:                        int _cnt40 = 0;
1059:                        _loop40: do {
1060:                            if (_t == null)
1061:                                _t = ASTNULL;
1062:                            if ((_t.getType() == RULE)) {
1063:                                rule(_t);
1064:                                _t = _retTree;
1065:                            } else {
1066:                                if (_cnt40 >= 1) {
1067:                                    break _loop40;
1068:                                } else {
1069:                                    throw new NoViableAltException(_t);
1070:                                }
1071:                            }
1072:
1073:                            _cnt40++;
1074:                        } while (true);
1075:                    }
1076:                } catch (RecognitionException ex) {
1077:                    reportError(ex);
1078:                    if (_t != null) {
1079:                        _t = _t.getNextSibling();
1080:                    }
1081:                }
1082:                _retTree = _t;
1083:            }
1084:
1085:            public final void action(AST _t) throws RecognitionException {
1086:
1087:                GrammarAST action_AST_in = (_t == ASTNULL) ? null
1088:                        : (GrammarAST) _t;
1089:                GrammarAST id1 = null;
1090:                GrammarAST id2 = null;
1091:                GrammarAST a1 = null;
1092:                GrammarAST a2 = null;
1093:
1094:                String scope = null, name = null;
1095:                String action = null;
1096:
1097:                try { // for error handling
1098:                    AST __t22 = _t;
1099:                    GrammarAST tmp30_AST_in = (GrammarAST) _t;
1100:                    match(_t, AMPERSAND);
1101:                    _t = _t.getFirstChild();
1102:                    id1 = (GrammarAST) _t;
1103:                    match(_t, ID);
1104:                    _t = _t.getNextSibling();
1105:                    {
1106:                        if (_t == null)
1107:                            _t = ASTNULL;
1108:                        switch (_t.getType()) {
1109:                        case ID: {
1110:                            id2 = (GrammarAST) _t;
1111:                            match(_t, ID);
1112:                            _t = _t.getNextSibling();
1113:                            a1 = (GrammarAST) _t;
1114:                            match(_t, ACTION);
1115:                            _t = _t.getNextSibling();
1116:                            scope = id1.getText();
1117:                            name = a1.getText();
1118:                            action = a1.getText();
1119:                            break;
1120:                        }
1121:                        case ACTION: {
1122:                            a2 = (GrammarAST) _t;
1123:                            match(_t, ACTION);
1124:                            _t = _t.getNextSibling();
1125:                            scope = null;
1126:                            name = id1.getText();
1127:                            action = a2.getText();
1128:                            break;
1129:                        }
1130:                        default: {
1131:                            throw new NoViableAltException(_t);
1132:                        }
1133:                        }
1134:                    }
1135:                    _t = __t22;
1136:                    _t = _t.getNextSibling();
1137:
1138:                    if (showActions) {
1139:                        out("@" + (scope != null ? scope + "::" : "") + name
1140:                                + action);
1141:                    }
1142:
1143:                } catch (RecognitionException ex) {
1144:                    reportError(ex);
1145:                    if (_t != null) {
1146:                        _t = _t.getNextSibling();
1147:                    }
1148:                }
1149:                _retTree = _t;
1150:            }
1151:
1152:            public final void option(AST _t) throws RecognitionException {
1153:
1154:                GrammarAST option_AST_in = (_t == ASTNULL) ? null
1155:                        : (GrammarAST) _t;
1156:                GrammarAST id = null;
1157:
1158:                try { // for error handling
1159:                    AST __t29 = _t;
1160:                    GrammarAST tmp31_AST_in = (GrammarAST) _t;
1161:                    match(_t, ASSIGN);
1162:                    _t = _t.getFirstChild();
1163:                    id = (GrammarAST) _t;
1164:                    match(_t, ID);
1165:                    _t = _t.getNextSibling();
1166:                    out(id.getText() + "=");
1167:                    optionValue(_t);
1168:                    _t = _retTree;
1169:                    _t = __t29;
1170:                    _t = _t.getNextSibling();
1171:                } catch (RecognitionException ex) {
1172:                    reportError(ex);
1173:                    if (_t != null) {
1174:                        _t = _t.getNextSibling();
1175:                    }
1176:                }
1177:                _retTree = _t;
1178:            }
1179:
1180:            public final void optionValue(AST _t) throws RecognitionException {
1181:
1182:                GrammarAST optionValue_AST_in = (_t == ASTNULL) ? null
1183:                        : (GrammarAST) _t;
1184:                GrammarAST id = null;
1185:                GrammarAST s = null;
1186:                GrammarAST c = null;
1187:                GrammarAST i = null;
1188:
1189:                try { // for error handling
1190:                    if (_t == null)
1191:                        _t = ASTNULL;
1192:                    switch (_t.getType()) {
1193:                    case ID: {
1194:                        id = (GrammarAST) _t;
1195:                        match(_t, ID);
1196:                        _t = _t.getNextSibling();
1197:                        out(id.getText());
1198:                        break;
1199:                    }
1200:                    case STRING_LITERAL: {
1201:                        s = (GrammarAST) _t;
1202:                        match(_t, STRING_LITERAL);
1203:                        _t = _t.getNextSibling();
1204:                        out(s.getText());
1205:                        break;
1206:                    }
1207:                    case CHAR_LITERAL: {
1208:                        c = (GrammarAST) _t;
1209:                        match(_t, CHAR_LITERAL);
1210:                        _t = _t.getNextSibling();
1211:                        out(c.getText());
1212:                        break;
1213:                    }
1214:                    case INT: {
1215:                        i = (GrammarAST) _t;
1216:                        match(_t, INT);
1217:                        _t = _t.getNextSibling();
1218:                        out(i.getText());
1219:                        break;
1220:                    }
1221:                    default: {
1222:                        throw new NoViableAltException(_t);
1223:                    }
1224:                    }
1225:                } catch (RecognitionException ex) {
1226:                    reportError(ex);
1227:                    if (_t != null) {
1228:                        _t = _t.getNextSibling();
1229:                    }
1230:                }
1231:                _retTree = _t;
1232:            }
1233:
1234:            public final void tokenSpec(AST _t) throws RecognitionException {
1235:
1236:                GrammarAST tokenSpec_AST_in = (_t == ASTNULL) ? null
1237:                        : (GrammarAST) _t;
1238:
1239:                try { // for error handling
1240:                    if (_t == null)
1241:                        _t = ASTNULL;
1242:                    switch (_t.getType()) {
1243:                    case TOKEN_REF: {
1244:                        GrammarAST tmp32_AST_in = (GrammarAST) _t;
1245:                        match(_t, TOKEN_REF);
1246:                        _t = _t.getNextSibling();
1247:                        break;
1248:                    }
1249:                    case ASSIGN: {
1250:                        AST __t36 = _t;
1251:                        GrammarAST tmp33_AST_in = (GrammarAST) _t;
1252:                        match(_t, ASSIGN);
1253:                        _t = _t.getFirstChild();
1254:                        GrammarAST tmp34_AST_in = (GrammarAST) _t;
1255:                        match(_t, TOKEN_REF);
1256:                        _t = _t.getNextSibling();
1257:                        {
1258:                            if (_t == null)
1259:                                _t = ASTNULL;
1260:                            switch (_t.getType()) {
1261:                            case STRING_LITERAL: {
1262:                                GrammarAST tmp35_AST_in = (GrammarAST) _t;
1263:                                match(_t, STRING_LITERAL);
1264:                                _t = _t.getNextSibling();
1265:                                break;
1266:                            }
1267:                            case CHAR_LITERAL: {
1268:                                GrammarAST tmp36_AST_in = (GrammarAST) _t;
1269:                                match(_t, CHAR_LITERAL);
1270:                                _t = _t.getNextSibling();
1271:                                break;
1272:                            }
1273:                            default: {
1274:                                throw new NoViableAltException(_t);
1275:                            }
1276:                            }
1277:                        }
1278:                        _t = __t36;
1279:                        _t = _t.getNextSibling();
1280:                        break;
1281:                    }
1282:                    default: {
1283:                        throw new NoViableAltException(_t);
1284:                    }
1285:                    }
1286:                } catch (RecognitionException ex) {
1287:                    reportError(ex);
1288:                    if (_t != null) {
1289:                        _t = _t.getNextSibling();
1290:                    }
1291:                }
1292:                _retTree = _t;
1293:            }
1294:
1295:            public final void modifier(AST _t) throws RecognitionException {
1296:
1297:                GrammarAST modifier_AST_in = (_t == ASTNULL) ? null
1298:                        : (GrammarAST) _t;
1299:                out(modifier_AST_in.getText());
1300:                out(" ");
1301:
1302:                try { // for error handling
1303:                    if (_t == null)
1304:                        _t = ASTNULL;
1305:                    switch (_t.getType()) {
1306:                    case LITERAL_protected: {
1307:                        GrammarAST tmp37_AST_in = (GrammarAST) _t;
1308:                        match(_t, LITERAL_protected);
1309:                        _t = _t.getNextSibling();
1310:                        break;
1311:                    }
1312:                    case LITERAL_public: {
1313:                        GrammarAST tmp38_AST_in = (GrammarAST) _t;
1314:                        match(_t, LITERAL_public);
1315:                        _t = _t.getNextSibling();
1316:                        break;
1317:                    }
1318:                    case LITERAL_private: {
1319:                        GrammarAST tmp39_AST_in = (GrammarAST) _t;
1320:                        match(_t, LITERAL_private);
1321:                        _t = _t.getNextSibling();
1322:                        break;
1323:                    }
1324:                    case FRAGMENT: {
1325:                        GrammarAST tmp40_AST_in = (GrammarAST) _t;
1326:                        match(_t, FRAGMENT);
1327:                        _t = _t.getNextSibling();
1328:                        break;
1329:                    }
1330:                    default: {
1331:                        throw new NoViableAltException(_t);
1332:                    }
1333:                    }
1334:                } catch (RecognitionException ex) {
1335:                    reportError(ex);
1336:                    if (_t != null) {
1337:                        _t = _t.getNextSibling();
1338:                    }
1339:                }
1340:                _retTree = _t;
1341:            }
1342:
1343:            public final void ruleScopeSpec(AST _t) throws RecognitionException {
1344:
1345:                GrammarAST ruleScopeSpec_AST_in = (_t == ASTNULL) ? null
1346:                        : (GrammarAST) _t;
1347:
1348:                try { // for error handling
1349:                    AST __t57 = _t;
1350:                    GrammarAST tmp41_AST_in = (GrammarAST) _t;
1351:                    match(_t, SCOPE);
1352:                    _t = _t.getFirstChild();
1353:                    {
1354:                        if (_t == null)
1355:                            _t = ASTNULL;
1356:                        switch (_t.getType()) {
1357:                        case ACTION: {
1358:                            GrammarAST tmp42_AST_in = (GrammarAST) _t;
1359:                            match(_t, ACTION);
1360:                            _t = _t.getNextSibling();
1361:                            break;
1362:                        }
1363:                        case 3:
1364:                        case ID: {
1365:                            break;
1366:                        }
1367:                        default: {
1368:                            throw new NoViableAltException(_t);
1369:                        }
1370:                        }
1371:                    }
1372:                    {
1373:                        _loop60: do {
1374:                            if (_t == null)
1375:                                _t = ASTNULL;
1376:                            if ((_t.getType() == ID)) {
1377:                                GrammarAST tmp43_AST_in = (GrammarAST) _t;
1378:                                match(_t, ID);
1379:                                _t = _t.getNextSibling();
1380:                            } else {
1381:                                break _loop60;
1382:                            }
1383:
1384:                        } while (true);
1385:                    }
1386:                    _t = __t57;
1387:                    _t = _t.getNextSibling();
1388:                } catch (RecognitionException ex) {
1389:                    reportError(ex);
1390:                    if (_t != null) {
1391:                        _t = _t.getNextSibling();
1392:                    }
1393:                }
1394:                _retTree = _t;
1395:            }
1396:
1397:            public final void ruleAction(AST _t) throws RecognitionException {
1398:
1399:                GrammarAST ruleAction_AST_in = (_t == ASTNULL) ? null
1400:                        : (GrammarAST) _t;
1401:                GrammarAST id = null;
1402:                GrammarAST a = null;
1403:
1404:                try { // for error handling
1405:                    AST __t54 = _t;
1406:                    GrammarAST tmp44_AST_in = (GrammarAST) _t;
1407:                    match(_t, AMPERSAND);
1408:                    _t = _t.getFirstChild();
1409:                    id = (GrammarAST) _t;
1410:                    match(_t, ID);
1411:                    _t = _t.getNextSibling();
1412:                    a = (GrammarAST) _t;
1413:                    match(_t, ACTION);
1414:                    _t = _t.getNextSibling();
1415:                    _t = __t54;
1416:                    _t = _t.getNextSibling();
1417:                    if (showActions)
1418:                        out("@" + id.getText() + "{" + a.getText() + "}");
1419:                } catch (RecognitionException ex) {
1420:                    reportError(ex);
1421:                    if (_t != null) {
1422:                        _t = _t.getNextSibling();
1423:                    }
1424:                }
1425:                _retTree = _t;
1426:            }
1427:
1428:            public final void block(AST _t, boolean forceParens)
1429:                    throws RecognitionException {
1430:
1431:                GrammarAST block_AST_in = (_t == ASTNULL) ? null
1432:                        : (GrammarAST) _t;
1433:
1434:                int numAlts = countAltsForBlock(block_AST_in);
1435:
1436:                try { // for error handling
1437:                    AST __t62 = _t;
1438:                    GrammarAST tmp45_AST_in = (GrammarAST) _t;
1439:                    match(_t, BLOCK);
1440:                    _t = _t.getFirstChild();
1441:                    if (forceParens || numAlts > 1)
1442:                        out(" (");
1443:                    {
1444:                        if (_t == null)
1445:                            _t = ASTNULL;
1446:                        switch (_t.getType()) {
1447:                        case OPTIONS: {
1448:                            optionsSpec(_t);
1449:                            _t = _retTree;
1450:                            out(" : ");
1451:                            break;
1452:                        }
1453:                        case ALT: {
1454:                            break;
1455:                        }
1456:                        default: {
1457:                            throw new NoViableAltException(_t);
1458:                        }
1459:                        }
1460:                    }
1461:                    alternative(_t);
1462:                    _t = _retTree;
1463:                    rewrite(_t);
1464:                    _t = _retTree;
1465:                    {
1466:                        _loop65: do {
1467:                            if (_t == null)
1468:                                _t = ASTNULL;
1469:                            if ((_t.getType() == ALT)) {
1470:                                out(" | ");
1471:                                alternative(_t);
1472:                                _t = _retTree;
1473:                                rewrite(_t);
1474:                                _t = _retTree;
1475:                            } else {
1476:                                break _loop65;
1477:                            }
1478:
1479:                        } while (true);
1480:                    }
1481:                    GrammarAST tmp46_AST_in = (GrammarAST) _t;
1482:                    match(_t, EOB);
1483:                    _t = _t.getNextSibling();
1484:                    if (forceParens || numAlts > 1)
1485:                        out(")");
1486:                    _t = __t62;
1487:                    _t = _t.getNextSibling();
1488:                } catch (RecognitionException ex) {
1489:                    reportError(ex);
1490:                    if (_t != null) {
1491:                        _t = _t.getNextSibling();
1492:                    }
1493:                }
1494:                _retTree = _t;
1495:            }
1496:
1497:            public final void exceptionGroup(AST _t)
1498:                    throws RecognitionException {
1499:
1500:                GrammarAST exceptionGroup_AST_in = (_t == ASTNULL) ? null
1501:                        : (GrammarAST) _t;
1502:
1503:                try { // for error handling
1504:                    if (_t == null)
1505:                        _t = ASTNULL;
1506:                    switch (_t.getType()) {
1507:                    case LITERAL_catch: {
1508:                        {
1509:                            int _cnt79 = 0;
1510:                            _loop79: do {
1511:                                if (_t == null)
1512:                                    _t = ASTNULL;
1513:                                if ((_t.getType() == LITERAL_catch)) {
1514:                                    exceptionHandler(_t);
1515:                                    _t = _retTree;
1516:                                } else {
1517:                                    if (_cnt79 >= 1) {
1518:                                        break _loop79;
1519:                                    } else {
1520:                                        throw new NoViableAltException(_t);
1521:                                    }
1522:                                }
1523:
1524:                                _cnt79++;
1525:                            } while (true);
1526:                        }
1527:                        {
1528:                            if (_t == null)
1529:                                _t = ASTNULL;
1530:                            switch (_t.getType()) {
1531:                            case LITERAL_finally: {
1532:                                finallyClause(_t);
1533:                                _t = _retTree;
1534:                                break;
1535:                            }
1536:                            case EOR: {
1537:                                break;
1538:                            }
1539:                            default: {
1540:                                throw new NoViableAltException(_t);
1541:                            }
1542:                            }
1543:                        }
1544:                        break;
1545:                    }
1546:                    case LITERAL_finally: {
1547:                        finallyClause(_t);
1548:                        _t = _retTree;
1549:                        break;
1550:                    }
1551:                    default: {
1552:                        throw new NoViableAltException(_t);
1553:                    }
1554:                    }
1555:                } catch (RecognitionException ex) {
1556:                    reportError(ex);
1557:                    if (_t != null) {
1558:                        _t = _t.getNextSibling();
1559:                    }
1560:                }
1561:                _retTree = _t;
1562:            }
1563:
1564:            public final void rewrite(AST _t) throws RecognitionException {
1565:
1566:                GrammarAST rewrite_AST_in = (_t == ASTNULL) ? null
1567:                        : (GrammarAST) _t;
1568:
1569:                try { // for error handling
1570:                    {
1571:                        _loop99: do {
1572:                            if (_t == null)
1573:                                _t = ASTNULL;
1574:                            if ((_t.getType() == REWRITE)) {
1575:                                single_rewrite(_t);
1576:                                _t = _retTree;
1577:                            } else {
1578:                                break _loop99;
1579:                            }
1580:
1581:                        } while (true);
1582:                    }
1583:                } catch (RecognitionException ex) {
1584:                    reportError(ex);
1585:                    if (_t != null) {
1586:                        _t = _t.getNextSibling();
1587:                    }
1588:                }
1589:                _retTree = _t;
1590:            }
1591:
1592:            public final int countAltsForBlock(AST _t)
1593:                    throws RecognitionException {
1594:                int n = 0;
1595:
1596:                GrammarAST countAltsForBlock_AST_in = (_t == ASTNULL) ? null
1597:                        : (GrammarAST) _t;
1598:
1599:                try { // for error handling
1600:                    AST __t67 = _t;
1601:                    GrammarAST tmp47_AST_in = (GrammarAST) _t;
1602:                    match(_t, BLOCK);
1603:                    _t = _t.getFirstChild();
1604:                    {
1605:                        if (_t == null)
1606:                            _t = ASTNULL;
1607:                        switch (_t.getType()) {
1608:                        case OPTIONS: {
1609:                            GrammarAST tmp48_AST_in = (GrammarAST) _t;
1610:                            match(_t, OPTIONS);
1611:                            _t = _t.getNextSibling();
1612:                            break;
1613:                        }
1614:                        case ALT: {
1615:                            break;
1616:                        }
1617:                        default: {
1618:                            throw new NoViableAltException(_t);
1619:                        }
1620:                        }
1621:                    }
1622:                    {
1623:                        int _cnt72 = 0;
1624:                        _loop72: do {
1625:                            if (_t == null)
1626:                                _t = ASTNULL;
1627:                            if ((_t.getType() == ALT)) {
1628:                                GrammarAST tmp49_AST_in = (GrammarAST) _t;
1629:                                match(_t, ALT);
1630:                                _t = _t.getNextSibling();
1631:                                {
1632:                                    _loop71: do {
1633:                                        if (_t == null)
1634:                                            _t = ASTNULL;
1635:                                        if ((_t.getType() == REWRITE)) {
1636:                                            GrammarAST tmp50_AST_in = (GrammarAST) _t;
1637:                                            match(_t, REWRITE);
1638:                                            _t = _t.getNextSibling();
1639:                                        } else {
1640:                                            break _loop71;
1641:                                        }
1642:
1643:                                    } while (true);
1644:                                }
1645:                                n++;
1646:                            } else {
1647:                                if (_cnt72 >= 1) {
1648:                                    break _loop72;
1649:                                } else {
1650:                                    throw new NoViableAltException(_t);
1651:                                }
1652:                            }
1653:
1654:                            _cnt72++;
1655:                        } while (true);
1656:                    }
1657:                    GrammarAST tmp51_AST_in = (GrammarAST) _t;
1658:                    match(_t, EOB);
1659:                    _t = _t.getNextSibling();
1660:                    _t = __t67;
1661:                    _t = _t.getNextSibling();
1662:                } catch (RecognitionException ex) {
1663:                    reportError(ex);
1664:                    if (_t != null) {
1665:                        _t = _t.getNextSibling();
1666:                    }
1667:                }
1668:                _retTree = _t;
1669:                return n;
1670:            }
1671:
1672:            public final void exceptionHandler(AST _t)
1673:                    throws RecognitionException {
1674:
1675:                GrammarAST exceptionHandler_AST_in = (_t == ASTNULL) ? null
1676:                        : (GrammarAST) _t;
1677:
1678:                try { // for error handling
1679:                    AST __t82 = _t;
1680:                    GrammarAST tmp52_AST_in = (GrammarAST) _t;
1681:                    match(_t, LITERAL_catch);
1682:                    _t = _t.getFirstChild();
1683:                    GrammarAST tmp53_AST_in = (GrammarAST) _t;
1684:                    match(_t, ARG_ACTION);
1685:                    _t = _t.getNextSibling();
1686:                    GrammarAST tmp54_AST_in = (GrammarAST) _t;
1687:                    match(_t, ACTION);
1688:                    _t = _t.getNextSibling();
1689:                    _t = __t82;
1690:                    _t = _t.getNextSibling();
1691:                } catch (RecognitionException ex) {
1692:                    reportError(ex);
1693:                    if (_t != null) {
1694:                        _t = _t.getNextSibling();
1695:                    }
1696:                }
1697:                _retTree = _t;
1698:            }
1699:
1700:            public final void finallyClause(AST _t) throws RecognitionException {
1701:
1702:                GrammarAST finallyClause_AST_in = (_t == ASTNULL) ? null
1703:                        : (GrammarAST) _t;
1704:
1705:                try { // for error handling
1706:                    AST __t84 = _t;
1707:                    GrammarAST tmp55_AST_in = (GrammarAST) _t;
1708:                    match(_t, LITERAL_finally);
1709:                    _t = _t.getFirstChild();
1710:                    GrammarAST tmp56_AST_in = (GrammarAST) _t;
1711:                    match(_t, ACTION);
1712:                    _t = _t.getNextSibling();
1713:                    _t = __t84;
1714:                    _t = _t.getNextSibling();
1715:                } catch (RecognitionException ex) {
1716:                    reportError(ex);
1717:                    if (_t != null) {
1718:                        _t = _t.getNextSibling();
1719:                    }
1720:                }
1721:                _retTree = _t;
1722:            }
1723:
1724:            public final void rewrite_template(AST _t)
1725:                    throws RecognitionException {
1726:
1727:                GrammarAST rewrite_template_AST_in = (_t == ASTNULL) ? null
1728:                        : (GrammarAST) _t;
1729:                GrammarAST id = null;
1730:                GrammarAST ind = null;
1731:                GrammarAST arg = null;
1732:                GrammarAST a = null;
1733:
1734:                try { // for error handling
1735:                    AST __t90 = _t;
1736:                    GrammarAST tmp57_AST_in = (GrammarAST) _t;
1737:                    match(_t, TEMPLATE);
1738:                    _t = _t.getFirstChild();
1739:                    {
1740:                        if (_t == null)
1741:                            _t = ASTNULL;
1742:                        switch (_t.getType()) {
1743:                        case ID: {
1744:                            id = (GrammarAST) _t;
1745:                            match(_t, ID);
1746:                            _t = _t.getNextSibling();
1747:                            out(" " + id.getText());
1748:                            break;
1749:                        }
1750:                        case ACTION: {
1751:                            ind = (GrammarAST) _t;
1752:                            match(_t, ACTION);
1753:                            _t = _t.getNextSibling();
1754:                            out(" ({" + ind.getText() + "})");
1755:                            break;
1756:                        }
1757:                        default: {
1758:                            throw new NoViableAltException(_t);
1759:                        }
1760:                        }
1761:                    }
1762:                    AST __t92 = _t;
1763:                    GrammarAST tmp58_AST_in = (GrammarAST) _t;
1764:                    match(_t, ARGLIST);
1765:                    _t = _t.getFirstChild();
1766:                    out("(");
1767:                    {
1768:                        _loop95: do {
1769:                            if (_t == null)
1770:                                _t = ASTNULL;
1771:                            if ((_t.getType() == ARG)) {
1772:                                AST __t94 = _t;
1773:                                GrammarAST tmp59_AST_in = (GrammarAST) _t;
1774:                                match(_t, ARG);
1775:                                _t = _t.getFirstChild();
1776:                                arg = (GrammarAST) _t;
1777:                                match(_t, ID);
1778:                                _t = _t.getNextSibling();
1779:                                out(arg.getText() + "=");
1780:                                a = (GrammarAST) _t;
1781:                                match(_t, ACTION);
1782:                                _t = _t.getNextSibling();
1783:                                out(a.getText());
1784:                                _t = __t94;
1785:                                _t = _t.getNextSibling();
1786:                            } else {
1787:                                break _loop95;
1788:                            }
1789:
1790:                        } while (true);
1791:                    }
1792:                    out(")");
1793:                    _t = __t92;
1794:                    _t = _t.getNextSibling();
1795:                    {
1796:                        if (_t == null)
1797:                            _t = ASTNULL;
1798:                        switch (_t.getType()) {
1799:                        case DOUBLE_QUOTE_STRING_LITERAL: {
1800:                            GrammarAST tmp60_AST_in = (GrammarAST) _t;
1801:                            match(_t, DOUBLE_QUOTE_STRING_LITERAL);
1802:                            _t = _t.getNextSibling();
1803:                            out(" " + tmp60_AST_in.getText());
1804:                            break;
1805:                        }
1806:                        case DOUBLE_ANGLE_STRING_LITERAL: {
1807:                            GrammarAST tmp61_AST_in = (GrammarAST) _t;
1808:                            match(_t, DOUBLE_ANGLE_STRING_LITERAL);
1809:                            _t = _t.getNextSibling();
1810:                            out(" " + tmp61_AST_in.getText());
1811:                            break;
1812:                        }
1813:                        case 3: {
1814:                            break;
1815:                        }
1816:                        default: {
1817:                            throw new NoViableAltException(_t);
1818:                        }
1819:                        }
1820:                    }
1821:                    _t = __t90;
1822:                    _t = _t.getNextSibling();
1823:                } catch (RecognitionException ex) {
1824:                    reportError(ex);
1825:                    if (_t != null) {
1826:                        _t = _t.getNextSibling();
1827:                    }
1828:                }
1829:                _retTree = _t;
1830:            }
1831:
1832:            public final void atom(AST _t) throws RecognitionException {
1833:
1834:                GrammarAST atom_AST_in = (_t == ASTNULL) ? null
1835:                        : (GrammarAST) _t;
1836:                GrammarAST rarg = null;
1837:                GrammarAST targ = null;
1838:                out(" ");
1839:
1840:                try { // for error handling
1841:                    if (_t == null)
1842:                        _t = ASTNULL;
1843:                    switch (_t.getType()) {
1844:                    case STRING_LITERAL:
1845:                    case CHAR_LITERAL:
1846:                    case TOKEN_REF:
1847:                    case RULE_REF:
1848:                    case WILDCARD: {
1849:                        {
1850:                            if (_t == null)
1851:                                _t = ASTNULL;
1852:                            switch (_t.getType()) {
1853:                            case RULE_REF: {
1854:                                AST __t119 = _t;
1855:                                GrammarAST tmp62_AST_in = (GrammarAST) _t;
1856:                                match(_t, RULE_REF);
1857:                                _t = _t.getFirstChild();
1858:                                out(atom_AST_in.toString());
1859:                                {
1860:                                    if (_t == null)
1861:                                        _t = ASTNULL;
1862:                                    switch (_t.getType()) {
1863:                                    case ARG_ACTION: {
1864:                                        rarg = (GrammarAST) _t;
1865:                                        match(_t, ARG_ACTION);
1866:                                        _t = _t.getNextSibling();
1867:                                        out("[" + rarg.toString() + "]");
1868:                                        break;
1869:                                    }
1870:                                    case 3:
1871:                                    case BANG:
1872:                                    case ROOT: {
1873:                                        break;
1874:                                    }
1875:                                    default: {
1876:                                        throw new NoViableAltException(_t);
1877:                                    }
1878:                                    }
1879:                                }
1880:                                {
1881:                                    if (_t == null)
1882:                                        _t = ASTNULL;
1883:                                    switch (_t.getType()) {
1884:                                    case BANG:
1885:                                    case ROOT: {
1886:                                        ast_suffix(_t);
1887:                                        _t = _retTree;
1888:                                        break;
1889:                                    }
1890:                                    case 3: {
1891:                                        break;
1892:                                    }
1893:                                    default: {
1894:                                        throw new NoViableAltException(_t);
1895:                                    }
1896:                                    }
1897:                                }
1898:                                _t = __t119;
1899:                                _t = _t.getNextSibling();
1900:                                break;
1901:                            }
1902:                            case TOKEN_REF: {
1903:                                AST __t122 = _t;
1904:                                GrammarAST tmp63_AST_in = (GrammarAST) _t;
1905:                                match(_t, TOKEN_REF);
1906:                                _t = _t.getFirstChild();
1907:                                out(atom_AST_in.toString());
1908:                                {
1909:                                    if (_t == null)
1910:                                        _t = ASTNULL;
1911:                                    switch (_t.getType()) {
1912:                                    case ARG_ACTION: {
1913:                                        targ = (GrammarAST) _t;
1914:                                        match(_t, ARG_ACTION);
1915:                                        _t = _t.getNextSibling();
1916:                                        out("[" + targ.toString() + "]");
1917:                                        break;
1918:                                    }
1919:                                    case 3:
1920:                                    case BANG:
1921:                                    case ROOT: {
1922:                                        break;
1923:                                    }
1924:                                    default: {
1925:                                        throw new NoViableAltException(_t);
1926:                                    }
1927:                                    }
1928:                                }
1929:                                {
1930:                                    if (_t == null)
1931:                                        _t = ASTNULL;
1932:                                    switch (_t.getType()) {
1933:                                    case BANG:
1934:                                    case ROOT: {
1935:                                        ast_suffix(_t);
1936:                                        _t = _retTree;
1937:                                        break;
1938:                                    }
1939:                                    case 3: {
1940:                                        break;
1941:                                    }
1942:                                    default: {
1943:                                        throw new NoViableAltException(_t);
1944:                                    }
1945:                                    }
1946:                                }
1947:                                _t = __t122;
1948:                                _t = _t.getNextSibling();
1949:                                break;
1950:                            }
1951:                            case CHAR_LITERAL: {
1952:                                AST __t125 = _t;
1953:                                GrammarAST tmp64_AST_in = (GrammarAST) _t;
1954:                                match(_t, CHAR_LITERAL);
1955:                                _t = _t.getFirstChild();
1956:                                out(atom_AST_in.toString());
1957:                                {
1958:                                    if (_t == null)
1959:                                        _t = ASTNULL;
1960:                                    switch (_t.getType()) {
1961:                                    case BANG:
1962:                                    case ROOT: {
1963:                                        ast_suffix(_t);
1964:                                        _t = _retTree;
1965:                                        break;
1966:                                    }
1967:                                    case 3: {
1968:                                        break;
1969:                                    }
1970:                                    default: {
1971:                                        throw new NoViableAltException(_t);
1972:                                    }
1973:                                    }
1974:                                }
1975:                                _t = __t125;
1976:                                _t = _t.getNextSibling();
1977:                                break;
1978:                            }
1979:                            case STRING_LITERAL: {
1980:                                AST __t127 = _t;
1981:                                GrammarAST tmp65_AST_in = (GrammarAST) _t;
1982:                                match(_t, STRING_LITERAL);
1983:                                _t = _t.getFirstChild();
1984:                                out(atom_AST_in.toString());
1985:                                {
1986:                                    if (_t == null)
1987:                                        _t = ASTNULL;
1988:                                    switch (_t.getType()) {
1989:                                    case BANG:
1990:                                    case ROOT: {
1991:                                        ast_suffix(_t);
1992:                                        _t = _retTree;
1993:                                        break;
1994:                                    }
1995:                                    case 3: {
1996:                                        break;
1997:                                    }
1998:                                    default: {
1999:                                        throw new NoViableAltException(_t);
2000:                                    }
2001:                                    }
2002:                                }
2003:                                _t = __t127;
2004:                                _t = _t.getNextSibling();
2005:                                break;
2006:                            }
2007:                            case WILDCARD: {
2008:                                AST __t129 = _t;
2009:                                GrammarAST tmp66_AST_in = (GrammarAST) _t;
2010:                                match(_t, WILDCARD);
2011:                                _t = _t.getFirstChild();
2012:                                out(atom_AST_in.toString());
2013:                                {
2014:                                    if (_t == null)
2015:                                        _t = ASTNULL;
2016:                                    switch (_t.getType()) {
2017:                                    case BANG:
2018:                                    case ROOT: {
2019:                                        ast_suffix(_t);
2020:                                        _t = _retTree;
2021:                                        break;
2022:                                    }
2023:                                    case 3: {
2024:                                        break;
2025:                                    }
2026:                                    default: {
2027:                                        throw new NoViableAltException(_t);
2028:                                    }
2029:                                    }
2030:                                }
2031:                                _t = __t129;
2032:                                _t = _t.getNextSibling();
2033:                                break;
2034:                            }
2035:                            default: {
2036:                                throw new NoViableAltException(_t);
2037:                            }
2038:                            }
2039:                        }
2040:                        out(" ");
2041:                        break;
2042:                    }
2043:                    case LABEL: {
2044:                        GrammarAST tmp67_AST_in = (GrammarAST) _t;
2045:                        match(_t, LABEL);
2046:                        _t = _t.getNextSibling();
2047:                        out(" $" + tmp67_AST_in.getText());
2048:                        break;
2049:                    }
2050:                    default: {
2051:                        throw new NoViableAltException(_t);
2052:                    }
2053:                    }
2054:                } catch (RecognitionException ex) {
2055:                    reportError(ex);
2056:                    if (_t != null) {
2057:                        _t = _t.getNextSibling();
2058:                    }
2059:                }
2060:                _retTree = _t;
2061:            }
2062:
2063:            public final void ebnf(AST _t) throws RecognitionException {
2064:
2065:                GrammarAST ebnf_AST_in = (_t == ASTNULL) ? null
2066:                        : (GrammarAST) _t;
2067:
2068:                try { // for error handling
2069:                    if (_t == null)
2070:                        _t = ASTNULL;
2071:                    switch (_t.getType()) {
2072:                    case BLOCK: {
2073:                        block(_t, true);
2074:                        _t = _retTree;
2075:                        out(" ");
2076:                        break;
2077:                    }
2078:                    case OPTIONAL: {
2079:                        AST __t110 = _t;
2080:                        GrammarAST tmp68_AST_in = (GrammarAST) _t;
2081:                        match(_t, OPTIONAL);
2082:                        _t = _t.getFirstChild();
2083:                        block(_t, true);
2084:                        _t = _retTree;
2085:                        _t = __t110;
2086:                        _t = _t.getNextSibling();
2087:                        out("? ");
2088:                        break;
2089:                    }
2090:                    case CLOSURE: {
2091:                        AST __t111 = _t;
2092:                        GrammarAST tmp69_AST_in = (GrammarAST) _t;
2093:                        match(_t, CLOSURE);
2094:                        _t = _t.getFirstChild();
2095:                        block(_t, true);
2096:                        _t = _retTree;
2097:                        _t = __t111;
2098:                        _t = _t.getNextSibling();
2099:                        out("* ");
2100:                        break;
2101:                    }
2102:                    case POSITIVE_CLOSURE: {
2103:                        AST __t112 = _t;
2104:                        GrammarAST tmp70_AST_in = (GrammarAST) _t;
2105:                        match(_t, POSITIVE_CLOSURE);
2106:                        _t = _t.getFirstChild();
2107:                        block(_t, true);
2108:                        _t = _retTree;
2109:                        _t = __t112;
2110:                        _t = _t.getNextSibling();
2111:                        out("+ ");
2112:                        break;
2113:                    }
2114:                    default: {
2115:                        throw new NoViableAltException(_t);
2116:                    }
2117:                    }
2118:                } catch (RecognitionException ex) {
2119:                    reportError(ex);
2120:                    if (_t != null) {
2121:                        _t = _t.getNextSibling();
2122:                    }
2123:                }
2124:                _retTree = _t;
2125:            }
2126:
2127:            public final void tree(AST _t) throws RecognitionException {
2128:
2129:                GrammarAST tree_AST_in = (_t == ASTNULL) ? null
2130:                        : (GrammarAST) _t;
2131:
2132:                try { // for error handling
2133:                    AST __t114 = _t;
2134:                    GrammarAST tmp71_AST_in = (GrammarAST) _t;
2135:                    match(_t, TREE_BEGIN);
2136:                    _t = _t.getFirstChild();
2137:                    out(" ^(");
2138:                    element(_t);
2139:                    _t = _retTree;
2140:                    {
2141:                        _loop116: do {
2142:                            if (_t == null)
2143:                                _t = ASTNULL;
2144:                            if ((_t.getType() == BLOCK
2145:                                    || _t.getType() == OPTIONAL
2146:                                    || _t.getType() == CLOSURE
2147:                                    || _t.getType() == POSITIVE_CLOSURE
2148:                                    || _t.getType() == SYNPRED
2149:                                    || _t.getType() == RANGE
2150:                                    || _t.getType() == CHAR_RANGE
2151:                                    || _t.getType() == EPSILON
2152:                                    || _t.getType() == LABEL
2153:                                    || _t.getType() == GATED_SEMPRED
2154:                                    || _t.getType() == SYN_SEMPRED
2155:                                    || _t.getType() == BACKTRACK_SEMPRED
2156:                                    || _t.getType() == ACTION
2157:                                    || _t.getType() == ASSIGN
2158:                                    || _t.getType() == STRING_LITERAL
2159:                                    || _t.getType() == CHAR_LITERAL
2160:                                    || _t.getType() == TOKEN_REF
2161:                                    || _t.getType() == BANG
2162:                                    || _t.getType() == PLUS_ASSIGN
2163:                                    || _t.getType() == SEMPRED
2164:                                    || _t.getType() == ROOT
2165:                                    || _t.getType() == RULE_REF
2166:                                    || _t.getType() == NOT
2167:                                    || _t.getType() == TREE_BEGIN || _t
2168:                                    .getType() == WILDCARD)) {
2169:                                element(_t);
2170:                                _t = _retTree;
2171:                            } else {
2172:                                break _loop116;
2173:                            }
2174:
2175:                        } while (true);
2176:                    }
2177:                    out(") ");
2178:                    _t = __t114;
2179:                    _t = _t.getNextSibling();
2180:                } catch (RecognitionException ex) {
2181:                    reportError(ex);
2182:                    if (_t != null) {
2183:                        _t = _t.getNextSibling();
2184:                    }
2185:                }
2186:                _retTree = _t;
2187:            }
2188:
2189:            public final void ast_suffix(AST _t) throws RecognitionException {
2190:
2191:                GrammarAST ast_suffix_AST_in = (_t == ASTNULL) ? null
2192:                        : (GrammarAST) _t;
2193:
2194:                try { // for error handling
2195:                    if (_t == null)
2196:                        _t = ASTNULL;
2197:                    switch (_t.getType()) {
2198:                    case ROOT: {
2199:                        GrammarAST tmp72_AST_in = (GrammarAST) _t;
2200:                        match(_t, ROOT);
2201:                        _t = _t.getNextSibling();
2202:                        out("^");
2203:                        break;
2204:                    }
2205:                    case BANG: {
2206:                        GrammarAST tmp73_AST_in = (GrammarAST) _t;
2207:                        match(_t, BANG);
2208:                        _t = _t.getNextSibling();
2209:                        out("!");
2210:                        break;
2211:                    }
2212:                    default: {
2213:                        throw new NoViableAltException(_t);
2214:                    }
2215:                    }
2216:                } catch (RecognitionException ex) {
2217:                    reportError(ex);
2218:                    if (_t != null) {
2219:                        _t = _t.getNextSibling();
2220:                    }
2221:                }
2222:                _retTree = _t;
2223:            }
2224:
2225:            public static final String[] _tokenNames = { "<0>", "EOF", "<2>",
2226:                    "NULL_TREE_LOOKAHEAD", "\"options\"", "\"tokens\"",
2227:                    "\"parser\"", "LEXER", "RULE", "BLOCK", "OPTIONAL",
2228:                    "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "RANGE",
2229:                    "CHAR_RANGE", "EPSILON", "ALT", "EOR", "EOB", "EOA", "ID",
2230:                    "ARG", "ARGLIST", "RET", "LEXER_GRAMMAR", "PARSER_GRAMMAR",
2231:                    "TREE_GRAMMAR", "COMBINED_GRAMMAR", "INITACTION", "LABEL",
2232:                    "TEMPLATE", "\"scope\"", "GATED_SEMPRED", "SYN_SEMPRED",
2233:                    "BACKTRACK_SEMPRED", "\"fragment\"", "ACTION",
2234:                    "DOC_COMMENT", "SEMI", "\"lexer\"", "\"tree\"",
2235:                    "\"grammar\"", "AMPERSAND", "COLON", "RCURLY", "ASSIGN",
2236:                    "STRING_LITERAL", "CHAR_LITERAL", "INT", "STAR",
2237:                    "TOKEN_REF", "\"protected\"", "\"public\"", "\"private\"",
2238:                    "BANG", "ARG_ACTION", "\"returns\"", "\"throws\"", "COMMA",
2239:                    "LPAREN", "OR", "RPAREN", "\"catch\"", "\"finally\"",
2240:                    "PLUS_ASSIGN", "SEMPRED", "IMPLIES", "ROOT", "RULE_REF",
2241:                    "NOT", "TREE_BEGIN", "QUESTION", "PLUS", "WILDCARD",
2242:                    "REWRITE", "DOLLAR", "DOUBLE_QUOTE_STRING_LITERAL",
2243:                    "DOUBLE_ANGLE_STRING_LITERAL", "WS", "COMMENT",
2244:                    "SL_COMMENT", "ML_COMMENT", "OPEN_ELEMENT_OPTION",
2245:                    "CLOSE_ELEMENT_OPTION", "ESC", "DIGIT", "XDIGIT",
2246:                    "NESTED_ARG_ACTION", "NESTED_ACTION",
2247:                    "ACTION_CHAR_LITERAL", "ACTION_STRING_LITERAL",
2248:                    "ACTION_ESC", "WS_LOOP", "INTERNAL_RULE_REF", "WS_OPT",
2249:                    "SRC" };
2250:
2251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.