But this creates a different tree, while what I need is plain and simple structure like this: + / \ / \ a * / \ / \ c d Tomasz
--- On Fri, 8/7/09, Sam Barnett-Cormack <[email protected]> wrote: From: Sam Barnett-Cormack <[email protected]> Subject: Re: [antlr-interest] could not even do k=1 for decision xx; reason: timed out To: "Tomasz Jastrzebski" <[email protected]> Date: Friday, August 7, 2009, 2:30 PM Tomasz Jastrzebski wrote: > 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 > ; Still left-factor it. additiveExpression : e1=multiplicativeExpression ((o='+'|o='-') e2=multiplicativeExpression -> BINARY_EXPRESSION<BinaryExpression>[$o.text, $e1.tree, $e2.tree])* ; This means that the output expression is only considered if the optional subrule matches - otherwise it uses the default output (just e1). -- Sam Barnett-Cormack --~--~---------~--~----~------------~-------~--~----~ 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
