[antlr-interest] a simple (not for me :)) grammar problem

Fırat Küçük firatkucuk at gmail.com
Mon Jan 7 12:35:11 PST 2008


no,
this is what i did.

this grammar parses "3     .    4    . hello".

so as gavin said.

"It's not a solution if it doesn't work :)"



2008/1/7, Mark Volkmann <r.mark.volkmann at gmail.com>:
>
> On Jan 7, 2008 6:24 AM, Gavin Lambert <antlr at mirality.co.nz> wrote:
> > At 21:20 7/01/2008, =?ISO-8859-9?Q?F=FDrat_K=FC=E7=FCk?= wrote:
> >  >
> >  >this is my simple solution:
> >
> > It's not a solution if it doesn't work :)
> >
> > Try doing what I suggested.  You really should handle the floats
> > in the lexer, since you don't have to worry about whitespace
> > weirdness that way.  And if you do it the way I said, it should
> > work.
>
> I think this is what you want or at least really close.
>
> grammar Sample;
>
> start
>   options { backtrack = true; }
>   : (floatValue | integerValue) DOT IDENTIFIER
>     { System.out.println("matched!"); }
>   ;
>
> floatValue: NUMBER DOT NUMBER;
> integerValue: NUMBER;
>
> DOT: '.';
> IDENTIFIER: LETTER+;
> NUMBER: DIGIT+;
> fragment LETTER: 'a'..'z';
> fragment DIGIT: '0'..'9';
>
> NEWLINE: '\r'? '\n' { skip(); };
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>



-- 
Öğr. Gör. Fırat Küçük
ADAMYO Distance Learning
SAKARYA University / TURKEY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080107/8689dab1/attachment.html 


More information about the antlr-interest mailing list