rm need for isRuleContext in templates; refer to underlying grammar object.

This commit is contained in:
parrt 2016-11-05 06:28:58 -07:00
parent 85f2a87840
commit e0521400cb
2 changed files with 3 additions and 5 deletions

View File

@ -276,7 +276,7 @@ func (l *<lexer.name>) Action(localctx antlr.RuleContext, ruleIndex, actionIndex
switch ruleIndex { switch ruleIndex {
<if(recog.actionFuncs.values)> <if(recog.actionFuncs.values)>
<recog.actionFuncs.values:{f | case <f.ruleIndex>: <recog.actionFuncs.values:{f | case <f.ruleIndex>:
<if(f.isRuleContext)> <if(f.factory.grammar.lexer)>
l.<f.name>_Action(localctx, actionIndex) l.<f.name>_Action(localctx, actionIndex)
<else> <else>
var t *<f.name; format="cap">Context = nil var t *<f.name; format="cap">Context = nil
@ -304,7 +304,7 @@ func (l *<lexer.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex
switch ruleIndex { switch ruleIndex {
<if(recog.sempredFuncs.values)> <if(recog.sempredFuncs.values)>
<recog.sempredFuncs.values:{f | case <f.ruleIndex>: <recog.sempredFuncs.values:{f | case <f.ruleIndex>:
<if(f.isRuleContext)> <if(f.factory.grammar.lexer)>
return l.<f.name>_Sempred(localctx, predIndex) return l.<f.name>_Sempred(localctx, predIndex)
<else> <else>
var t *<f.name; format="cap">Context = nil var t *<f.name; format="cap">Context = nil
@ -330,7 +330,7 @@ func (l *<lexer.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex
* overriding implementation impossible to maintain. * overriding implementation impossible to maintain.
*/ */
RuleActionFunction(r, actions) ::= << RuleActionFunction(r, actions) ::= <<
func (l *<lexer.name>) <r.name; format="cap">_Action(localctx <if(r.isRuleContext)>antlr.RuleContext<else>*<r.ctxType><endif>, actionIndex int) { func (l *<lexer.name>) <r.name; format="cap">_Action(localctx <if(r.factory.grammar.lexer)>antlr.RuleContext<else>*<r.ctxType><endif>, actionIndex int) {
switch actionIndex { switch actionIndex {
<if(actions)> <if(actions)>
<actions:{index | case <index>: <actions:{index | case <index>:

View File

@ -38,7 +38,6 @@ import java.util.LinkedHashMap;
public class RuleActionFunction extends OutputModelObject { public class RuleActionFunction extends OutputModelObject {
public String name; public String name;
public String ctxType; public String ctxType;
public boolean isRuleContext;
public int ruleIndex; public int ruleIndex;
/** Map actionIndex to Action */ /** Map actionIndex to Action */
@ -49,7 +48,6 @@ public class RuleActionFunction extends OutputModelObject {
super(factory); super(factory);
name = r.name; name = r.name;
ruleIndex = r.index; ruleIndex = r.index;
isRuleContext = ctxType.equals("RuleContext");
this.ctxType = ctxType; this.ctxType = ctxType;
} }
} }