Trees

@uml A set of utility routines useful for all kinds of ANTLR trees

Members

Static functions

_findAllNodes
void _findAllNodes(ParseTree t, int index, bool findTokens, ParseTree[] nodes)
Undocumented in source. Be warned that the author may not have intended to support it.
descendants
ParseTree[] descendants(ParseTree t)
Undocumented in source. Be warned that the author may not have intended to support it.
findAllNodes
ParseTree[] findAllNodes(ParseTree t, int index, bool findTokens)
Undocumented in source. Be warned that the author may not have intended to support it.
findAllRuleNodes
ParseTree[] findAllRuleNodes(ParseTree t, int ruleIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
findAllTokenNodes
ParseTree[] findAllTokenNodes(ParseTree t, int ttype)
Undocumented in source. Be warned that the author may not have intended to support it.
findNodeSuchThat
Tree findNodeSuchThat(Tree t, Predicate!Tree pred)

@uml Return first node satisfying the pred

getAncestors
Tree[] getAncestors(Tree t)

@uml Return a list of all ancestors of this node. The first node of list is the root and the last is the parent of this node.

getChildren
Tree[] getChildren(Tree t)

@uml Return ordered list of all children of this node

getDescendants
ParseTree[] getDescendants(ParseTree t)

@uml Get all descendents; includes t itself.

getNodeText
string getNodeText(Tree t, InterfaceRecognizer recog)
Undocumented in source. Be warned that the author may not have intended to support it.
getNodeText
string getNodeText(Tree t, string[] ruleNames)
Undocumented in source. Be warned that the author may not have intended to support it.
getRootOfSubtreeEnclosingRegion
ParserRuleContext getRootOfSubtreeEnclosingRegion(ParseTree t, int startTokenIndex, int stopTokenIndex)

@uml Find smallest subtree of t enclosing range startTokenIndex..stopTokenIndex inclusively using postorder traversal. Recursive depth-first-search.

isAncestorOf
bool isAncestorOf(Tree t, Tree u)

@uml Return true if t is u's parent or a node on path to root from u. Use == not equals().

stripChildrenOutOfRange
void stripChildrenOutOfRange(ParserRuleContext t, ParserRuleContext root, int startIndex, int stopIndex)

@uml Replace any subtree siblings of root that are completely to left or right of lookahead range with a CommonToken(Token.INVALID_TYPE,"...") node. The source interval for t is not altered to suit smaller range!

toStringTree
string toStringTree(Tree t)

@uml Print out a whole tree in LISP form. {@link #getNodeText} is used on the node payloads to get the text for the nodes. Detect parse trees and extract data appropriately.

toStringTree
string toStringTree(Tree t, InterfaceRecognizer recog)

@uml Print out a whole tree in LISP form. {@link #getNodeText} is used on the node payloads to get the text for the nodes. Detect parse trees and extract data appropriately.

toStringTree
string toStringTree(Tree t, string[] ruleNames)

@uml Print out a whole tree in LISP form. {@link #getNodeText} is used on the node payloads to get the text for the nodes.

Meta