-
Debian, 5.8.8, P::RD 1.94:
Warning (line 27): Found an error marker (<error>) after an uncond
+itional
<error>
(Hint: An unconditional <error> always causes the prod
+uction
containing it to immediately fail. An error mar
+ker that
follows an <error> will never be reached. Did y
+ou mean
to use <error?> instead?)
ERROR (line 1): Invalid startOfRecord: Was expecting RECORDSTAR
+T
-
WinXP, Active Perl 5.10.0 build 5001, P::RD 1.94: (repeated 3 times with different line numbers)
Variable "$errortext" is not available at c:/progs/perl5100/site/lib/P
+arse/RecDescent.pm line 2917.
Variable "$errorprefix" is not available at c:/progs/perl5100/site/lib
+/Parse/RecDescent.pm line 2917.
Use of uninitialized value $errorprefix in formline at c:/progs/perl51
+00/site/lib/Parse/RecDescent.pm line 2850.
Use of uninitialized value $errortext in formline at c:/progs/perl5100
+/site/lib/Parse/RecDescent.pm line 2850.
Use of uninitialized value $errortext in formline at c:/progs/perl5100
+/site/lib/Parse/RecDescent.pm line 2852.
:
Repeated twice with different line numbers.
-
WinXP, Active Perl 5.10.0 build 5004, P::RD 1.94:
same.
-
WinXP, Active Perl 5.10.0 build 5004, with P::RD 1.94 installed from CPAN instead of PPM:
same.
-
WinXP, Active Perl 5.8.8, P::RD 1.94:
Warning (line 27): Found an error marker (<error>) after an uncond
+itional
<error>
(Hint: An unconditional <error> always causes the prod
+uction
containing it to immediately fail. An error mar
+ker that
follows an <error> will never be reached. Did y
+ou mean
to use <error?> instead?)
ERROR (line 1): Invalid startOfRecord: Was expecting RECORDSTAR
+T
Looks like an incompatibility with 5.10.0.
I guess I'll have to look at the actual code, but it'll have to wait.
Update: I've never seen that error message before, so here's what diagnostics has to say about it:
(W closure) During compilation, an inner named subroutine or eval
+is
attempting to capture an outer lexical that is not currently avail
+able.
This can happen for one of two reasons. First, the outer lexical m
+ay be
declared in an outer anonymous subroutine that has not yet been cr
+eated.
(Remember that named subs are created at compile time, while anony
+mous
subs are created at run-time.) For example,
sub { my $a; sub f { $a } }
At the time that f is created, it can't capture the current value
+of $a,
since the anonymous subroutine hasn't been created yet. Conversely
+,
the following won't give a warning since the anonymous subroutine
+has by
now been created and is live:
sub { my $a; eval 'sub f { $a }' }->();
The second situation is caused by an eval accessing a variable tha
+t has
gone out of scope, for example,
sub f {
my $a;
sub { eval '$a' }
}
f()->();
Here, when the '$a' in the eval is being compiled, f() is not curr
+ently being
executed, so its $a is not available for capture.
| [reply] [d/l] [select] |
Confirmed that it's not just Windows. I installed ActivePerl 1004 (perl 5.10.0) on Ubuntu Jaunty and got the $errorparse error message.
Update: Oh, and I got the error marker error using the Jaunty distro perl (5.10.0), so it's not a 5.10 problem either.
| [reply] [d/l] [select] |
Here is some reduced grammer and code that works - parses the metafields (prefix #) correctly, but bums out at the "normal" fields (prefix F)..
Any ideas?
#!/usr/bin/perl -w
use strict;
use warnings;
#use diagnostics;
use Parse::RecDescent;
use Data::Dumper;
# Enable warnings within the Parse::RecDescent module.
$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an er
+ror
$::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c
+.
$::RD_HINT = 1; # Give out hints to help fix problems.
#$::AUTOSTUB = 1;
my $grammar = <<'_EOGRAMMAR_';
#{ our $errortext = ''; our $errorprefix = '';}
RECORDSTART : /^RECORD\r*\n/
{
print "\n[*] RECORDSTART -> " . $item[1];
$item[1];
}
RECORDEND : /^\./
{
print '\n[*] RECORDEND -> ' . $item[1];
$item[1];
}
fieldName : /[^ \t\n]+/
{
print "\n[*] fieldName -> $item[1]\n";
$item[1];
}
metaName : /[^ \t\n]+\n?/
{
$item[1];
}
metaFieldValue: /([^\n]*)\n/
{
$1;
}
fieldValue: /([^\n]*)\n/
{
print "[*] fieldValue $item[1]\n";
$1;
}
field : /^F/ fieldName fieldValue
{
print "[*] Got field named \'" . $item{ fieldName } . '\' with
+ value \'' . $item{ fieldValue } . "\'\n";
print Data::Dumper->Dump([$text], ["fieldStuff"]);
}
metaField : /^\#/ metaName metaFieldValue
{
print "[*] Got metafield named \'" . $item{ metaName } . '\' w
+ith value \'' . $item{ metaFieldValue } . "\'\n";
}
recordBody : field(s)
{
print "\n[*] field(s)\n";
#print main::Dumper \@item;
print Data::Dumper->Dump([$text], ["field(s)"]);
}
|
metaField(s)
{
print "\n[*] metaField(s)\n";
#print main::Dumper \@item;
print Data::Dumper->Dump([$text], ["metaField(s)"]);
}
|
<error>
#<error: I am confused in recordBody at $thisoffset!>
#startOfRecord: RECORDSTART recordBody(s /$/) RECORDEND
startOfRecord: RECORDSTART recordBody RECORDEND { $return = $item[1]
+}
|
#<error>
<error: I could not even parse a line line starting at $thiso
+ffset!>
_EOGRAMMAR_
#$skeletonPattern = "#input_type[ \t]*";
#my $metaFieldPattern = qr/[ \t]*#([^ \t]+)[ \t]+(.*)/o; # "#input_typ
+e SCDR+", "#filename processed_01_20080616001403.cdr", etc
#my $normalFieldPattern = qr/([ \t]*)([0-9]*)F[ \t]+([^ \t]+)[ \t]+([^
+ \t\r\n]+)(.*)/; # "1F S_Diagnostic1 62" OR " F S_Diagnostic1 62"
+OR " F S_Diagnostic1 62" are synonymous, etc
my $testData = <<'_EOGTESTA_';
RECORD
#input_id 91210758171x001_0013
#input_type PTC
#output_type MTC
#source_id 01
#filename TTFILE01-0001-20080101000000
#jingalama valuewith#inIt andaSpace
F ptc_record_length 00B6
F ptc_charging_start_time 20090604093721
F ptc_charging_end_time 20080604093721
F ptc_called_msrn_ton FF
F ptc_term_mcz_duration 060000
.
_EOGTESTA_
my $testData1 = <<'_EOGTESTA_';
RECORD
#input_id 91210758171x001_0013
#output_id
#input_type PTC
#output_type PTC
#addkey
#source_id 01
#filename TTFILE01-0001-20080101000000
F ptc_record_length 00B6
F ptc_record_type
F ptc_charging_start_time 20090604093721
F ptc_charging_end_time 20080604093721
F ptc_called_msrn_ton FF
F ptc_term_mcz_duration 060000
F ptc_term_mcz_change_direction
.
_EOGTESTA_
print $testData, "\n\n";
#<STDIN>;
my $parser = Parse::RecDescent->new($grammar);
$parser->startOfRecord($testData) or die "Bad input!\n";
Output is:
RECORD
#input_id 91210758171x001_0013
#input_type PTC
#output_type MTC
#source_id 01
#filename TTFILE01-0001-20080101000000
#jingalama valuewith#inIt andaSpace
F ptc_record_length 00B6
F ptc_charging_start_time 20090604093721
F ptc_charging_end_time 20080604093721
F ptc_called_msrn_ton FF
F ptc_term_mcz_duration 060000
.
* RECORDSTART -> RECORD
* Got metafield named 'input_id' with value '91210758171x001_0013'
* Got metafield named 'input_type' with value 'PTC'
* Got metafield named 'output_type' with value 'MTC'
* Got metafield named 'source_id' with value '01'
* Got metafield named 'filename' with value 'TTFILE01-0001-20080101000000'
* Got metafield named 'jingalama' with value 'valuewith#inIt andaSpace'
* metaField(s)
$metaField(s) = 'F ptc_record_length 00B6
F ptc_charging_start_time 20090604093721
F ptc_charging_end_time 20080604093721
F ptc_called_msrn_ton FF
F ptc_term_mcz_duration 060000
.
';
| [reply] [d/l] |