[antlr-interest] Puzzled by leading dot
Alexey Demakov
demakov at ispras.ru
Tue Mar 15 08:37:48 PST 2005
It is not correct if there are skipped whitespace
because "." WHITESPACE "SE" will be accepted.
Regards,
Alexey
-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com
----- Original Message -----
From: "togol machillan" <togolmach2 at lycos.com>
To: <antlr-interest at antlr.org>
Sent: Tuesday, March 15, 2005 7:31 PM
Subject: Re: [antlr-interest] Puzzled by leading dot
> Writing the dot as a separate character like '.' might solve the problem.
>
> Mach
>
>
> ----- Original Message -----
> From: "Juergen Weber" <weberjn at yahoo.com>
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Puzzled by leading dot
> Date: Tue, 15 Mar 2005 07:58:00 -0800 (PST)
>
> >
> >
> > Hi,
> >
> > I want to parse lines of the form
> >
> > .SE DATE = '03.02.2005';.SE TIME = '20:17'
> >
> >
> > (basically a key value format, the .SE is to be
> > ignored).
> >
> > If I parse the input with the grammar below, I got
> > this error message:
> >
> > Exception in thread "main" line 1:1: unexpected char:
> > '.'
> >
> > How could I specify a keyword with a leading dot?
> >
> > Thanks for your help,
> > Juergen
> >
> >
> >
> >
> > class MyParser extends Parser;
> >
> >
> > line
> > : item (SEMI item)*
> > ;
> >
> > item
> > : DOTSE IDENT "=" STRING_LITERAL
> > ;
> >
> >
> >
> > class MyLexer extends Lexer;
> >
> > tokens {
> > DOTSE=".SE";
> > }
> >
> >
> > IDENT
> > : ('a'..'z'|'A'..'Z'|'_')
> > ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
> > ;
> >
> >
> >
> > STRING_LITERAL
> > :
> > '\''
> > (~'\'')*
> > '\''
> > ;
> >
> >
> > SEMI: ';'
> > ;
> >
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Small Business - Try our new resources site!
> > http://smallbusiness.yahoo.com/resources/
>
> --
> _______________________________________________
> NEW! Lycos Dating Search. The only place to search multiple dating sites at once.
> http://datingsearch.lycos.com
>
>
More information about the antlr-interest
mailing list