📄 actiontranslatorlexer.java
字号:
// $ANTLR end SET_RULE_SCOPE_ATTR // $ANTLR start RULE_SCOPE_ATTR public void mRULE_SCOPE_ATTR() throws RecognitionException { try { ruleNestingLevel++; int _type = RULE_SCOPE_ATTR; int _start = getCharIndex(); int _line = getLine(); int _charPosition = getCharPositionInLine(); int _channel = Token.DEFAULT_CHANNEL; Grammar.LabelElementPair pair=null; String refdRuleName=null; // ActionTranslator.g:366:4: ( '$' x= ID '.' y= ID {...}?{...}?) // ActionTranslator.g:366:4: '$' x= ID '.' y= ID {...}?{...}? { match('$'); if (failed) return ; int xStart = getCharIndex(); mID(); if (failed) return ; Token x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart, getCharIndex()-1); match('.'); if (failed) return ; int yStart = getCharIndex(); mID(); if (failed) return ; Token y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart, getCharIndex()-1); if ( !(enclosingRule!=null) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "RULE_SCOPE_ATTR", "enclosingRule!=null"); } if ( backtracking==1 ) { pair = enclosingRule.getRuleLabel(x.getText()); refdRuleName = x.getText(); if ( pair!=null ) { refdRuleName = pair.referencedRuleName; } } if ( !((enclosingRule.getRuleLabel(x.getText())!=null || isRuleRefInAlt(x.getText())) && getRuleLabelAttribute(enclosingRule.getRuleLabel(x.getText())!=null?enclosingRule.getRuleLabel(x.getText()).referencedRuleName:x.getText(),y.getText())!=null) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "RULE_SCOPE_ATTR", "(enclosingRule.getRuleLabel($x.text)!=null || isRuleRefInAlt($x.text)) &&\n\t getRuleLabelAttribute(enclosingRule.getRuleLabel($x.text)!=null?enclosingRule.getRuleLabel($x.text).referencedRuleName:$x.text,$y.text)!=null"); } if ( backtracking==1 ) { String label = x.getText(); if ( pair==null ) { // $ruleref.attr gotta get old label or compute new one checkElementRefUniqueness(x.getText(), false); label = enclosingRule.getElementLabel(x.getText(), outerAltNum, generator); if ( label==null ) { ErrorManager.grammarError(ErrorManager.MSG_FORWARD_ELEMENT_REF, grammar, actionToken, "$"+x.getText()+"."+y.getText()); label = x.getText(); } } StringTemplate st; Rule refdRule = grammar.getRule(refdRuleName); AttributeScope scope = refdRule.getLocalAttributeScope(y.getText()); if ( scope.isPredefinedRuleScope ) { st = template("ruleLabelPropertyRef_"+y.getText()); grammar.referenceRuleLabelPredefinedAttribute(refdRuleName); st.setAttribute("scope", label); st.setAttribute("attr", y.getText()); } else if ( scope.isPredefinedLexerRuleScope ) { st = template("lexerRuleLabelPropertyRef_"+y.getText()); grammar.referenceRuleLabelPredefinedAttribute(refdRuleName); st.setAttribute("scope", label); st.setAttribute("attr", y.getText()); } else if ( scope.isParameterScope ) { // TODO: error! } else { st = template("ruleLabelRef"); st.setAttribute("referencedRule", refdRule); st.setAttribute("scope", label); st.setAttribute("attr", scope.getAttribute(y.getText())); } } } if ( backtracking==1 ) { if ( token==null && ruleNestingLevel==1 ) { emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1); } } } finally { ruleNestingLevel--; } } // $ANTLR end RULE_SCOPE_ATTR // $ANTLR start LABEL_REF public void mLABEL_REF() throws RecognitionException { try { ruleNestingLevel++; int _type = LABEL_REF; int _start = getCharIndex(); int _line = getLine(); int _charPosition = getCharPositionInLine(); int _channel = Token.DEFAULT_CHANNEL; // ActionTranslator.g:424:4: ( '$' ID {...}?) // ActionTranslator.g:424:4: '$' ID {...}? { match('$'); if (failed) return ; int ID1Start = getCharIndex(); mID(); if (failed) return ; Token ID1 = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, ID1Start, getCharIndex()-1); if ( !(enclosingRule!=null && getElementLabel(ID1.getText())!=null && enclosingRule.getRuleLabel(ID1.getText())==null) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "LABEL_REF", "enclosingRule!=null &&\n\t getElementLabel($ID.text)!=null &&\n\t\t enclosingRule.getRuleLabel($ID.text)==null"); } if ( backtracking==1 ) { StringTemplate st; Grammar.LabelElementPair pair = getElementLabel(ID1.getText()); if ( pair.type==Grammar.TOKEN_LABEL ) { st = template("tokenLabelRef"); } else { st = template("listLabelRef"); } st.setAttribute("label", ID1.getText()); } } if ( backtracking==1 ) { if ( token==null && ruleNestingLevel==1 ) { emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1); } } } finally { ruleNestingLevel--; } } // $ANTLR end LABEL_REF // $ANTLR start ISOLATED_TOKEN_REF public void mISOLATED_TOKEN_REF() throws RecognitionException { try { ruleNestingLevel++; int _type = ISOLATED_TOKEN_REF; int _start = getCharIndex(); int _line = getLine(); int _charPosition = getCharPositionInLine(); int _channel = Token.DEFAULT_CHANNEL; // ActionTranslator.g:443:4: ( '$' ID {...}?) // ActionTranslator.g:443:4: '$' ID {...}? { match('$'); if (failed) return ; int ID2Start = getCharIndex(); mID(); if (failed) return ; Token ID2 = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, ID2Start, getCharIndex()-1); if ( !(grammar.type!=Grammar.LEXER && enclosingRule!=null && isTokenRefInAlt(ID2.getText())) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "ISOLATED_TOKEN_REF", "grammar.type!=Grammar.LEXER && enclosingRule!=null && isTokenRefInAlt($ID.text)"); } if ( backtracking==1 ) { String label = enclosingRule.getElementLabel(ID2.getText(), outerAltNum, generator); checkElementRefUniqueness(ID2.getText(), true); if ( label==null ) { ErrorManager.grammarError(ErrorManager.MSG_FORWARD_ELEMENT_REF, grammar, actionToken, ID2.getText()); } else { StringTemplate st = template("tokenLabelRef"); st.setAttribute("label", label); } } } if ( backtracking==1 ) { if ( token==null && ruleNestingLevel==1 ) { emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1); } } } finally { ruleNestingLevel--; } } // $ANTLR end ISOLATED_TOKEN_REF // $ANTLR start ISOLATED_LEXER_RULE_REF public void mISOLATED_LEXER_RULE_REF() throws RecognitionException { try { ruleNestingLevel++; int _type = ISOLATED_LEXER_RULE_REF; int _start = getCharIndex(); int _line = getLine(); int _charPosition = getCharPositionInLine(); int _channel = Token.DEFAULT_CHANNEL; // ActionTranslator.g:463:4: ( '$' ID {...}?) // ActionTranslator.g:463:4: '$' ID {...}? { match('$'); if (failed) return ; int ID3Start = getCharIndex(); mID(); if (failed) return ; Token ID3 = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, ID3Start, getCharIndex()-1); if ( !(grammar.type==Grammar.LEXER && enclosingRule!=null && isRuleRefInAlt(ID3.getText())) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "ISOLATED_LEXER_RULE_REF", "grammar.type==Grammar.LEXER &&\n\t enclosingRule!=null &&\n\t isRuleRefInAlt($ID.text)"); } if ( backtracking==1 ) { String label = enclosingRule.getElementLabel(ID3.getText(), outerAltNum, generator); checkElementRefUniqueness(ID3.getText(), false); if ( label==null ) { ErrorManager.grammarError(ErrorManager.MSG_FORWARD_ELEMENT_REF, grammar, actionToken, ID3.getText()); } else { StringTemplate st = template("lexerRuleLabel"); st.setAttribute("label", label); } } } if ( backtracking==1 ) { if ( token==null && ruleNestingLevel==1 ) { emit(_type,_line,_charPosition,_channel,_start,getCharIndex()-1); } } } finally { ruleNestingLevel--; } } // $ANTLR end ISOLATED_LEXER_RULE_REF // $ANTLR start SET_LOCAL_ATTR public void mSET_LOCAL_ATTR() throws RecognitionException { try { ruleNestingLevel++; int _type = SET_LOCAL_ATTR; int _start = getCharIndex(); int _line = getLine(); int _charPosition = getCharPositionInLine(); int _channel = Token.DEFAULT_CHANNEL; // ActionTranslator.g:495:4: ( '$' ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' {...}?) // ActionTranslator.g:495:4: '$' ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' {...}? { match('$'); if (failed) return ; int ID4Start = getCharIndex(); mID(); if (failed) return ; Token ID4 = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, ID4Start, getCharIndex()-1); // ActionTranslator.g:495:11: ( WS )? int alt4=2; int LA4_0 = input.LA(1); if ( ((LA4_0>='\t' && LA4_0<='\n')||LA4_0==' ') ) { alt4=1; } switch (alt4) { case 1 : // ActionTranslator.g:495:11: WS { mWS(); if (failed) return ; } break; } match('='); if (failed) return ; int exprStart = getCharIndex(); mATTR_VALUE_EXPR(); if (failed) return ; Token expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart, getCharIndex()-1); match(';'); if (failed) return ; if ( !(enclosingRule!=null && enclosingRule.getLocalAttributeScope(ID4.getText())!=null && !enclosingRule.getLocalAttributeScope(ID4.getText()).isPredefinedLexerRuleScope) ) { if (backtracking>0) {failed=true; return ;} throw new FailedPredicateException(input, "SET_LOCAL_ATTR", "enclosingRule!=null\n\t\t\t\t\t\t\t\t\t\t\t\t\t&& enclosingRule.getLocalAttributeScope($ID.text)!=null\n\t\t\t\t\t\t\t\t\t\t\t\t\t&& !enclosingRule.getLocalAttributeScope($ID.text).isPredefinedLexerRuleScope"); } if ( backtracking==1 ) { StringTemplate st; AttributeScope scope = enclosingRule.getLocalAttributeScope(ID4.getText()); if ( scope.isPredefinedRuleScope ) { if (ID4.getText().equals("tree") || ID4.getText().equals("st")) { st = template("ruleSetPropertyRef_"+ID4.getText()); grammar.referenceRuleLabelPredefinedAttribute(enclosingRule.name); st.setAttribute("scope", enclosingRule.name); st.setAttribute("attr", ID4.getText()); st.setAttribute("expr", translateAction(expr.getText())); } else { ErrorManager.grammarError(ErrorManager.MSG_WRITE_TO_READONLY_ATTR, grammar, actionToken, ID4.getText(),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -