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 {
<if(recog.actionFuncs.values)>
<recog.actionFuncs.values:{f | case <f.ruleIndex>:
<if(f.isRuleContext)>
<if(f.factory.grammar.lexer)>
l.<f.name>_Action(localctx, actionIndex)
<else>
var t *<f.name; format="cap">Context = nil
@ -304,7 +304,7 @@ func (l *<lexer.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex
switch ruleIndex {
<if(recog.sempredFuncs.values)>
<recog.sempredFuncs.values:{f | case <f.ruleIndex>:
<if(f.isRuleContext)>
<if(f.factory.grammar.lexer)>
return l.<f.name>_Sempred(localctx, predIndex)
<else>
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.
*/
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 {
<if(actions)>
<actions:{index | case <index>:

View File

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