[antlr-interest] Lexer semantic predicate syntax?

Steve Bennett stevagewp at gmail.com
Mon Nov 19 21:14:46 PST 2007


Quick question about predicates in the lexer:

Both of these seem to be acceptable:

FOO: {...}? 'foo';

FOO: {...}? => 'foo';

However, in the first case, a message is printed to the output if the
predicate fails, and one token (I think) is lost. The second case
seems to behave exactly as expected. Is this an error, or is there
some distinction between the two?

The first syntax comes from
http://www.cs.usfca.edu/~parrt/course/652/lectures/antlr-lexers.html
while the second is from p110 of the book. I don't see any other
explicit discussion of lexer predicates apart from that.

Steve


More information about the antlr-interest mailing list