📄 definegrammaritemswalker.java
字号:
{ throw new NoViableAltException(_t); } } } _t = __t28; _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final void rule(AST _t) throws RecognitionException { GrammarAST rule_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; GrammarAST args = null; GrammarAST ret = null; GrammarAST b = null; String mod=null; String name=null; Map opts=null; Rule r = null; try { // for error handling AST __t34 = _t; GrammarAST tmp9_AST_in = (GrammarAST)_t; match(_t,RULE); _t = _t.getFirstChild(); id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { opts = tmp9_AST_in.options; } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case FRAGMENT: case LITERAL_protected: case LITERAL_public: case LITERAL_private: { mod=modifier(_t); _t = _retTree; break; } case ARG: { break; } default: { throw new NoViableAltException(_t); } } } AST __t36 = _t; GrammarAST tmp10_AST_in = (GrammarAST)_t; match(_t,ARG); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ARG_ACTION: { args = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t36; _t = _t.getNextSibling(); AST __t38 = _t; GrammarAST tmp11_AST_in = (GrammarAST)_t; match(_t,RET); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ARG_ACTION: { ret = (GrammarAST)_t; match(_t,ARG_ACTION); _t = _t.getNextSibling(); break; } case 3: { break; } default: { throw new NoViableAltException(_t); } } } _t = __t38; _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { optionsSpec(_t); _t = _retTree; break; } case BLOCK: case SCOPE: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } if ( inputState.guessing==0 ) { name = id.getText(); currentRuleName = name; if ( Character.isUpperCase(name.charAt(0)) && grammar.type==Grammar.COMBINED ) { // a merged grammar spec, track lexer rules and send to another grammar grammar.defineLexerRuleFoundInParser(id.getToken(), rule_AST_in); } else { int numAlts = countAltsForRule(rule_AST_in); grammar.defineRule(id.getToken(), mod, opts, rule_AST_in, args, numAlts); r = grammar.getRule(name); if ( args!=null ) { r.parameterScope = grammar.createParameterScope(name,args.token); r.parameterScope.addAttributes(args.getText(), ","); } if ( ret!=null ) { r.returnScope = grammar.createReturnScope(name,ret.token); r.returnScope.addAttributes(ret.getText(), ","); } } } { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case SCOPE: { ruleScopeSpec(_t,r); _t = _retTree; break; } case BLOCK: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } { _loop43: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==AMPERSAND)) { ruleAction(_t,r); _t = _retTree; } else { break _loop43; } } while (true); } if ( inputState.guessing==0 ) { this.blockLevel=0; } b = _t==ASTNULL ? null : (GrammarAST)_t; block(_t); _t = _retTree; { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case LITERAL_exception: { exceptionGroup(_t); _t = _retTree; break; } case EOR: { break; } default: { throw new NoViableAltException(_t); } } } GrammarAST tmp12_AST_in = (GrammarAST)_t; match(_t,EOR); _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { // copy rule options into the block AST, which is where // the analysis will look for k option etc... b.options = opts; } _t = __t34; _t = _t.getNextSibling(); } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final String modifier(AST _t) throws RecognitionException { String mod; GrammarAST modifier_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; mod = modifier_AST_in.getText(); try { // for error handling if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case LITERAL_protected: { GrammarAST tmp13_AST_in = (GrammarAST)_t; match(_t,LITERAL_protected); _t = _t.getNextSibling(); break; } case LITERAL_public: { GrammarAST tmp14_AST_in = (GrammarAST)_t; match(_t,LITERAL_public); _t = _t.getNextSibling(); break; } case LITERAL_private: { GrammarAST tmp15_AST_in = (GrammarAST)_t; match(_t,LITERAL_private); _t = _t.getNextSibling(); break; } case FRAGMENT: { GrammarAST tmp16_AST_in = (GrammarAST)_t; match(_t,FRAGMENT); _t = _t.getNextSibling(); break; } default: { throw new NoViableAltException(_t); } } } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; return mod; } public final void ruleScopeSpec(AST _t, Rule r ) throws RecognitionException { GrammarAST ruleScopeSpec_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST attrs = null; GrammarAST uses = null; try { // for error handling AST __t63 = _t; GrammarAST tmp17_AST_in = (GrammarAST)_t; match(_t,SCOPE); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case ACTION: { attrs = (GrammarAST)_t; match(_t,ACTION); _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { r.ruleScope = grammar.createRuleScope(r.name,attrs.token); r.ruleScope.isDynamicRuleScope = true; r.ruleScope.addAttributes(attrs.getText(), ";"); } break; } case 3: case ID: { break; } default: { throw new NoViableAltException(_t); } } } { _loop66: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ID)) { uses = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { if ( grammar.getGlobalScope(uses.getText())==null ) { ErrorManager.grammarError(ErrorManager.MSG_UNKNOWN_DYNAMIC_SCOPE, grammar, uses.token, uses.getText()); } else { if ( r.useScopes==null ) {r.useScopes=new ArrayList();} r.useScopes.add(uses.getText()); } } } else { break _loop66; } } while (true); } _t = __t63; _t = _t.getNextSibling(); } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final void ruleAction(AST _t, Rule r ) throws RecognitionException { GrammarAST ruleAction_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST amp = null; GrammarAST id = null; GrammarAST a = null; try { // for error handling AST __t60 = _t; amp = _t==ASTNULL ? null :(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 = __t60; _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { if (r!=null) r.defineAction(amp,id,a); } } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final void block(AST _t) throws RecognitionException { GrammarAST block_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; this.blockLevel++; if ( this.blockLevel==1 ) {this.outerAltNum=1;} try { // for error handling AST __t68 = _t; GrammarAST tmp18_AST_in = (GrammarAST)_t; match(_t,BLOCK); _t = _t.getFirstChild(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { optionsSpec(_t); _t = _retTree; break; } case ALT: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } { _loop71: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==AMPERSAND)) { blockAction(_t); _t = _retTree; } else { break _loop71; } } while (true); } { int _cnt73=0; _loop73: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==ALT)) { alternative(_t); _t = _retTree; rewrite(_t); _t = _retTree; if ( inputState.guessing==0 ) { if ( this.blockLevel==1 ) {this.outerAltNum++;} } } else { if ( _cnt73>=1 ) { break _loop73; } else {throw new NoViableAltException(_t);} } _cnt73++; } while (true); } GrammarAST tmp19_AST_in = (GrammarAST)_t; match(_t,EOB); _t = _t.getNextSibling(); _t = __t68; _t = _t.getNextSibling(); if ( inputState.guessing==0 ) { this.blockLevel--; } } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final void exceptionGroup(AST _t) throws RecognitionException { GrammarAST exceptionGroup_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; try { // for error handling { int _cnt82=0; _loop82: do { if (_t==null) _t=ASTNULL; if ((_t.getType()==LITERAL_exception)) { exceptionSpec(_t); _t = _retTree; } else { if ( _cnt82>=1 ) { break _loop82; } else {throw new NoViableAltException(_t);} } _cnt82++; } while (true); } } catch (RecognitionException ex) { if (inputState.guessing==0) { reportError(ex); if (_t!=null) {_t = _t.getNextSibling();} } else { throw ex; } } _retTree = _t; } public final int countAltsForRule(AST _t) throws RecognitionException { int n=0; GrammarAST countAltsForRule_AST_in = (_t == ASTNULL) ? null : (GrammarAST)_t; GrammarAST id = null; try { // for error handling AST __t46 = _t; GrammarAST tmp20_AST_in = (GrammarAST)_t; match(_t,RULE); _t = _t.getFirstChild(); id = (GrammarAST)_t; match(_t,ID); _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case FRAGMENT: case LITERAL_protected: case LITERAL_public: case LITERAL_private: { modifier(_t); _t = _retTree; break; } case ARG: { break; } default: { throw new NoViableAltException(_t); } } } GrammarAST tmp21_AST_in = (GrammarAST)_t; match(_t,ARG); _t = _t.getNextSibling(); GrammarAST tmp22_AST_in = (GrammarAST)_t; match(_t,RET); _t = _t.getNextSibling(); { if (_t==null) _t=ASTNULL; switch ( _t.getType()) { case OPTIONS: { GrammarAST tmp23_AST_in = (GrammarAST)_t; match(_t,OPTIONS); _t = _t.getNextSibling(); break; } case BLOCK: case SCOPE: case AMPERSAND: { break; } default: { throw new NoViableAltException(_t); } } } {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -