locked_user sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE:   False Alarm!
I didn’t know that someone around here, in the dark and distant past, fotzed with the installed version (supposed to be 1.94), apparently adding their own code to it and otherwise breaking it.

I'm using Parse::RecDescent, admittedly for the first time, and I have run into a rather peculiar problem.

The constructor has obviously found things that it doesn’t like about the grammar (no surprise there...), but, even though I’ve turned on every error/warning/hint option that there is, here’s the only thing that comes out: (printed to STDERR)

: : : :

(Yeah, “WTF...?”   That’s what I said, too!)   The “error messages” consist of ... a few blanks, a colon-character, and nothing else.   There are no useful messages here.   Nothing but blanks and colons.   The constructor-call is returning undef, as it is supposed to do in the case of a grammar error.

Any ideas?   I know that I need to debug this thing, but I’m not getting any useful information with which to begin.   I do know that the grammar-string (quite a long string, of course), is being passed to the constructor.   The behavior is consistent with “grammar error,” and at this nascent point in the development cycle I fully expect there to be lots of them.   But... I need something to react to!

Replies are listed 'Best First'.
Re: An odd (lack of...) error message(s) from Parse::RecDescent
by jethro (Monsignor) on Sep 16, 2010 at 02:50 UTC
    If you can't give us details then you have to find the problem yourself. Remove stuff from your grammar until you get a meaningfull error message. The last thing you removed must be the culprit. If you can remove everything and it still prints this, the problem is in your script and not in the grammar.
Re: An odd (lack of...) error message(s) from Parse::RecDescent
by GrandFather (Saint) on Sep 16, 2010 at 00:44 UTC

    Maybe a small sample that reproduces the problem would help?

    True laziness is hard work
Re: An odd (lack of...) error message(s) from Parse::RecDescent
by roboticus (Chancellor) on Sep 16, 2010 at 10:16 UTC

    sundialsvc4:

    Three words: Divide and conquer.

    In other words, take the grammar tree, and replace one of the subtrees with a trivial production, and see if the error goes away. If the error remains, then you've shortened the grammar to a smaller example. If not, you've found the production that contains the error, and you should be able to put that production at the root of your script and remove the rest of the grammar.

    Lather, rinse and repeat. You'll either: (a) have a short example (which would be easier anonymize) that you can post, or (b) trip over the answer.

    ...roboticus

      That’s what I’ll be doing today ... and when I find it, I will post.

      The nature of the output ... blanks and colon-characters, with the colons (actually) not always quite in the same column ... almost looks like it is part of, or taken from, some part of the grammar.   It is, obviously, “nonsensical, but not random.”   So, as you say, “there’s really only way to find this,” and as soon as I do, I will give a full report.   All in the name of saving a few of the next person’s hair follicles.   Thanks, all.

      “There comes a glorious time in every day when one must stop writing computer software, and start drinking good dark beer.”

        sundialsvc4:

        Another thought occurred to me: It may be worth your while to use a tracing module (e.g. Devel::Trace) and run your program so you can see the last few operations that occurred. Then you might see an interesting place to put a breakpoint in Parse::RecDescent and find out what's driving it mad.

        (I had just opened Parse::RecDescent in my editor, thinking I'd give it a brief scan to see what bits of code may be generating the message, but 6000+ lines of code can be a bit much to wade through.)

        ...roboticus

Re: An odd (lack of...) error message(s) from Parse::RecDescent
by Khen1950fx (Canon) on Sep 16, 2010 at 01:59 UTC
    For some examples of error messages, take a look at some of these.

      This seems to be a successfully generated parser, whereas my situation is that I haven’t gotten that far yet.   I know that I’ve got errors in my grammar, and I am faced with an absence of sensible messages that would point me to the way to find them.

      “Grammar debugging,” in any parser, is always an exercise that you are anxious to forget, once “you’ve finally got the damm thing working.”  :-D   But does anyone out there who’s done it fairly recently, have any suggestions or war-stories?

Re: An odd (lack of...) error message(s) from Parse::RecDescent
by locked_user sundialsvc4 (Abbot) on Sep 16, 2010 at 01:04 UTC

    Part of the problem, of course, is that it isn’t exactly small.   (Another problem is that the customer really does not want anything going in-or-out the front door, and since they pay very promptly I have to play along.)

    I’m sorta hoping that someone out there will just be able to nod and say ... “oh yeah, that happened to me once, too.”   And here’s how I fixed it...”   We all know what it’s like when we know that the computer is doing something totally bogus, but we don’t yet know what it is. :-)

    I am reasonably confident that the constructor is being given the grammar-string that I intend to be giving it.   And I am reasonably sure that it is trying to tell me that the grammar is busted.   (I am absolutely sure that it contains many bugs and tpyos.)

    (Oh, no... no... it couldn’t be the programmer ... no, no...)   ;-)

        :-)   Mea culpa.
Re: [SOLVED; FALSE-ALARM] An odd (lack of...) error message(s) from Parse::RecDescent
by locked_user sundialsvc4 (Abbot) on Sep 17, 2010 at 04:23 UTC

    Ahem...

    I said that I would “report back” on this thing once I’d figured it out.   Well, I did.   And it turns out that the whole thing was (as I had begun to suspect...) totally and completely bogus.

    I downloaded the most-recent version of this package from CPAN, and installed it into a local directory (using use lib to add it to the search-path of the application in question), and the entire problem magically “went away.”

    Suspicious now, I diffed the installed code against the latest incarnation, and discovered that the installed code had (obviously) been rather extensively modified.   Looks to be debugging-code, or something-or-other, that was never taken out.   (Presumably, the person who did it is “many miles away by now,” and I actually hold no grudges at all against him or her.)

    So... “false alarm.” Now we (all) know.