Subject: | parser creation fails when $Data::Dumper::Terse=1 |
Date: | Sat, 26 Sep 2015 12:54:31 -0400 |
To: | bug-Parse-RecDescent [...] rt.cpan.org |
From: | sburton-cpan [...] allafrica.com |
the code block generated in _code() produces an error if some other
module has already included Data::Dumper, and set $Data::Dumper::Terse
to a true value. basically the opening line fails to define '$skip'
correctly.
works just fine:
/tmp# perl -Mstrict -mParse::RecDescent -mData::Dumper -we
'$Data::Dumper::Terse = 0; $::RD_HINT = 1; $::RD_TRACE = 1; my $grammar
= qq[startrule : string\nstring : "hello"]; my $parser =
Parse::RecDescent->new($grammar);'; mv RD_TRACE RD_TRACE-terse-0
Parse::RecDescent: Treating "startrule :" as a rule declaration
Parse::RecDescent: Treating "string" as a subrule match
Parse::RecDescent: Treating "string :" as a rule declaration
Parse::RecDescent: Treating ""hello"" as an interpolated literal
terminal
printing code (9308) to RD_TRACE
parser creation fails
/tmp# perl -Mstrict -mParse::RecDescent -mData::Dumper -we
'$Data::Dumper::Terse = 1; $::RD_HINT = 1; $::RD_TRACE = 1; my $grammar
= qq[startrule : string\nstring : "hello"]; my $parser =
Parse::RecDescent->new($grammar);'; mv RD_TRACE RD_TRACE-terse-1
Parse::RecDescent: Treating "startrule :" as a rule declaration
Parse::RecDescent: Treating "string" as a subrule match
Parse::RecDescent: Treating "string :" as a rule declaration
Parse::RecDescent: Treating ""hello"" as an interpolated literal
terminal
printing code (9299) to RD_TRACE
ERROR: Internal error in generated parser code!
Hint: syntax error at (eval 7) line 10, near "'\\s*'
{" BEGIN
not safe after errors--compilation aborted at
(eval 7)
line 15.
/tmp# diff -u RD_TRACE-terse-0 RD_TRACE-terse-1
--- RD_TRACE-terse-0 2015-09-26 16:33:44.000000000 +0000
+++ RD_TRACE-terse-1 2015-09-26 16:33:18.000000000 +0000
@@ -4,7 +4,7 @@
use strict;
use vars qw($skip $AUTOLOAD );
@Parse::RecDescent::namespace000001::ISA = ();
-$skip = '\\s*';
+'\\s*'
/tmp# perl -mParse::RecDescent -we 'print $Parse::RecDescent::VERSION."\n";'
1.967012
/tmp# perl -v
This is perl 5, version 14, subversion 2 (v5.14.2) built for
x86_64-linux-gnu-thread-multi
/tmp# uname -srvmo
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u4 x86_64 GNU/Linux