Dispatch accept() for terminal nodes to visitor

This commit is contained in:
Sam Harwell 2012-03-03 21:57:08 -06:00
parent 0375f8318a
commit 80b3ec8c62
1 changed files with 8 additions and 1 deletions

View File

@ -80,7 +80,9 @@ public interface ParseTree extends SyntaxTree {
public int getChildCount() { return 0; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) { return null; }
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
return visitor.visitTerminal(this);
}
@Override
public String toStringTree(Parser parser) {
@ -117,6 +119,11 @@ public interface ParseTree extends SyntaxTree {
public ErrorNodeImpl(Symbol token) {
super(token);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
return visitor.visitErrorNode(this);
}
}
// the following methods narrow the return type; they are not additional methods