📄 antlrtreeprinter.java
字号:
out(id2.getText()+"+="); atom(_t); _t = _retTree; _t = __t109; _t = _t.getNextSibling(); break; } case BLOCK: case OPTIONAL: case CLOSURE: case POSITIVE_CLOSURE: { ebnf(_t); _t = _retTree; break; } case TREE_BEGIN: { tree(_t); _t = _retTree; break; } case SYNPRED: { AST __t110 = _t; GrammarAST tmp18_AST_in = (GrammarAST)_t; match(_t,SYNPRED); _t = _t.getFirstChild(); block(_t,true); _t = _retTree; _t = __t110; _t = _t.getNextSibling(); out("=>"); break; } case ACTION: { a = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); if ( showActions ) {out("{"); out(a.getText()); out("}");} break; } case SEMPRED: { pred = (GrammarAST)_t; match(_t,SEMPRED); _t = _t.getNextSibling(); if ( showActions ) {out("{"); out(pred.getText()); out("}?");} else {out("{...}?");} break; } case SYN_SEMPRED: { spred = (GrammarAST)_t; match(_t,SYN_SEMPRED); _t = _t.getNextSibling(); String name = spred.getText(); GrammarAST predAST=grammar.getSyntacticPredicate(name); block(predAST, true); out("=>"); break; } case GATED_SEMPRED: { gpred = (GrammarAST)_t; match(_t,GATED_SEMPRED); _t = _t.getNextSibling(); if ( showActions ) {out("{"); out(gpred.getText()); out("}? =>");} else {out("{...}? =>");} break; } case EPSILON: { GrammarAST tmp19_AST_in = (GrammarAST)_t; match(_t,EPSILON); _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 single_rewrite(AST _t) throws RecognitionException { GrammarAST single_rewrite_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t88 = _t; GrammarAST tmp20_AST_in = (GrammarAST)_t; match(_t,REWRITE); _t = _t.getFirstChild(); out(" ->"); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case SEMPRED: { GrammarAST tmp21_AST_in = (GrammarAST)_t; match(_t,SEMPRED); _t = _t.getNextSibling(); out(" {"+tmp21_AST_in.getText()+"}?"); break; } case ALT: case TEMPLATE: case ACTION: { break; } default: { throw new NoViableAltException(_t); } } } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ALT: { alternative(_t); _t = _retTree; break; } case TEMPLATE: { rewrite_template(_t); _t = _retTree; break; } case ACTION: { GrammarAST tmp22_AST_in = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); out(" {"+tmp22_AST_in.getText()+"}"); break; } default: { throw new NoViableAltException(_t); } } } _t = __t88; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void grammarSpec(AST _t, String gtype ) throws RecognitionException { GrammarAST grammarSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; GrammarAST cmt = null; try { // for error handling id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); out(gtype+"grammar "+id.getText()); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case DOC_COMMENT: { cmt = (GrammarAST)_t; match(_t,DOC_COMMENT); _t = _t.getNextSibling(); out(cmt.getText()+"\n"); break; } case OPTIONS: case TOKENS: case RULE: case SCOPE: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { optionsSpec(_t); _t = _retTree; break; } case TOKENS: case RULE: case SCOPE: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } out(";\n"); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case TOKENS: { tokensSpec(_t); _t = _retTree; break; } case RULE: case SCOPE: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } { _loop16: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==SCOPE)) { attrScope(_t); _t = _retTree; } else { break _loop16; } } while (true); } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case AMPERSAND: { actions(_t); _t = _retTree; break; } case RULE: { break; } default: { throw new NoViableAltException(_t); } } } rules(_t); _t = _retTree; } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void attrScope(AST _t) throws RecognitionException { GrammarAST attrScope_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t10 = _t; GrammarAST tmp23_AST_in = (GrammarAST)_t; match(_t,SCOPE); _t = _t.getFirstChild(); GrammarAST tmp24_AST_in = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); GrammarAST tmp25_AST_in = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); _t = __t10; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void optionsSpec(AST _t) throws RecognitionException { GrammarAST optionsSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t25 = _t; GrammarAST tmp26_AST_in = (GrammarAST)_t; match(_t,OPTIONS); _t = _t.getFirstChild(); out(" options {"); { int _cnt27=0; _loop27: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ASSIGN)) { option(_t); _t = _retTree; out("; "); } else { if ( _cnt27>=1 ) { break _loop27; } else {throw new NoViableAltException(_t);} } _cnt27++; } while (true); } out("} "); _t = __t25; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void tokensSpec(AST _t) throws RecognitionException { GrammarAST tokensSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling AST __t32 = _t; GrammarAST tmp27_AST_in = (GrammarAST)_t; match(_t,TOKENS); _t = _t.getFirstChild(); { int _cnt34=0; _loop34: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ASSIGN||_t.getType()==TOKEN_REF)) { tokenSpec(_t); _t = _retTree; } else { if ( _cnt34>=1 ) { break _loop34; } else {throw new NoViableAltException(_t);} } _cnt34++; } while (true); } _t = __t32; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void actions(AST _t) throws RecognitionException { GrammarAST actions_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling { int _cnt20=0; _loop20: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==AMPERSAND)) { action(_t); _t = _retTree; } else { if ( _cnt20>=1 ) { break _loop20; } else {throw new NoViableAltException(_t);} } _cnt20++; } while (true); } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void rules(AST _t) throws RecognitionException { GrammarAST rules_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling { int _cnt40=0; _loop40: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==RULE)) { rule(_t); _t = _retTree; } else { if ( _cnt40>=1 ) { break _loop40; } else {throw new NoViableAltException(_t);} } _cnt40++; } while (true); } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void action(AST _t) throws RecognitionException { GrammarAST action_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id1 = null; GrammarAST id2 = null; GrammarAST a1 = null; GrammarAST a2 = null; String scope=null, name=null; String action=null; try { // for error handling AST __t22 = _t; GrammarAST tmp28_AST_in = (GrammarAST)_t; match(_t,AMPERSAND); _t = _t.getFirstChild(); id1 = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ID: { id2 = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); a1 = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); scope=id1.getText(); name=a1.getText(); action=a1.getText(); break; } case ACTION: { a2 = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); scope=null; name=id1.getText(); action=a2.getText(); break; } default: { throw new NoViableAltException(_t); } } } _t = __t22; _t = _t.getNextSibling(); if ( showActions ) { out("@"+(scope!=null?scope+"::":"")+name+action); } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void option(AST _t) throws RecognitionException { GrammarAST option_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; try { // for error handling AST __t29 = _t; GrammarAST tmp29_AST_in = (GrammarAST)_t; match(_t,ASSIGN); _t = _t.getFirstChild(); id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); out(id.getText()+"="); optionValue(_t); _t = _retTree; _t = __t29; _t = _t.getNextSibling(); } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void optionValue(AST _t) throws RecognitionException { GrammarAST optionValue_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; GrammarAST s = null; GrammarAST c = null; GrammarAST i = null; try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ID: { id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); out(id.getText()); break; } case STRING_LITERAL: { s = (GrammarAST)_t; match(_t,STRING_LITERAL); _t = _t.getNextSibling(); out(s.getText()); break; } case CHAR_LITERAL: { c = (GrammarAST)_t; match(_t,CHAR_LITERAL); _t = _t.getNextSibling(); out(c.getText()); break; } case INT: { i = (GrammarAST)_t; match(_t,INT); _t = _t.getNextSibling(); out(i.getText()); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } _retTree = _t; } public final void tokenSpec(AST _t) throws RecognitionException { GrammarAST tokenSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case TOKEN_REF: { GrammarAST tmp30_AST_in = (GrammarAST)_t; match(_t,TOKEN_REF); _t = _t.getNextSibling(); break; } case ASSIGN: { AST __t36 = _t; GrammarAST tmp31_AST_in = (GrammarAST)_t;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -