Parse Trees
Interface Tree defines the basic notion of a tree that has a payload and children. A SyntaxTree is a tree that knows how to associate tree nodes with tokens in a TokenStream. Getting more specific, interface ParseTree represents a node in a parse tree. It knows how to return the text associated with all leaf nodes below it in the tree. We saw sample parse trees in Building Language Applications Using Parse Trees, and how the nodes correspond to the types in this class hierarchy. ParseTree also provides the usual visitor pattern double-dispatch accept method for ParseTreeVisitor, which we looked at in Parse-Tree Listeners and Visitors.
Classes RuleNode and TerminalNode correspond to subtree roots and leaf nodes. ANTLR creates ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access