[ragel-users] Parsing date strings

Luis Kornblueh luis.kornblueh at zmaw.de
Thu Aug 11 09:36:01 UTC 2011


Hi everybody,

I came around ragel and read the user guide, which I understood only 
partly (I'm not having CS as background ;-)

I would like to write a parser for iso 8601 date, duration and 
recurrence strings. As we are related to climate science the dates
which needs to be handled aren't the once everybody has done.

I didn't manage to solve my problem and wnat to kindly ask everybody 
around here, having more experience, for help.

The first thing I have is parsing simple dates:

- something like 20340203 (3rd of February 2034) for example
   is no real problem
- -3456781203 in contrast is (3rd of May of the year -345678,
   proleptic Gregorian)

I'd like to use the same expr for both strings.

iso_year = ('-'? . digit+) >tag_iso_year;
iso_month = ('0' . [1-9] | '1' . [0-2]) >tag_iso_month;
iso_day = ('0' . [1-9] | [12] . [0-9] | '3' . [01]) >tag_iso_day;

iso_date = (iso_year . iso_month . iso_day) %set_iso_date;

Now iso 8601 is providing en extended format containg hyphens between 
the components:

iso_date_extended = (iso_year . '-' . iso_month . '-' . iso_day)

How can I manage the transparent handling in one machine.

The last issue is that I didn't understood error handling. It would be 
great to have something like a pointer to the point in the string, where 
parsing failed ...

The whole code is supposed to be C.

Thanks in advance for any kind of help,
Luis

-- 
                              \\\\\\
                              (-0^0-)
--------------------------oOO--(_)--OOo-----------------------------

  Luis Kornblueh                           Tel. : +49-40-41173289
  Max-Planck-Institute for Meteorology     Fax. : +49-40-41173298
  Bundesstr. 53
  D-20146 Hamburg                   Email: luis.kornblueh at zmaw.de
  Federal Republic of Germany

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4634 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20110811/2ea6c01e/attachment-0001.bin>
-------------- next part --------------
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list