On Fri, 2008-10-17 at 15:45 +0200, Johannes Luber wrote:
> Axelle Ziegler schrieb:
> > Hi,
> > I'm feeling I'm missing something pretty fundamental here, if someone
> > can enlight me. I've been switching from antlr 3.0.1 to antlr 3.1 and
> > got some weird errors with my variable names rule. In the end, I've
> > narrowed it down to this small example, using antlrWorks :
> >
> > grammar Test;
> >
> > atoms :
> > VARNAME;
> >
> > private MIN :('a'..'z');
> > private MAJ :('A'..'Z');
> > private CHAR :('_')|('.')|(':')|('!')|('?')|('\'');
> >
> > VARNAME : MIN(MAJ|MIN|CHAR|'0'..'9')*;
>
> There are two errors. The first is that "private" isn't currently used
> (though it is allowed syntactically). I think you want "fragment" here.
Yes - the lack of fragment is matching the MIN as a token in its own
right.
> The other problem is that in lexer rules '*' should not be used. Or more
> specifically: You may not create empty tokens. Doing so increases in the
> best case merely the code size and doesn't work in the worst case.
However, he has not done that here as the VARNAME rule starts with one
MIN followed by any number of the following tokens, so it does not
create an empty token (lack of spaces in the rule spec makes it harder
to see that I think).
Jim
--~--~---------~--~----~------------~-------~--~----~
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:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address