January 2013
Intermediate to advanced
328 pages
8h 5m
English
ANTLR’s runtime consists of six packages, with most of the application-facing classes in the main org.antlr.v4.runtime package. By far the most common classes are the ones used to launch a parser on some input. Here is the typical code snippet for a grammar file called X.g and a parse-tree listener called MyListener that implements XListener:
| | XLexer lexer = new XLexer(input); |
| | CommonTokenStream tokens = new CommonTokenStream(lexer); |
| | XParser parser = new XParser(tokens); |
| | ParseTree tree = parser.XstartRule(); |
| | |
| | ParseTreeWalker walker = new ParseTreeWalker(); |
| | MyListener listener = new MyListener(parser); |
| | walker.walk(listener, tree); |
We first encountered this in Integrating a Generated Parser into a Java ...
Read now
Unlock full access