January 2013
Intermediate to advanced
328 pages
8h 5m
English
So far, we’ve isolated our application-specific code to parse-tree walkers, which means that our code has always executed after parsing is complete. As we’ll see in the next few chapters, some language applications require executing application-specific code while parsing. To do that, we need the ability to inject code snippets, called actions, directly into the code ANTLR generates. Our first goal, then, is to learn how to embed actions in parsers and lexers and to figure out what we can put in those actions.
Keep in mind that, in general, it’s a good idea to avoid entangling grammars and application-specific code. Grammars without actions are easier to read, aren’t tied to a particular target language, and ...
Read now
Unlock full access