I'm trying to parse an expression like a IN [3 .. 5[
, where the direction of the angle brackets determine whether the interval is inclusive or exclusive. I want this to be rewritten to an AST like
NODE-TYPE
|
+------------+-----------+
| | |
variable lower-bound upper-bound
where NODE-TYPE is one of BTW_INCLUSIVE, BTW_EXCL_LOWER, BTW_EXCL_UPPER or BTW_EXCL_BOTH, depending on the direction of the angle brackets.
I have the following parse rule:
interval_expr : expr1=variable IN
(LBRACKET|RBRACKET)
expr2=expression DOTDOT expr3=expression
(LBRACKET|RBRACKET)
-> ^(BETWEEN $expr1 $expr2 $expr3)
This works, except that it does not create the correct tree node type. How can I choose which node type to create based on what was matched?