Gautam
Gautam

Reputation: 7958

ANTLR 3, what does LT!* mean?

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 ?

Upvotes: 3

Views: 571

Answers (1)

Bart Kiers
Bart Kiers

Reputation: 170278

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.

Upvotes: 4

Related Questions