diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java b/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java index 0622c3892..0f4583a4d 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/RuleContext.java @@ -34,6 +34,7 @@ import org.antlr.v4.runtime.misc.Nullable; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTreeVisitor; import org.antlr.v4.runtime.tree.RuleNode; +import org.antlr.v4.runtime.tree.Tree; import org.antlr.v4.runtime.tree.Trees; import org.antlr.v4.runtime.tree.gui.TreeViewer; @@ -59,7 +60,7 @@ import java.util.concurrent.Future; * getting error information. * * These objects are used during parsing and prediction. - * For the special case of parsers and tree parsers, we use the subclass + * For the special case of parsers, we use the subclass * ParserRuleContext. * * @see ParserRuleContext @@ -150,6 +151,11 @@ public class RuleContext implements RuleNode { return 0; } + @Override + public List getChildren() { + return null; + } + @Override public T accept(ParseTreeVisitor visitor) { return visitor.visitChildren(this); } diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java index 05e26306e..3fdd4e124 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/TerminalNodeImpl.java @@ -34,6 +34,8 @@ import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.misc.Interval; +import java.util.List; + public class TerminalNodeImpl implements TerminalNode { public Token symbol; public ParseTree parent; @@ -63,6 +65,11 @@ public class TerminalNodeImpl implements TerminalNode { @Override public int getChildCount() { return 0; } + @Override + public List getChildren() { + return null; + } + @Override public T accept(ParseTreeVisitor visitor) { return visitor.visitTerminal(this); diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java b/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java index 119dbee7c..8f1ec38a2 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java @@ -33,6 +33,9 @@ package org.antlr.v4.runtime.tree; import org.antlr.v4.runtime.RuleContext; import org.antlr.v4.runtime.Token; +import java.util.Collection; +import java.util.List; + /** The basic notion of a tree has a parent, a payload, and a list of children. * It is the most abstract interface for all the trees used by ANTLR. */ @@ -59,6 +62,9 @@ public interface Tree { */ int getChildCount(); + /** Return ordered list of all children of this node */ + List getChildren(); + /** Print out a whole tree, not just a node, in LISP format * {@code (root child1 .. childN)}. Print just a node if this is a leaf. */