January 2013
Intermediate to advanced
328 pages
8h 5m
English
ANTLR provides support for two tree-walking mechanisms in its runtime library. By default, ANTLR generates a parse-tree listener interface that responds to events triggered by the built-in tree walker. The listeners themselves are exactly like SAX document handler objects for XML parsers. SAX listeners receive notification of events like startDocument and endDocument. The methods in a listener are just callbacks, such as we’d use to respond to a checkbox click in a GUI application. Once we look at listeners, we’ll see how ANTLR can also generate tree walkers that follow the visitor design pattern.[13]
To walk a tree and trigger calls into a listener, ANTLR’s runtime provides class ParseTreeWalker ...
Read now
Unlock full access