1 /* 2 * Copyright (c) 2012-2018 The ANTLR Project. All rights reserved. 3 * Use of this file is governed by the BSD 3-clause license that 4 * can be found in the LICENSE.txt file in the project root. 5 */ 6 7 module antlr.v4.runtime.tree.ParseTree; 8 9 import antlr.v4.runtime.InterfaceRecognizer; 10 import antlr.v4.runtime.RuleContext : RuleContext; 11 import antlr.v4.runtime.tree.SyntaxTree; 12 13 /** 14 * An interface to access the tree of {@link RuleContext} objects created 15 * * during a parse that makes the data structure look like a simple parse tree. 16 * This node represents both internal nodes, rule invocations, 17 * and leaf nodes, token matches. 18 * 19 * <p>The payload is either a {@link Token} or a {@link RuleContext} object.</p> 20 */ 21 interface ParseTree : SyntaxTree 22 { 23 24 /** 25 * @uml 26 * @override 27 */ 28 public override ParseTree getParent(); 29 30 public void setParent(RuleContext parent); 31 32 /** 33 * @uml 34 * @override 35 */ 36 public override ParseTree getChild(int i); 37 38 /** 39 * The {@link ParseTreeVisitor} needs a double dispatch method. 40 */ 41 public T accept(T)(ParseTreeVisitor!U visitor); 42 43 /** 44 * Return the combined text of all leaf nodes. Does not get any 45 * off-channel tokens (if any) so won't return whitespace and 46 * comments if they are sent to parser on hidden channel. 47 */ 48 public string getText(); 49 50 /** 51 * Specialize toStringTree so that it can print out more information 52 * based upon the parser. 53 */ 54 public string toStringTree(InterfaceRecognizer parser); 55 56 }