ANTLR tree construction problem -
ANTLR tree construction problem -
if got grammar rule like
a: (c|d|e) i can create ast rule attaching rewrite rules each alternative(c, d, e) this:
a: (c -> ^(a c) | d -> ^(a d) | e -> ^(a e)) but, if got different grammar rule like
a: (a|b) (c|d|e) how create ast every possible match? first tried this:
a: (a|b) (c|d|e) -> ^((a|b) (c|d|e)) but, did not work.
is there simple way solve problem?
thanks in advance. :)
you have 2 options:
1a : (left=a | left=b) (right=c | right=d | right=e) -> ^($left $right) ; or:
2a : left right -> ^(left right) ; left : | b ; right : c | d | e ; personally, prefer 2nd option.
antlr
Comments
Post a Comment