forked from jasder/antlr
Since ASTLabelType=GrammarAST, construct CommonTreeNodeStream with GrammarASTAdaptor to make sure UP/DOWN nodes cannot result in a ClassCastException
This commit is contained in:
parent
669f676c55
commit
05fb538304
|
@ -96,7 +96,7 @@ public ErrorManager getErrorManager() { return null; }
|
|||
|
||||
public void visitGrammar(GrammarAST t) { visit(t, "grammarSpec"); }
|
||||
public void visit(GrammarAST t, String ruleName) {
|
||||
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
|
||||
CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), t);
|
||||
setTreeNodeStream(nodes);
|
||||
try {
|
||||
Method m = getClass().getMethod(ruleName);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
package org.antlr.v4.tool;
|
||||
|
||||
import org.antlr.runtime.CommonToken;
|
||||
import org.antlr.runtime.tree.CommonTreeNodeStream;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
import org.antlr.runtime.tree.TreeVisitor;
|
||||
import org.antlr.runtime.tree.TreeVisitorAction;
|
||||
|
@ -76,8 +77,7 @@ public class GrammarTransformPipeline {
|
|||
}
|
||||
|
||||
public void reduceBlocksToSets(GrammarAST root) {
|
||||
org.antlr.runtime.tree.CommonTreeNodeStream nodes =
|
||||
new org.antlr.runtime.tree.CommonTreeNodeStream(root);
|
||||
CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
|
||||
GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
|
||||
BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
|
||||
transformer.setTreeAdaptor(adaptor);
|
||||
|
|
Loading…
Reference in New Issue