dHarry has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I seek wisdom for implementing a parser in Perl. I am more an “end user” when it comes to parsers I have limited experience in writing them.
I am thinking about implementing a Parser for ODL (Object Description Language, no not the Object Definition Language). ODL is endorsed by the PDS (Planetary Data System) and is used to describe/define data products, e.g. scientific measurements done by instruments. See below for an example then it becomes clear what I would like to parse. This offers a pretty good and short explanation.
There is some SW around…
But I am really looking for a Perl solution (yes I am biased).
A parser that can read the ODL format and generates events like “start_of_object X”, “keyword_Y” , “end_of_object Z” triggering callback functions. A bit like SAX but then for XMODL I suppose. Then I can build other stuff on top of that like validation of the data or generate other data products from it.
I have looked around on CPAN and the web and performed a Super Search…
Can anyone point me in the right direction, i.e. how to implement an (ODL) parser? Or is there already something around?
Example data file EXAMPLE.LBL__DATA__
/*** FILE CHARACTERISTIC DATA ELEMENTS ***/ FILE_NAME = "2007_11_11T10_11_47_1.DAT" FILE_RECORDS = 9392 RECORD_TYPE = FIXED_LENGTH RECORD_BYTES = 4264 RELEASE_ID = 0001 REVISION_ID = 0001 /* Table object describing the data */ OBJECT = TABLE COLUMNS = 42 INTERCHANGE_FORMAT = BINARY ROW_BYTES = 4264 ROWS = 9387 DESCRIPTION = "BLABLA” OBJECT = COLUMN COLUMN_NUMBER = 1 NAME = SPECTRUM BYTES = 2048 START_BYTE = 1 DATA_TYPE = MSB_INTEGER DESCRIPTION = " THIS COLUMN CONTAINS THE RAW DATA OF THE 512 CHANNEL X-RAY SPECTRUM OF THE INSTRUMENT. " ITEMS = 512 ITEM_BYTES = 4 END_OBJECT = COLUMN /* more COLUMN objects here */ END_OBJECT = TABLE END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing an ODL parser?
by moritz (Cardinal) on Jul 29, 2008 at 16:34 UTC | |
by dHarry (Abbot) on Jul 30, 2008 at 13:57 UTC | |
by moritz (Cardinal) on Jul 30, 2008 at 14:18 UTC | |
|
Re: Writing an ODL parser?
by jethro (Monsignor) on Jul 29, 2008 at 19:00 UTC | |
by dHarry (Abbot) on Jul 30, 2008 at 14:04 UTC | |
by jethro (Monsignor) on Jul 30, 2008 at 18:56 UTC | |
|
Re: Writing an ODL parser?
by pc88mxer (Vicar) on Jul 29, 2008 at 19:22 UTC | |
by dHarry (Abbot) on Jul 30, 2008 at 14:12 UTC |