[antlr-interest] Problem with *

Martin Probst mail at martin-probst.com
Wed Feb 8 14:40:40 PST 2006


Hi,

maybe you could post your whole grammar? That might help. You can also
get debug trace from the lexer if you run antlr with the option
-debugLexer (if I remember correctly). Sometimes reading the generated
code or tracing through it can help a lot (you have to look at the
lexer).

A possible cause would be that the '*' character is matched by a
different rule in your Lexer (which would explain why writing it
literally in the parser works). Make sure no other Lexer rule can match
a single star. Do you get any non-determinism warnings from ANTLR?

Martin

Am Mittwoch, den 08.02.2006, 22:43 +0100 schrieb Jens Bartelheimer:
> Hi again,
> 
> has nobody a solution for my problem?
> 
> I have recognized that the same problem exist if I define only one 
> single token in my rule.
> 
> Jens
> 
> Jens Bartelheimer wrote:
> > Hi,
> >
> > I am new to antlr and I have a problem with the Star *.
> >
> > If I only parse a String with a star the first rule recognize the 
> > star, the second with a token not.
> >
> > Why?
> >
> > 1st:
> > ----
> >
> > getTest
> > {
> > }
> >    :   "*"
> >        {
> >    System.out.println("Star gefunden");
> >        }
> >    ;
> >
> >
> > 2nd:
> > getTest
> > {
> > }
> >    :   STAR
> >        {
> >    System.out.println("Star found");
> >        }
> >    ;
> >
> > Lexer:
> > STAR: '*';
> >
> > raises: line 1:1: expecting STAR, found '*'
> >
> >
> >
> 



More information about the antlr-interest mailing list