问题
I was looking at the code for a Javascript grammar written in ANTLR 3,
http://www.antlr3.org/grammar/1206736738015/JavaScript.g
In many instances I found
program
: LT!* sourceElements LT!* EOF!
;
what does LT!*
mean ?
EDIT:
From http://ftp.camk.edu.pl/camk/chris/antlrman/antlrman.pdf
I found that LT
stands for LOOKAHEAD TOKEN
but it is the N
th look ahead token, where is the N
part in the above ?
回答1:
No, LT
does not mean LOOKAHEAD TOKEN
in this context. It is a token defined nearly at the end of the grammar:
LT
: '\n' // Line feed.
| '\r' // Carriage return.
| '\u2028' // Line separator.
| '\u2029' // Paragraph separator.
;
The *
means that the parser tries to match zero or more of these tokens, and the !
indicates that the generated AST should not include these LT
tokens.
来源:https://stackoverflow.com/questions/16213085/antlr-3-what-does-lt-mean