perlquestion
diotalevi
<p>Hi all, I think my grammar's <c>thing</c> rule should have captured <c>$+{thing}</c>. It didn't. What did I miss?</p>
<c>use Test::More tests => 1;
use Data::Dumper;
'cow' =~ /
(?:
# Grammar rules go here...
(?<thing> .+ )
){0}
# Invoke grammar here
^(?&thing)
/x
or die "Didn't match";
my $got = Dumper({
'%+' => {%+},
'@+' => [@+],
'@-' => [@-],
});
my $expected = Dumper({
'%+' => {
thing => 'cow'
},
'@-' => [ 0, 0 ],
'@+' => [ 3, 3 ],
});
is( $got, $expected );</c><p>Test results:</p><c># Failed test at bin/ooga.pl line 24.
# got: '$VAR1 = {
# '%+' => {},
# '@-' => [
# '0'
# ],
# '@+' => [
# '1',
# undef
# ]
# };
# '
# expected: '$VAR1 = {
# '%+' => {
# 'thing' => 'cow'
# },
# '@-' => [
# 0,
# 0
# ],
# '@+' => [
# 3,
# 3
# ]
# };
# '</c>