[antlr-interest] Syntactic anti-predicates

Gavin Lambert antlr at mirality.co.nz
Sat Feb 9 13:36:02 PST 2008


At 06:53 10/02/2008, Steve Bennett wrote:
 >
 >Is there a convenient way to say "if the upcoming tokens look
 >like X Y Z" then *don't* match this rule? It seems I always
 >have to resort to a semantic predicate like this:
 >
 >{input.LA(1) != X && input.LA(2) != Y}? =>  R
 >
 >or some complicated rule that amount to not X Y Z:
 >
 >(notXYZ) => R
 >
 >Is there a simple way I'm missing?

Why not just use:

ruleA
   :  (X Y Z) => ruleXYZ
   |  ruleNotXYZ
   ;

?


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.20.0/1268 - Release Date: 9/02/2008 11:54




More information about the antlr-interest mailing list