forked from jasder/antlr
Rerun semantic checks on rule produced by LR transform
This commit is contained in:
parent
97f23097d0
commit
0f69799b08
|
@ -43,6 +43,8 @@ import org.antlr.v4.parse.GrammarASTAdaptor;
|
|||
import org.antlr.v4.parse.ScopeParser;
|
||||
import org.antlr.v4.parse.ToolANTLRParser;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.semantics.BasicSemanticChecks;
|
||||
import org.antlr.v4.semantics.RuleCollector;
|
||||
import org.antlr.v4.tool.AttributeDict;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
|
@ -141,6 +143,12 @@ public class LeftRecursiveRuleTransformer {
|
|||
transform.reduceBlocksToSets(r.ast);
|
||||
transform.expandParameterizedLoops(r.ast);
|
||||
|
||||
// Rerun semantic checks on the new rule
|
||||
RuleCollector ruleCollector = new RuleCollector(g);
|
||||
ruleCollector.visit(t, "rule");
|
||||
BasicSemanticChecks basics = new BasicSemanticChecks(g, ruleCollector);
|
||||
basics.visit(t, "rule");
|
||||
|
||||
// track recursive alt info for codegen
|
||||
r.recPrimaryAlts = new ArrayList<LeftRecursiveRuleAltInfo>();
|
||||
r.recPrimaryAlts.addAll(leftRecursiveRuleWalker.prefixAlts);
|
||||
|
|
Loading…
Reference in New Issue