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 visitGrammar(GrammarAST t) { visit(t, "grammarSpec"); }
|
||||||
public void visit(GrammarAST t, String ruleName) {
|
public void visit(GrammarAST t, String ruleName) {
|
||||||
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
|
CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), t);
|
||||||
setTreeNodeStream(nodes);
|
setTreeNodeStream(nodes);
|
||||||
try {
|
try {
|
||||||
Method m = getClass().getMethod(ruleName);
|
Method m = getClass().getMethod(ruleName);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
package org.antlr.v4.tool;
|
package org.antlr.v4.tool;
|
||||||
|
|
||||||
import org.antlr.runtime.CommonToken;
|
import org.antlr.runtime.CommonToken;
|
||||||
|
import org.antlr.runtime.tree.CommonTreeNodeStream;
|
||||||
import org.antlr.runtime.tree.Tree;
|
import org.antlr.runtime.tree.Tree;
|
||||||
import org.antlr.runtime.tree.TreeVisitor;
|
import org.antlr.runtime.tree.TreeVisitor;
|
||||||
import org.antlr.runtime.tree.TreeVisitorAction;
|
import org.antlr.runtime.tree.TreeVisitorAction;
|
||||||
|
@ -76,8 +77,7 @@ public class GrammarTransformPipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reduceBlocksToSets(GrammarAST root) {
|
public void reduceBlocksToSets(GrammarAST root) {
|
||||||
org.antlr.runtime.tree.CommonTreeNodeStream nodes =
|
CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
|
||||||
new org.antlr.runtime.tree.CommonTreeNodeStream(root);
|
|
||||||
GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
|
GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
|
||||||
BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
|
BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
|
||||||
transformer.setTreeAdaptor(adaptor);
|
transformer.setTreeAdaptor(adaptor);
|
||||||
|
|
Loading…
Reference in New Issue