[antlr-interest] Rule for ISO 8601 - Duration Standar
Javier Gomez Escribano
jg.escribano at uam.es
Tue Dec 16 03:52:42 PST 2008
Hello!
I'm trying to parse a "duration string" which is in format ISO 8601:
*PnnYnnMnnDTnnHnnMnnS* (*P*1*Y*0*M*27*DT*11*H*9*M*11*S*)
where *nn* are numbers.
(A reference to ISO 8601 for durations...
http://en.wikipedia.org/wiki/ISO_8601)
The problem is that I have to put a white space between letters and numbers.
And it is something I'd like to avoid.
Here is part of my code
duration : (P_TOKEN (year=number Y_TOKEN)? (month=number M_TOKEN)?
(day=number D_TOKEN)?)?(T_TOKEN (hour=number H_TOKEN)? (min=number M_TOKEN)?
(sec=number S_TOKEN)?)? -> ^(YEAR $year)? ^(MONTH $month)? ^(DAY $day)?
^(HOUR $hour)? ^(MINUTE $min)? ^(SECOND $sec)? ;
number : value=INT -> ^($value) ;
INT : ('0'..'9')+;
Any recommendations?
Thank you
--
Javier Gomez Escribano
http://rincon.uam.es/dir?cw=782003784179687
--
Javier Gomez Escribano
http://rincon.uam.es/dir?cw=782003784179687
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081216/e38f21b0/attachment.html
More information about the antlr-interest
mailing list