[antlr-interest] Need help parsing text format

Isabelle Muszynski imus at linuxmail.org
Mon Apr 30 04:46:24 PDT 2007


Hi everyone,

I need to parse text of the form 

BCS123/12.LT12ZX/HAM-BRE.1/bla&&^^%%$$bla.3

where the 1st and 3rd pieces are alphanumeric.

My grammar is shown at the end of this mail.
The problem is that it won't parse the cases where alphanumeric fields only contain for ex. letters :

BCSABC/12.CHARLIE/HAM-BRE.1/bla&&^^%%$$bla.3

I don't understand what I'm doing wrong :-(

TIA,
Isabelle

/*** GRAMMAR ***/
grammar Tokens;

SLASH :       '/';
DASH:   '-' ;
DOT     :       '.';

fragment SPECIAL_CHAR :	
          '`' | '!' | '@' | '$' | '%' | '^' | '&' | '*' | '(' | ')' |
         '+' | '=' | '[' | ']' | ':' | '\'' | '"' | '\\' | '|' | ',' | '<' | '?' ;

fragment DIGIT 	: '0'..'9'	;
	
fragment LETTER :	'a'..'z' | 'A'..'Z' ;	

fragment ALPHA 	:	LETTER | DIGIT;

fragment ANY_CHAR :	ALPHA | SPECIAL_CHAR ;

fragment WS_CHAR  : (' ' | '\t' | '\u000C' ) ;

WS      :       WS_CHAR+;

NEWLINE  : '\r'? '\n' ;

LETTER_WORD :	LETTER+ ;
NUMBER_WORD  :	DIGIT+ ;
ALPHA_WORD  : ALPHA+ ;
FREE_WORD : ANY_CHAR+ ;

load	:	
	ALPHA_WORD
	SLASH
	NUMBER_WORD
	DOT 
	ALPHA_WORD
	SLASH
	LETTER_WORD
	DASH
	LETTER_WORD
	DOT
	NUMBER_WORD
	SLASH
	FREE_WORD
	(DOT NUMBER_WORD)?
	NEWLINE
	;

=
HIPAA compliant Digital Transcription
V-Safes with V-800: Share and receive files (DSS, WAV, RTF, DOC) from phone (V-800), handheld-recorders (Olympus). HIPAA compliance. AES encryption. Batch print and download.
http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=091a5e152e265f0b42e2fc00947b1a35


-- 
Powered by Outblaze


More information about the antlr-interest mailing list