[antlr-interest] Help writing a particular semantic predicate

Indhu Bharathi indhu.b at s7software.com
Tue Oct 6 19:49:21 PDT 2009


In that case you have to use syntactic predicate.

 

Cheers, Indhu

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Naveen Chawla
Sent: Wednesday, October 07, 2009 4:33 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Help writing a particular semantic predicate

 

Ok, I've solved my particular problem using token lookaheads, but I was
wondering if there is a way of doing non-terminal symbol lookaheads in
semantic predicates?

2009/10/6 Naveen Chawla <naveen.chwl at googlemail.com>

grammar x;

 

x:  a b;

 

     a: 'i' a? | c? 'j';     // Question, how would I write the semantic
predicates: if this "a" is followed by 'v1' choose the first alternative, if
not choose the second alternative

 

          c: 'i';

 

     b: 'v1' | 'v2';

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091007/01b3fa31/attachment.html 


More information about the antlr-interest mailing list