📄 antlrtreeprinter.java
字号:
default: { throw new NoViableAltException(_t); } } } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t121; _t = _t.getNextSibling(); break; } case TOKEN_REF: { AST __t124 = _t; GrammarAST tmp61_AST_in = (GrammarAST)_t; match(_t,TOKEN_REF); _t = _t.getFirstChild(); out(atom_AST_in.toString()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ARG_ACTION: { targ = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); out("["+targ.toString()+"]"); break; } case 3: case BANG: case ROOT: case RULEROOT: { break; } default: { throw new NoViableAltException(_t); } } } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t124; _t = _t.getNextSibling(); break; } case CHAR_LITERAL: { AST __t127 = _t; GrammarAST tmp62_AST_in = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getFirstChild(); out(atom_AST_in.toString()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t127; _t = _t.getNextSibling(); break; } case STRING_LITERAL: { AST __t129 = _t; GrammarAST tmp63_AST_in = (GrammarAST)_t; match(_t,STRING_LITERAL); _t = _t.getFirstChild(); out(atom_AST_in.toString()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t129; _t = _t.getNextSibling(); break; } case WILDCARD: { AST __t131 = _t; GrammarAST tmp64_AST_in = (GrammarAST)_t; match(_t,WILDCARD); _t = _t.getFirstChild(); out(atom_AST_in.toString()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t131; _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } out(" "); break; } case LABEL: { GrammarAST tmp65_AST_in = (GrammarAST)_t; match(_t,LABEL); _t = _t.getNextSibling(); out(" $"+tmp65_AST_in.getText()); break; } case SET: { set(_t); _t = _retTree; break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void ebnf(AST _t) throws RecognitionException { GrammarAST ebnf_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BLOCK: { block(_t,true); _t = _retTree; out(" "); break; } case OPTIONAL: { AST __t112 = _t; GrammarAST tmp66_AST_in = (GrammarAST)_t; match(_t,OPTIONAL); _t = _t.getFirstChild(); block(_t,true); _t = _retTree; _t = __t112; _t = _t.getNextSibling(); out("? "); break; } case CLOSURE: { AST __t113 = _t; GrammarAST tmp67_AST_in = (GrammarAST)_t; match(_t,CLOSURE); _t = _t.getFirstChild(); block(_t,true); _t = _retTree; _t = __t113; _t = _t.getNextSibling(); out("* "); break; } case POSITIVE_CLOSURE: { AST __t114 = _t; GrammarAST tmp68_AST_in = (GrammarAST)_t; match(_t,POSITIVE_CLOSURE); _t = _t.getFirstChild(); block(_t,true); _t = _retTree; _t = __t114; _t = _t.getNextSibling(); out("+ "); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void tree(AST _t) throws RecognitionException { GrammarAST tree_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t116 = _t; GrammarAST tmp69_AST_in = (GrammarAST)_t; match(_t,TREE_BEGIN); _t = _t.getFirstChild(); out(" ^("); element(_t); _t = _retTree; { _loop118: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==BLOCK||_t.getType()==OPTIONAL||_t.getType()==CLOSURE||_t.getType()==POSITIVE_CLOSURE||_t.getType()==SYNPRED||_t.getType()==RANGE||_t.getType()==CHAR_RANGE||_t.getType()==EPSILON||_t.getType()==SET||_t.getType()==LABEL||_t.getType()==GATED_SEMPRED||_t.getType()==SYN_SEMPRED||_t.getType()==ACTION||_t.getType()==ASSIGN||_t.getType()==STRING_LITERAL||_t.getType()==CHAR_LITERAL||_t.getType()==TOKEN_REF||_t.getType()==PLUS_ASSIGN||_t.getType()==SEMPRED||_t.getType()==NOT||_t.getType()==TREE_BEGIN||_t.getType()==RULE_REF||_t.getType()==WILDCARD)) { element(_t); _t = _retTree; } else { break _loop118; } } while (true); } out(") "); _t = __t116; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void ast_suffix(AST _t) throws RecognitionException { GrammarAST ast_suffix_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ROOT: { GrammarAST tmp70_AST_in = (GrammarAST)_t; match(_t,ROOT); _t = _t.getNextSibling(); out("^"); break; } case RULEROOT: { GrammarAST tmp71_AST_in = (GrammarAST)_t; match(_t,RULEROOT); _t = _t.getNextSibling(); out("^^"); break; } case BANG: { GrammarAST tmp72_AST_in = (GrammarAST)_t; match(_t,BANG); _t = _t.getNextSibling(); out("!"); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void set(AST _t) throws RecognitionException { GrammarAST set_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t135 = _t; GrammarAST tmp73_AST_in = (GrammarAST)_t; match(_t,SET); _t = _t.getFirstChild(); out("("); setElement(_t); _t = _retTree; { _loop137: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==CHAR_RANGE||_t.getType()==STRING_LITERAL||_t.getType()==CHAR_LITERAL||_t.getType()==TOKEN_REF)) { out("|"); setElement(_t); _t = _retTree; } else { break _loop137; } } while (true); } out(")"); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case BANG: case ROOT: case RULEROOT: { ast_suffix(_t); _t = _retTree; break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t135; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void setElement(AST _t) throws RecognitionException { GrammarAST setElement_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST c1 = null; GrammarAST c2 = null; try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case STRING_LITERAL: case CHAR_LITERAL: case TOKEN_REF: { { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case CHAR_LITERAL: { GrammarAST tmp74_AST_in = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getNextSibling(); out(setElement_AST_in.toString()); break; } case TOKEN_REF: { GrammarAST tmp75_AST_in = (GrammarAST)_t; match(_t,TOKEN_REF); _t = _t.getNextSibling(); out(setElement_AST_in.toString()); break; } case STRING_LITERAL: { GrammarAST tmp76_AST_in = (GrammarAST)_t; match(_t,STRING_LITERAL); _t = _t.getNextSibling(); out(setElement_AST_in.toString()); break; } default: { throw new NoViableAltException(_t); } } } break; } case CHAR_RANGE: { AST __t141 = _t; GrammarAST tmp77_AST_in = (GrammarAST)_t; match(_t,CHAR_RANGE); _t = _t.getFirstChild(); c1 = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getNextSibling(); c2 = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getNextSibling(); _t = __t141; _t = _t.getNextSibling(); out(c1.getText()+ ".."+ c2.getText()); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public static final String[] _tokenNames = { "<0>", "EOF", "<2>", "NULL_TREE_LOOKAHEAD", "\"options\"", "\"tokens\"", "\"parser\"", "LEXER", "RULE", "BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "RANGE", "CHAR_RANGE", "EPSILON", "ALT", "EOR", "EOB", "EOA", "CHARSET", "SET", "ID", "ARG", "ARGLIST", "RET", "LEXER_GRAMMAR", "PARSER_GRAMMAR", "TREE_GRAMMAR", "COMBINED_GRAMMAR", "INITACTION", "LABEL", "TEMPLATE", "\"scope\"", "GATED_SEMPRED", "SYN_SEMPRED", "\"fragment\"", "ACTION", "DOC_COMMENT", "SEMI", "\"lexer\"", "\"tree\"", "\"grammar\"", "AMPERSAND", "COLON", "RCURLY", "ASSIGN", "STRING_LITERAL", "CHAR_LITERAL", "INT", "STAR", "TOKEN_REF", "\"protected\"", "\"public\"", "\"private\"", "BANG", "ARG_ACTION", "\"returns\"", "\"throws\"", "COMMA", "LPAREN", "OR", "RPAREN", "\"exception\"", "\"catch\"", "OPEN_ELEMENT_OPTION", "CLOSE_ELEMENT_OPTION", "PLUS_ASSIGN", "SEMPRED", "IMPLIES", "NOT", "TREE_BEGIN", "QUESTION", "PLUS", "RULE_REF", "WILDCARD", "ROOT", "RULEROOT", "REWRITE", "DOLLAR", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "WS", "COMMENT", "SL_COMMENT", "ML_COMMENT", "ESC", "DIGIT", "XDIGIT", "NESTED_ARG_ACTION", "NESTED_ACTION", "ACTION_CHAR_LITERAL", "ACTION_STRING_LITERAL", "ACTION_ESC", "WS_LOOP", "INTERNAL_RULE_REF", "WS_OPT", "SRC" }; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -