Hello all,
I have several rules "chained" like this:
additiveExpression
: multiplicativeExpression ('+' | '-') multiplicativeExpression
| multiplicativeExpression
;
multiplicativeExpression
: exponentiationExpression ('*' | '/') exponentiationExpression
| exponentiationExpression
;
and eventually the tool complains: could not even do k=1 for decision XX;
reason: timed out (>1000ms)
Nothing unseen - such rules could be easily left-factored:
additiveExpression
: multiplicativeExpression (('+' | '-') multiplicativeExpression)*
;
multiplicativeExpression
: exponentiationExpression (('*' | '/') exponentiationExpression)*
;
But the problem is that I cannot do that since I need to catch reference to
each expression and operator to build nice AST tree. The real code looks more
like this:
additiveExpression
: e1=multiplicativeExpression (o='+' | o='-') e2=multiplicativeExpression ->
BINARY_EXPRESSION<BinaryExpression>[$o.text, $e1.tree, $e2.tree]
| multiplicativeExpression
;
multiplicativeExpression
: e1=exponentiationExpression (o='*' | o='/') e2=exponentiationExpression ->
BINARY_EXPRESSION<BinaryExpression>[$o.text, $e1.tree, $e2.tree]
| exponentiationExpression
;
Any ideas?
Thanks,
Tomasz
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address