Oliver Zeigermann wrote:
> 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
>
>
This grammar is not syntactically restrictive since it allows ^(AND 3
4). This will cause problems if you want to evaluate the tree since you
won't know the type of the return value of expression. It is better to
separate out arithmetic and logical expressions. Care must be taken to
establish if ID is arithmetic or logical.
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
-~----------~----~----~----~------~----~------~--~---