[antlr-interest] Check if rule returns empty result
Christian
chwchw at gmx.de
Thu Nov 3 13:01:02 PDT 2011
Hi at all,
I have the following rules:
method_declaration
: method_header method_body -> ^(METHOD_HEADER method_header)
^(METHOD_BODY method_body)
;
method_body:
';'!
| '{'! statement_list? '}'!;
;
Of course, method_body is executed because it has no question mark.
However, introducing rewrite rules and operators cause a problem. By
using ^(METHOD_BODY method_body), method_body must return a non-empty
value. However, statement_list? is optional and thus may not match at
all. In this case, method_body returns nothing anymore and I get an
RewriteEmpty exception.
How can I solve this problem by only changing rewrite rules?
Regards,
Christian
More information about the antlr-interest
mailing list