I spent several hours chasing down a simple bug in my Parse::RecDescent (P::RD) grammar. It turned out that in one of my subrules, I wrote:
equals: '>=' | '<=' | '=' | '>' | '>'
Note the duplication of the '>' symbol. This works fine in Perl (
`perl -e 'print 0 || "hi" || "hi"'`), but apparently P::RD didn't really like it. Finally,
jcwren showed me my stupid error. I changed the second '>' to '<' and everything magically worked.
But it left me wondering why this would cause the rule not to work correctly. After all, it works in Perl.
Is there anyone familiar with the inner workings of Parse::RecDescent who would care to shine a light on this seemingly mysterious behavior?
I realize that P::RD is only supposed to work on correct grammar, and this certainly wasn't correct (technically). But this should at least be considered a GOTCHA in the docs, and if possible, should be the target of some error-checking code in the next release.
Thanks!
Quinn Slack
perl -e 's ssfhjok qupyrqs&&tr sfjkohpyuqrspitnrapj"hs&&eval&&s&&&'
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.