rename visit->walk
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9060]
This commit is contained in:
parent
2d234ee28c
commit
62937ca639
|
@ -31,8 +31,8 @@ package org.antlr.v4.runtime.tree;
|
|||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
public class ParseTreeVisitor {
|
||||
public void visit(ParseTreeListener listener, ParseTree t) {
|
||||
public class ParseTreeWalker {
|
||||
public void walk(ParseTreeListener listener, ParseTree t) {
|
||||
if ( t instanceof ParseTree.TokenNode) {
|
||||
visitToken(listener, (ParseTree.TokenNode) t);
|
||||
return;
|
||||
|
@ -41,7 +41,7 @@ public class ParseTreeVisitor {
|
|||
enterRule(listener, r);
|
||||
int n = r.getChildCount();
|
||||
for (int i = 0; i<n; i++) {
|
||||
visit(listener, r.getChild(i));
|
||||
walk(listener, r.getChild(i));
|
||||
}
|
||||
exitRule(listener, r);
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
import org.antlr.v4.runtime.ANTLRFileStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
public class TestT {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -16,7 +14,7 @@ public class TestT {
|
|||
TParser.sContext tree = p.s();
|
||||
System.out.println(tree.toStringTree(p));
|
||||
|
||||
ParseTreeVisitor visitor = new ParseTreeVisitor();
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
TListener listener = new BlankTListener() {
|
||||
public void enterEveryRule(ParserRuleContext ctx) {
|
||||
System.out.println("enter rule "+TParser.ruleNames[ctx.ruleIndex]);
|
||||
|
@ -25,6 +23,6 @@ public class TestT {
|
|||
System.out.println("exit rule s");
|
||||
}
|
||||
};
|
||||
visitor.visit(listener, tree);
|
||||
walker.walk(listener, tree);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.antlr.v4.test;
|
||||
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
import org.antlr.v4.automata.*;
|
||||
import org.antlr.v4.codegen.CodeGenerator;
|
||||
import org.antlr.v4.semantics.SemanticPipeline;
|
||||
import org.antlr.v4.tool.*;
|
||||
import org.junit.Test;
|
||||
import org.stringtemplate.v4.*;
|
||||
|
||||
/** */
|
||||
public class TestActionTranslation extends BaseTest {
|
||||
|
@ -420,7 +423,7 @@ public class TestActionTranslation extends BaseTest {
|
|||
g.atn = factory.createATN();
|
||||
|
||||
CodeGenerator gen = new CodeGenerator(g);
|
||||
ST outputFileST = gen.generateRecognizer();
|
||||
ST outputFileST = gen.generateParser();
|
||||
String output = outputFileST.render();
|
||||
//System.out.println(output);
|
||||
String b = "#" + actionName + "#";
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TestLexerAttributes extends BaseTest {
|
|||
Tool antlr = new Tool();
|
||||
antlr.process(g,false);
|
||||
CodeGenerator gen = new CodeGenerator(g);
|
||||
ST outputFileST = gen.generateRecognizer();
|
||||
ST outputFileST = gen.generateLexer();
|
||||
String output = outputFileST.render();
|
||||
int start = output.indexOf('#');
|
||||
int end = output.lastIndexOf('#');
|
||||
|
|
Loading…
Reference in New Issue