[antlr-interest] predicate and ambiguity

Gavin Lambert antlr at mirality.co.nz
Mon Jul 9 01:06:20 PDT 2007


At 18:25 9/07/2007, Lloyd Dupont wrote:
 >I have seen the flag in the documentation, but I have no idea on 

 >how to exploit it!

With backtracking on, you should be able to do something like this 
(warning: air code, so you may need to adjust it a bit):

parserrule: TOK1 otherparserrule TOK2;

otherparserrule: TOK3 TOK4 func=ID {IsFunction($func.text)}? TOK5;

(You might have to put the predicate right at the end of the 
rule.  I forget how it goes exactly.)

 >On an other note I heard there is a PDF and a book.
 >Is it possible to pay online and get the PDF directly?

I believe so, yes.  I think it's available from the Pragmatic 
Programmers site.



More information about the antlr-interest mailing list