I am having trouble moving from parser grammar to tree grammar, the problem comes when i use tree operators (^,!) instead of rewrite rules (->)
where_clause
: 'where'! condition_or
;
condition_or
: condition_and ( 'or'^ condition_and )*
;
condition_and
: condition_expr ( 'and'^ condition_expr )*
;
condition_expr
: condition_comparision
// | condition_in
// | condition_like
;
condition_comparision
: column_identifier ('=' | '!=' | '>' | '<')^ sql_element
;
For the above parser grammar, how would the tree grammer look like ? Since this isn't recursive I wont be able to collapse this into a single rule in the tree grammar.
The other alternative to forcefully rewrite the parser grammar using rewrite syntax
condition_or
: condition_and -> condition_and
( 'or' x=condition_and -> ^('or' condition_or $x))*
;
Is there any simpler way to do this ?
Thanks