[antlr-interest] [bug?] AST rewrite rule with no (imaginary) token yields C runtime compile error
David Benn
dbenn at computer.org
Fri May 30 05:23:37 PDT 2008
Hi Gary
Thanks, that seems quite reasonable. Mostly I wanted to raise the
question: should this error make it through to the generated parser
code, or be caught by the ANTLR AST rewrite mechanism? If it is an
illegal construct, I would suppose the latter.
Thanks.
Rgds,
DJB
On 30/05/2008, at 5:44 PM, Gavin Lambert wrote:
> 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.)
>
Regards,
David Benn
dbenn at computer.org
0407 261163
"The real voyage of discovery consists not in seeking new landscapes
but in having new eyes." (Marcel Proust)
More information about the antlr-interest
mailing list