📄 antlrtreeprinter.java
字号:
match(_t,ASSIGN); _t = _t.getFirstChild(); GrammarAST tmp32_AST_in = (GrammarAST)_t; match(_t,TOKEN_REF); _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case STRING_LITERAL: { GrammarAST tmp33_AST_in = (GrammarAST)_t; match(_t,STRING_LITERAL); _t = _t.getNextSibling(); break; } case CHAR_LITERAL: { GrammarAST tmp34_AST_in = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } _t = __t36; _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void modifier(AST _t) throws RecognitionException { GrammarAST modifier_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; out(modifier_AST_in.getText()); out(" "); try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case LITERAL_protected: { GrammarAST tmp35_AST_in = (GrammarAST)_t; match(_t,LITERAL_protected); _t = _t.getNextSibling(); break; } case LITERAL_public: { GrammarAST tmp36_AST_in = (GrammarAST)_t; match(_t,LITERAL_public); _t = _t.getNextSibling(); break; } case LITERAL_private: { GrammarAST tmp37_AST_in = (GrammarAST)_t; match(_t,LITERAL_private); _t = _t.getNextSibling(); break; } case FRAGMENT: { GrammarAST tmp38_AST_in = (GrammarAST)_t; match(_t,FRAGMENT); _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void ruleScopeSpec(AST _t) throws RecognitionException { GrammarAST ruleScopeSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t57 = _t; GrammarAST tmp39_AST_in = (GrammarAST)_t; match(_t,SCOPE); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ACTION: { GrammarAST tmp40_AST_in = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); break; } case 3: case ID: { break; } default: { throw new NoViableAltException(_t); } } } { _loop60: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ID)) { GrammarAST tmp41_AST_in = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); } else { break _loop60; } } while (true); } _t = __t57; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void ruleAction(AST _t) throws RecognitionException { GrammarAST ruleAction_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; GrammarAST a = null; try { // for error handling AST __t54 = _t; GrammarAST tmp42_AST_in = (GrammarAST)_t; match(_t,AMPERSAND); _t = _t.getFirstChild(); id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); a = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); _t = __t54; _t = _t.getNextSibling(); if ( showActions ) out("@"+id.getText()+"{"+a.getText()+"}"); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void block(AST _t, boolean forceParens ) throws RecognitionException { GrammarAST block_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; int numAlts = countAltsForBlock(block_AST_in); try { // for error handling AST __t62 = _t; GrammarAST tmp43_AST_in = (GrammarAST)_t; match(_t,BLOCK); _t = _t.getFirstChild(); if ( forceParens||numAlts>1 ) out(" ("); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { optionsSpec(_t); _t = _retTree; out(" : "); break; } case ALT: { break; } default: { throw new NoViableAltException(_t); } } } alternative(_t); _t = _retTree; rewrite(_t); _t = _retTree; { _loop65: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ALT)) { out(" | "); alternative(_t); _t = _retTree; rewrite(_t); _t = _retTree; } else { break _loop65; } } while (true); } GrammarAST tmp44_AST_in = (GrammarAST)_t; match(_t,EOB); _t = _t.getNextSibling(); if ( forceParens||numAlts>1 ) out(")"); _t = __t62; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void exceptionGroup(AST _t) throws RecognitionException { GrammarAST exceptionGroup_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling { int _cnt79=0; _loop79: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==LITERAL_exception)) { exceptionSpec(_t); _t = _retTree; } else { if ( _cnt79>=1 ) { break _loop79; } else {throw new NoViableAltException(_t);} } _cnt79++; } while (true); } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void rewrite(AST _t) throws RecognitionException { GrammarAST rewrite_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling { _loop101: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==REWRITE)) { single_rewrite(_t); _t = _retTree; } else { break _loop101; } } while (true); } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final int countAltsForBlock(AST _t) throws RecognitionException { int n=0; GrammarAST countAltsForBlock_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t67 = _t; GrammarAST tmp45_AST_in = (GrammarAST)_t; match(_t,BLOCK); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { GrammarAST tmp46_AST_in = (GrammarAST)_t; match(_t,OPTIONS); _t = _t.getNextSibling(); break; } case ALT: { break; } default: { throw new NoViableAltException(_t); } } } { int _cnt72=0; _loop72: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ALT)) { GrammarAST tmp47_AST_in = (GrammarAST)_t; match(_t,ALT); _t = _t.getNextSibling(); { _loop71: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==REWRITE)) { GrammarAST tmp48_AST_in = (GrammarAST)_t; match(_t,REWRITE); _t = _t.getNextSibling(); } else { break _loop71; } } while (true); } n++; } else { if ( _cnt72>=1 ) { break _loop72; } else {throw new NoViableAltException(_t);} } _cnt72++; } while (true); } GrammarAST tmp49_AST_in = (GrammarAST)_t; match(_t,EOB); _t = _t.getNextSibling(); _t = __t67; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; return n; } public final void exceptionSpec(AST _t) throws RecognitionException { GrammarAST exceptionSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t81 = _t; GrammarAST tmp50_AST_in = (GrammarAST)_t; match(_t,LITERAL_exception); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ARG_ACTION: { GrammarAST tmp51_AST_in = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); break; } case 3: case LITERAL_catch: { break; } default: { throw new NoViableAltException(_t); } } } { _loop84: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==LITERAL_catch)) { exceptionHandler(_t); _t = _retTree; } else { break _loop84; } } while (true); } _t = __t81; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void exceptionHandler(AST _t) throws RecognitionException { GrammarAST exceptionHandler_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t86 = _t; GrammarAST tmp52_AST_in = (GrammarAST)_t; match(_t,LITERAL_catch); _t = _t.getFirstChild(); GrammarAST tmp53_AST_in = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); GrammarAST tmp54_AST_in = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); _t = __t86; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void rewrite_template(AST _t) throws RecognitionException { GrammarAST rewrite_template_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; GrammarAST ind = null; GrammarAST arg = null; GrammarAST a = null; try { // for error handling AST __t92 = _t; GrammarAST tmp55_AST_in = (GrammarAST)_t; match(_t,TEMPLATE); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ID: { id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); out(" "+id.getText()); break; } case ACTION: { ind = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); out(" ({"+ind.getText()+"})"); break; } default: { throw new NoViableAltException(_t); } } } AST __t94 = _t; GrammarAST tmp56_AST_in = (GrammarAST)_t; match(_t,ARGLIST); _t = _t.getFirstChild(); out("("); { _loop97: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ARG)) { AST __t96 = _t; GrammarAST tmp57_AST_in = (GrammarAST)_t; match(_t,ARG); _t = _t.getFirstChild(); arg = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); out(arg.getText()+"="); a = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); out(a.getText()); _t = __t96; _t = _t.getNextSibling(); } else { break _loop97; } } while (true); } out(")"); _t = __t94; _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case DOUBLE_QUOTE_STRING_LITERAL: { GrammarAST tmp58_AST_in = (GrammarAST)_t; match(_t,DOUBLE_QUOTE_STRING_LITERAL); _t = _t.getNextSibling(); out(" "+tmp58_AST_in.getText()); break; } case DOUBLE_ANGLE_STRING_LITERAL: { GrammarAST tmp59_AST_in = (GrammarAST)_t; match(_t,DOUBLE_ANGLE_STRING_LITERAL); _t = _t.getNextSibling(); out(" "+tmp59_AST_in.getText()); break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t92; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void atom(AST _t) throws RecognitionException { GrammarAST atom_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST rarg = null; GrammarAST targ = null; out(" "); try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case STRING_LITERAL: case CHAR_LITERAL: case TOKEN_REF: case RULE_REF: case WILDCARD: { { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case RULE_REF: { AST __t121 = _t; GrammarAST tmp60_AST_in = (GrammarAST)_t; match(_t,RULE_REF); _t = _t.getFirstChild(); out(atom_AST_in.toString()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ARG_ACTION: { rarg = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); out("["+rarg.toString()+"]"); break; } case 3: case BANG: case ROOT: case RULEROOT: { break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -