[antlr-interest] Version Problem

Johannes Luber jaluber at gmx.de
Fri Sep 7 03:11:47 PDT 2007


Mohammed Ibrahim wrote:
> hello folks ,
>  
> i have a problem in here , i would like to parse this string
> =======================================
> antlr / 2.0    <----- this string
> =======================================
> i wrote for it this EBNF
>  
>  
> VERSION : LETTER DECIMAL;
>  
> DECIMAL : INT ('.' INT)+;
>  
> LETTERS: 'a'..'z'+;
>  
> INT:  '0'..'9'+;
>  
> WS : ( '  ' |'\r'|'\n'|'/') +  { skip(); };
> ==========================================
>  
> It doesn't want to recognize it i don't want why ?????

Does this grammar compile at all? After all, you wrote LETTER instead
LETTERS in VERSION, which should be version. Another error is that WS
includes two consecutive spaces instead only one, which is probably the
source of your failure. With those changes the test string has been
recognized.

version : LETTERS DECIMAL;

DECIMAL : INT ('.' INT)+;

LETTERS: 'a'..'z'+;

INT:  '0'..'9'+;

WS : ( ' ' |'\r'|'\n'|'/') +  { skip(); };

Best regards,
Johannes Luber


More information about the antlr-interest mailing list