ANTLR 3,LT!*是什么意思? [英] ANTLR 3, what does LT!* mean?

查看:166
本文介绍了ANTLR 3,LT!*是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看用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 Nth 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆