January 2013
Intermediate to advanced
328 pages
8h 5m
English
The lexicon of ANTLR is familiar to most programmers because it follows the syntax of C and its derivatives with some extensions for grammatical descriptions.
There are single-line, multiline, and Javadoc-style comments.
| | /** This grammar is an example illustrating the three kinds |
| | * of comments. |
| | */ |
| | grammar T; |
| | |
| | /* a multi-line |
| | comment |
| | */ |
| | |
| | /** This rule matches a declarator for my language */ |
| | decl : ID ; // match a variable name |
The Javadoc comments are sent to the parser and are not ignored. These are allowed only at the start of the grammar and any rule.
Token names always start with a capital letter and so do lexer rules as defined by Java’s Character.isUpperCase ...
Read now
Unlock full access