| Newsgroups |
perl.recdescent |
| Message-ID |
<[email protected]> |
Could anyone relieve my ignorance and clue me in as to why the following grammar
won't parse the second test line (0810-0850) when the first line (0800-0850)
parses fine?
thanks,
Ken
use Parse::RecDescent;
my $parse = Parse::RecDescent->new(join '', <DATA>) or die "Bad Grammar!";
my @text = (
"0800-0850 \n",
"0810-0850 \n",
);
for my $line (@text)
{
my $x = $parse->cronSeg($line) or die "$line is NOT parsable!!\n";
}
__DATA__
cronSeg: TimeRange(s /;/) EOL {print "Found conSeg\n"}
TimeRange:
/\d{2}/ /:?/ /\d{2}/ '-' /\d{2}/ /:?/ /\d{2}/
{
print "Hr1:$item[1], Min1:$item[3], Hr2:$item[5],
Min2:$item[7]\n";
return "$item[1]$item[3] - $item[5]$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)
}
| '*' {$return = "0000 - 2359"; print "$item[0] $return\n"}
| <error>
EOL: /$/
comment: /#.*/
{print "found comment\n";}
emptyLine: /^\s*$/
{print "found emptyLine\n";}