Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quantified subrule capture not saved #2593

Closed
p6rt opened this issue Dec 29, 2011 · 6 comments
Closed

quantified subrule capture not saved #2593

p6rt opened this issue Dec 29, 2011 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 29, 2011

Migrated from rt.perl.org#107254 (status was 'resolved')

Searchable as RT107254$

@p6rt
Copy link
Author

p6rt commented Dec 29, 2011

From @softmoth

Here is a test case where the match succeeds, but the match object
doesn't save the subrule capture in some cases​:

grammar G {
  rule TOP { ^ <w1> <w2>? <w3>? $ }
  token w1 { \w+ }
  token w2 { \w+ }
  token w3 { \w+ }
}

my @​tests =
  'one two three',
  'one two',
  ;

for @​tests -> $line {
  my $match = G.parse($line);
  say ($match, $match<w1>, $match<w2>, $match<w3>).map({"[$_]"}).join(', ');
}

$ nom --version
This is perl6 version 2011.12-10-ga9bead6 built on parrot 3.11.0
revision RELEASE_3_11_0
$ nom t2.pl
[one two three], [one], [two], [three]
[one two], [one]

Notice in the second line it is missing the final ", [two]" in the
output. This is because the w2 capture is missing in the Match object.

This works in rakudo-ng​:

$ perl6 --version

This is Rakudo Perl 6, version 2011.07-2-g1b7dd12 built on parrot
3.6.0 RELEASE_3_6_0

Copyright 2008-2011, The Perl Foundation

$ perl6 t2.pl
[one two three], [one], [two], [three]
[one two], [one], [two], []
$

Tim

@p6rt
Copy link
Author

p6rt commented Mar 30, 2012

From @moritz

On Rakudo Argentina-27-g5793035, observe​:

grammar FAIL {
  token TOP { ^[ '?' <digit> ]? [ '#' <digit> ]? $ };
}

my $m = FAIL.parse('?5');
say "full match​: '$m'";
say " digit​: '$m<digit>'";
say " keys​: $m.keys()";

produces this output​:

full match​: '?5'
  digit​: ''
  keys​: digit

Which, as you can plainly see, makes no sense at all.
The regex matches, and the fact that $m.keys returns 'digit' both mean
that the <digit> call succeeded. But $m<digit> stringifies to '' (it
happens to be an empty Parcel, should be Parcel with a single,
successful Match object, or that Match object straight away; not sure
what rules the ? quantifiers follow right now).

This bug stops URI.pm from working, and thus also blocks LWP​::Simple. Nasty.

--
Moritz Lenz
http://perlgeek.de/ | http://perl-6.de/ | http://sudokugarden.de/

@p6rt
Copy link
Author

p6rt commented Mar 31, 2012

From @ronaldxs

After a bit of searching through rt I came up with a similar bug report​:
rt 107254 @​ https://rt-archive.perl.org/perl6/Ticket/Display.html?id=107254.

Ron

@p6rt
Copy link
Author

p6rt commented Mar 31, 2012

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 17, 2012

From @moritz

fixed by pmichaud, tested (both examples) in S05-capture/subrule.t.

@p6rt
Copy link
Author

p6rt commented May 17, 2012

@moritz - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed May 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant