Parser Rules
Parsers consist of a set of parser rules in either a parser or a combined grammar. A Java application launches a parser by invoking the rule function, generated by ANTLR, associated with the desired start rule. The most basic rule is just a rule name followed by a single alternative terminated with a semicolon.
â | â/** Javadoc comment can precede rule */â |
â | retstat â:â â'return'â expr â';'â â;â |
Rules can also have alternatives separated by the | operator.
â | statâ:â retstat |
â | â|â â'break'â â';'â |
â | â|â â'continue'â â';'â |
â | â;â |
Alternatives are either a list of rule elements or empty. For example, hereâs a rule with an empty alternative that makes the entire rule ...
Get The Definitive ANTLR 4 Reference, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.