On Fri, Mar 4, 2011 at 6:53 PM, g...@novadsp.com <g...@novadsp.com> wrote:

> Is there a pattern to follow for creating tree grammars for subrules?
>
> // parser rule. this works.
> expression
>     : (a=term -> $a) ( ( '|' b=term -> ^(OR $expression $b)
>                        | '|'        -> ^(OR $expression EPSILON)
>                        )
>                      )*
>     ;
>


I'd expect that to become the tree-grammar rule:

expression
  :  term
  |  ^(OR expression term)
  |  ^(OR expression EPSILON)
  ;



instead of:


>
> // tree grammar 1, based on CMinus example in the book.Throws a
> MismatchedTreeNodeException complaining about lack of
> // 'UP' at SEQUENCE_EXPR
> expression
>     : IF_ACTION
>     | ID
>     | ID ATTRIBUTES
>     | STRINGLITERAL
>     | EPSILON
>     | ^(GROUPED_EXPR expression)
>     | ^(OPTIONAL_EXPR expression)
>     | ^(SEQUENCE_EXPR expression)
>     ;
>
>
Regards,

Bart.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to