Hi demerphq,
Thanks for the P::RD grammar and the thoughts. If you read my original post to the end, you'd see I did indeed think about using P::RD, but came to the conclusion that thats a lot of overhead for something that can also be done in a couple of subs.
I needed a language parser recently, found P::RD, was impressed, and used it. The docu sure is long, but well-written and easy to understand (in my opinion), I haven't used <leftop> yet, but I managed my task without it, and I guess I'd get this one too if I tried, if not as terse as your soloution :)
Like I mentioned above, this is a real-protocol used to communicate between Muds and a communications server/router. Info here Intermud3 spec if anyones interested. So I'd hope it won't throw empty elements at me, but you never know. :)
As to returning undef without causing the rule to fail, wasn't that just a case of doing:
rule : production { $return = undef; 1; }
?
Or am I understanding you wrong?
I think I'll go benchmark these solutions.. Thanks everyone for the answers!
C.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.