Subject: | Extra space added to array elements in a rule |
Thanks for this very useful module! I just want to make you aware of a minor issue I had (looks like a bug to me). Consider following code:
use strict;
use warnings;
use Regexp::Grammars;
my $parser = qr{
<[item]>+
<rule: item> \w+
}x;
my $text = 'itemA itemB itemC';
if ($text =~ $parser) {
print "'$_'\n" for (@{ $/{item} });
}
The output is:
'itemA'
' itemB'
' itemC'
Notice the space in front of the second and third item. Expected output (since \w does not match a space):
'itemA'
'itemB'
'itemC'
or the expected output should simply be none/empty (i.e.: parse failed), since I did not explicitly specify the delimiter space. For example, changing the parser to:
my $parser = qr{
<[item]>+ % <.ws>
<rule: item> \w+
}x;
gives the expected output above.
Have a nice day.
Best regard,
Håkon Hægland