ANTLR 3,LT!*是什么意思? [英] ANTLR 3, what does LT!* mean?
问题描述
我在看用ANTLR 3编写的Javascript语法的代码,
I was looking at the code for a Javascript grammar written in ANTLR 3,
http://www.antlr3.org/grammar/1206736738015/JavaScript.g
我发现很多情况下
program
: LT!* sourceElements LT!* EOF!
;
LT!*
是什么意思?
来自 http://ftp.camk.edu.pl/camk/chris/antlrman /antlrman.pdf
我发现LT
代表LOOKAHEAD TOKEN
,但这是第N
个向前看的标记,上面的N
部分在哪里?
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 ?
推荐答案
否,在这种情况下,LT
并不表示LOOKAHEAD TOKEN
.这是一个几乎在语法末尾定义的标记:
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.
;
*
表示解析器尝试匹配零个或多个这些令牌,而!
表示生成的AST不应该包含这些LT
令牌.
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.
这篇关于ANTLR 3,LT!*是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!