[antlr-interest] Grammar problem
vincent
vincent.vbt at gmail.com
Mon Sep 3 08:54:10 PDT 2012
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
More information about the antlr-interest
mailing list