[antlr-interest] [bug?] AST rewrite rule with no (imaginary) token yields C runtime compile error
Gavin Lambert
antlr at mirality.co.nz
Fri May 30 01:14:01 PDT 2008
At 20:07 30/05/2008, David Benn wrote:
>predefined_type_def
> : primitive_type -> ^(primitive_type)
> | IDENT IDENT -> ^(IDENT IDENT)
> ;
>
>i.e. it had no imaginary root node in the AST rewrite rule.
[...]
>Assuming the rewrite rule is legal (but perhaps not desirable),
I
>guess this is a bug in the C runtime code generation step.
I vaguely remember a discussion on something similar a while
back. I think the general idea was that this sort of thing isn't
legal, since 'primitive_type' might expand to zero or more tokens,
and exactly one token must be the root node.
You could always just not try to wrap it into another subtree
level though -- 'primitive_type -> primitive_type' should work
fine. (In fact I think just 'primitive_type' alone should also
work, but I vaguely recall something odd with that as well.)
More information about the antlr-interest
mailing list