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

In reply to Writing an ODL parser? by dHarry

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.