ANTLR 3, what does LT!* mean?

南笙酒味 提交于 2019-12-10 19:29:50

问题


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 Nth 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!