[antlr-interest] Re: Lexer problem
mzukowski at bco.com
mzukowski at bco.com
Wed Jan 2 07:03:47 PST 2002
Yes try something like this:
( ".a" | (".a.a")=>".a.a" | ".b" | 'a' | 'c' )
Read the docs and look at the generated code to understand what it does.
Monty
> -----Original Message-----
> From: manfredlotz [mailto:Manfred.Lotz at web.de]
> Sent: Saturday, December 29, 2001 1:09 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: Lexer problem
>
>
> After scanning ".a." the lexer seems to think it has to be ",a,a".
> After finding 'b' it says unexpected char.
>
> Can a syntactic predicate help. I have to admit that I didn't
> understand exactly what it is and what it can do for me.
>
>
>
> Manfred
>
>
> --- In antlr-interest at y..., mzukowski at b... wrote:
> > Take a look at the generated code. Can you see why it doesn't work?
> You
> > may need to use a syntactic predicate in front of ".a.a".
> >
> > Monty
> >
> > > -----Original Message-----
> > > From: manfredlotz [mailto:Manfred.Lotz at w...]
> > > Sent: Thursday, December 27, 2001 9:41 PM
> > > To: antlr-interest at y...
> > > Subject: [antlr-interest] Lexer problem
> > >
> > >
> > > Using the definiton shown below the lexer has a problem to
> recognize
> > > tokens if they arrive in a certain order.
> > >
> > > E.g., ".a.a.b$" or ".ac$" work fine, however ".a.b$" does not.
> > >
> > > Any idea what I have to change to make it working. I know it has
> to do
> > > with the fact that ".a" is a substring of ".a.a" but I don't know
> how
> > > to improve the t.g file.
> > >
> > > Manfred
> > > _____________________
> > >
> > > class TLexer extends Lexer;
> > > options {
> > > k=4;
> > > filter=IGNORE;
> > > }
> > >
> > > MYENDTOKEN : '$' ;
> > >
> > > A : ( ".a" | ".a.a" | ".b" | 'a' | 'c' ) ;
> > >
> > > protected
> > > IGNORE : ( "\r\n" | '\r' | '\n' ) { _ttype = Token.SKIP; };
> > >
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
>
>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list