[antlr-interest] Lexical code to recognize a date?

Jack Pan Jack.Pan at Lewtan.com
Tue Jan 6 11:38:36 PST 2009


Hi,

I'd like to recognize '2/3/2008' as date, while anything else like '2/3
/ 2008' as division. The following lex code recognizes date fine, but it
messes up division...

I'm fairly new to ANTLR. I'm wondering if someone can point me a
direction for this problem?

DATE
	: DATENUM '/' DATENUM '/' YEARNUM
	;

fragment
DATENUM
	:	('0'..'9') ('0'..'9')?
	;
	
fragment	
YEARNUM
	:	('19'|'20') ('0'..'9')('0'..'9')
	;


Thanks,

Jack





More information about the antlr-interest mailing list