Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: How to grab Parse::RecDescent error output in a variable?

by vrk (Chaplain)
on Sep 17, 2008 at 08:21 UTC ( #711922=note: print w/replies, xml ) Need Help??


in reply to Re^4: How to grab Parse::RecDescent error output in a variable?
in thread How to grab Parse::RecDescent error output in a variable?

Done, and also received feedback already! Here's the bug report: https://rt.cpan.org/Ticket/Display.html?id=39323

And here's the solution I was seeking, based on demo/demo_errors.pl:

use strict; use Data::Dumper; use Parse::RecDescent; # Simple Lisp S-expressions (as an example) my $grammar = q# start: expression(s?) | { die join("\n", map { $_->[0] } @{ $thisparser->{errors} } +)."\n" } expression: /\w+/ | '(' expression(s?) ')' { $item[2] } | <error> #; my $p = Parse::RecDescent->new($grammar); # This will die if there is an error. print Dumper($p->start('(foo (bar))')); # Like so: $p->start('(foo');

--
say "Just Another Perl Hacker";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711922]
help
Chatterbox?
[1nickt]: you are missing an entire element, which is that your base ticket price only gets you a middle seat. If you want to be window or aisle you must pay, or gamble that you'll be assigned there at ...
[1nickt]: ... flihght time (hoping that not enough others have paid and there are some "good" seats to be allotted.
[1nickt]: And this is in addition to paying extra if you want to be in the first 12 rows, or in the emergency exit row.
choroba was once seeted besides a guy that was so fat he was almost squished between the guy
[holli]: I'm surprised there is not an entire genre of "fat guy on a plane" jokes

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-12-18 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (486 votes). Check out past polls.

    Notices?