OK, so you need a tree grammar that can parse complex boolean
expressions, right?

expression
  : ^((AND|OR) expression expression)
  | ^(('<'|'>'|'='|'!=') expression expression)
  | ^(('+'|'-'|'*'|'/') expression expression)
  | ID
  | literal
  ;

Would that work?

-Oliver

2009/1/22 Priolo, Scott <[email protected]>:
> Sorry about that, I'm trying to setup a walker that will know what to do
> with "OR" and "AND" operators.  I have the parser setup so that the AST is
> nicely formed with expr such as (< a 3).  I'm able to walk and evaluate
> these simple expr too. But! when I walk (or (and (< a 3) (< b 3)) (< c 3))
> I'm stumped.
>
> This must have been solved before and I would guess that there is probably a
> design pattern for walking boolean AST.
>
> Thanks,
> Scott
>
> -----Original Message-----
> From: Oliver Zeigermann [mailto:[email protected]]
> Sent: Thu 1/22/2009 4:19 AM
> To: Priolo, Scott
> Cc: [email protected]
> Subject: Re: [antlr-interest] Tree Evaluation with Logical Operators (AND
> and OR)
>
> Hi!
>
> Not quite sure what your problem is. Are you asking how an AST for a
> logical expression might look like? Or the grammar that creates it? Or
> the tree grammar that walks it? Or something else?
>
> -Oliver
>
>
> 2009/1/22 Priolo, Scott <[email protected]>:
>> Hello,
>>
>>
>>
>> I've searched high and low and can't find a reference to describe the
>> Logical Operators (and, or) design pattern for Tree Evaluation (after
>> purchasing the book I came up empty handed too).
>>
>>
>>
>> Any help?
>>
>>
>>
>> Thanks.
>>
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>
>
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to