[antlr-interest] forcing parenthesis (no precedence)
hakan eryargi
hakan.eryargi at gmail.com
Thu Jul 16 23:26:46 PDT 2009
thank you all. this effectively solved my problem :)
On Thu, Jul 16, 2009 at 5:55 PM, David-Sarah
Hopwood<david-sarah at jacaranda.org> wrote:
> Stuart Dootson wrote:
>> On Thu, Jul 16, 2009 at 1:21 PM, hakan eryargi <hakan.eryargi at gmail.com> wrote:
>>> i will really appreciate a simple sample if possible :)
>>
>> Simple grammar that mimics the Ada approach:
>>
>> grammar test;
>>
>> program : expression EOF
>> ;
>>
>> expression
>> : primary ( ('AND' primary ) + | ( 'OR' primary ) +)
>> ;
>
> This doesn't allow a single <primary> that does not use AND/OR as an
> <expression>. You want something like:
>
> expression
> : primary ( ('AND' primary ) + | ( 'OR' primary ) +)?
> ;
>
> (It's also preferable to declare all of the tokens, as in my other reply.)
>
>> primary : VARIABLE
>> | 'TRUE'
>> | 'FALSE'
>> | '(' expression ')'
>> ;
>>
>> VARIABLE : 'a'..'z' +
>> ;
>
> --
> David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list