[antlr-interest] Grammar problem

Jim Idle jimi at temporal-wave.com
Mon Sep 3 12:33:31 PDT 2012


optionalLines : (TXTALPHA | SPACE)* DOT

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of vincent
> Sent: Monday, September 03, 2012 8:54 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Grammar problem
>
>  Hy,
>
> I use some ANTLR grammar to decode text files. But i encouter a problem
> with the following example.
> Does anybody can help me ?
>
> My text files is componed of the following parts :
>
> start line : "-  "
> optional text : text ended with "."
> serial number : 5 digits ended by a space versioning : digit / digit
> text : text
>
> example with optional text :
>
> -  optional text.00001 001/001TEXT
>
> example without optional text :
>
> -  00001 001/001TEXT
>
> my probem is for optional text, cant detect it with antlr grammar.
> I use the following code :
>
>
>
>
> COMMA : ',';
> DOT : '.';
> HYPHEN :'-';
> SPACE : ' ';
> SLASH : '/';
> CHAR : ('a'..'z'|'A'..'Z');
> SEPARATOR : (DOT |HYPHEN)+;
> DIGIT : ('0'..'9');
> TXTALPHA : (CHAR)+ ;
> NUMBER : (DIGIT)+ ;
> TXTALPHANUM : ((CHAR) | (DIGIT))+;
>
>
> textline : HYPHEN (SPACE)+  (optionalLines)* normalLine;
>
> optionalLines : (TXTALPHA)* DOT
>
> normalLine: serialNumber SPACE currentPartNumber SLASH maxPartNumber;
>
> thanks
>
> VIncent
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list