Why would the following grammar not parse the test case? Note: it's
(apparently) failing on the terminating X.
Ken
use Parse::RecDescent;
my $parse = Parse::RecDescent->new(join '', <DATA>) or die "Bad Grammar!";
my $a = "0800-0850 X";
my $x = $parse->cronSeg($a);
if ($x)
{
print "x=$x $a parsed successfully!\n";
}
else
{
print "$a is NOT parsable!!\n";
}
__DATA__
cronSeg: TimeRange(s /;/) EOL {print "Found cronSeg\n"}
EOL: /X/ {return 1}
TimeRange:
/\d{2}/ /:?/ /\d{2}/ '-' /\d{2}/ /:?/ /\d{2}/
{
print "Hr1:$item[1], Min1:$item[3], Hr2:$item[5], Min2:$item[7]";
if ($item[1] >= 0 and $item[1] < 24 and $item[5] >= 0 and
$item[5] < 24 and
$item[3] >= 0 and $item[3] < 60 and $item[7] >= 0 and
$item[7] < 60)
{
print " ... passed IF\n";
return 1;
}
else
{
print " ... FAILED IF\n";
return 0;
}
}
| '*' {$return = "0000 - 2359"; print "$item[0] $return\n"}
| <error>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.