Esteemed monks,

I'd like to have your comments about a module I'm writing, dealing with the decoding and encoding of MMS messages (according to WAP specifications). I'd like to create a small library capable of both decoding incoming MMS messages, and encoding outgoing ones, to be eventually released in CPAN.

I basically finished writing a first form of decoder. I needed it in some hurry, so I quickly dropped testing along the way and also made some dirty things, just to have something "to touch" fast. It took me some spare time, and I always thought "when I'll have less hurry" - now - "I'll give it a better shape!". Here I am, looking for advice.

The data format is strictly binary, because these messages are thought to go over the air and strive to transfer as little information as possible (the main specs for encoding/decoding are Multimedia Messaging Service Encapsulation Specification and Wireless Session Protocol Specification, if you're curious). My decoder is, at the moment, completely function oriented (as opposed to OO oriented), and basically does all the decoding by means of functions calling other function... you get the picture of the mess.

I was wondering if it could be the case to rewrite the decoder using some "standard" parsing methods, like Parse::RecDescent, Parse::Yapp or even bison. The fact that I didn't so far is a clear, altough implicit, signal that I actually don't know much of all of these tools except their names and existence. So my first question is: are these tools good to parse binary data, whose format is structured in a nearly-compressed form?

If the basic answer is no (whatever the underlying reason is), I'm also wondering if I should intermix the deconding and encoding code or I should strictly separate them. On one hand, having them one near the other helps to preserve consistency (if I modify one function, I have the other at hand to check if it's compliant as well); on the other side, I somehow feel that they address broadly unrelated issues and I should separate them.

The last part of my quest is for pure advices. What are the common pitfalls to avoid when writing a parsing library? Are there some best practices to organise tests for this kind of applications?

Thank you as usual,

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

In reply to Decoder and encoder for MMS messages by polettix

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.