Subject: | adding optional subgroup causes match failures later |
With '(?&PerlStatement)?' commented out:
$ cat ppr-bah.pl
#!/usr/bin/env perl
use strict;
use warnings;
use PPR;
my $code = <<'_EOT_';
use constant PRESSURE => <<X;
X
<<<<<<A
42
A
_EOT_
$code =~ m{
\A
(?&PerlUseStatement)
(?&PerlOWS)
# (?&PerlStatement)?
<<<<<<A
(?&PerlOWS)
( (?&PerlLiteral) )
$PPR::GRAMMAR
}x
or die "No match";
print "Found literal: [$1]\n";
__END__
$ perl ppr-bah.pl
Found literal: [42]
With '(?&PerlStatement)?' active:
$ cat ppr-bah.pl
#!/usr/bin/env perl
use strict;
use warnings;
use PPR;
my $code = <<'_EOT_';
use constant PRESSURE => <<X;
X
<<<<<<A
42
A
_EOT_
$code =~ m{
\A
(?&PerlUseStatement)
(?&PerlOWS)
(?&PerlStatement)?
<<<<<<A
(?&PerlOWS)
( (?&PerlLiteral) )
$PPR::GRAMMAR
}x
or die "No match";
print "Found literal: [$1]\n";
__END__
$ perl ppr-bah.pl
No match at ppr-bah.pl line 17.