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

Separators in infix:<**> expression can't be captured in Rakudo #2401

Closed
p6rt opened this issue Apr 9, 2011 · 9 comments
Closed

Separators in infix:<**> expression can't be captured in Rakudo #2401

p6rt opened this issue Apr 9, 2011 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 9, 2011

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

Searchable as RT88128$

@p6rt
Copy link
Author

p6rt commented Apr 9, 2011

From @masak

<colomon> rakudo​: if 'eggs, milk, sugar and flour' ~~ m/​:s (\w+) ** \,
'and' (\w+)/ { say 'list​: ', $/[0].join(' | '); say 'end​: ', $/[1]; }
else { say 'no match' }
<p6eval> rakudo 4bf132​: OUTPUT«list​: eggs | milk | sugar␤end​: flour␤»
<masak> rakudo​: if 'eggs, milk, sugar and flour' ~~ m/​:s (\w+) ** (\,
| 'and')/ { say $0.join(' | '); say $1.join(' | ') }
<p6eval> rakudo 4bf132​: OUTPUT«eggs | milk | sugar | flour␤␤»
<masak> hm. why aren't my separators captured in $1 above?
<jnthn> masak​: This looks familiar...
<jnthn> masak​: I think ti's a bug.
<masak> jnthn​: do you think it's a reported bug? :)
<jnthn> masak​: Not sure. I mostly recall working around it in the Perl
6 grammar somewhere at some point.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented May 1, 2013

From @dwarring

  $ perl6 --version
  This is perl6 version 2013.04-22-gd2af402 built on parrot 5.2.0 revision
RELEASE_5_2_0
  $ cat g.pl
  grammar G {
  token TOP {<letter> +% <sep>}
  token letter{<[a..z]>}
  token sep{\,}
  }

  say G.parse("a,b,c,d").caps.map({$_.value});

  $ perl6 g.pl
  a b c , d

I'd have expected​: a , b , c , d

This is the first time I've tried to use '%' in a capture. Rakudo star
2013.02 also does the same.

- David

@p6rt
Copy link
Author

p6rt commented May 3, 2013

From @FROGGS

I'm not sure your report is valid​:

$ cat dev/g.pl
grammar G {
  token TOP {<letter> +% <sep>}
  token letter{<[a..z]>}
  token sep{\,}
}

say G.parse("a,b,c,d");

$ perl6 dev/g.pl
「a,b,c,d」
letter => 「a」
letter => 「b」
letter => 「c」
sep => 「,」
letter => 「d」

@p6rt
Copy link
Author

p6rt commented May 3, 2013

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

@p6rt
Copy link
Author

p6rt commented May 3, 2013

From @dwarring

It's inconsistent with the %% separator. This also also lets me catch
variable operators. e.g.

grammar G {
  token TOP {<letter> +%% <sep>}
  token letter{<[a..z]>}
  token sep{\,|\;}
}

say G.parse("a;b,c,d");
「a;b,c,d」

letter => 「a」
sep => 「;」
letter => 「b」
sep => 「,」
letter => 「c」
sep => 「,」
letter => 「d」

On Fri, May 3, 2013 at 7​:30 PM, Tobias Leich via RT <
perl6-bugs-followup@​perl.org> wrote​:

I'm not sure your report is valid​:

$ cat dev/g.pl
grammar G {
token TOP {<letter> +% <sep>}
token letter{<[a..z]>}
token sep{\,}
}

say G.parse("a,b,c,d");

$ perl6 dev/g.pl
「a,b,c,d」
letter => 「a」
letter => 「b」
letter => 「c」
sep => 「,」
letter => 「d」

@p6rt
Copy link
Author

p6rt commented May 3, 2013

From @pmichaud

Now fixed in 4741028​:

  pmichaud@​kiwi​:~/p6/rakudo$ cat g.pl
  grammar G {
  token TOP {<letter> +% <sep>}
  token letter{<[a..z]>}
  token sep{\,}
  }
 
  say G.parse("a,b,c,d").caps.map({$_.value});
 
  pmichaud@​kiwi​:~/p6/rakudo$ ./perl6 g.pl
  a , b , c , d
  pmichaud@​kiwi​:~/p6/rakudo$

Needs tests to resolve the ticket.

@p6rt
Copy link
Author

p6rt commented May 5, 2013

@dwarring - Status changed from 'open' to 'resolved'

@p6rt
Copy link
Author

p6rt commented May 6, 2013

From @dwarring

Thanks for that. I've added a couple of tests to roast/S05-capture/caps.t.

Raku/roast@bc4c9a5

Hope these help.

On Sat, May 4, 2013 at 7​:45 AM, Patrick R. Michaud via RT <
perl6-bugs-followup@​perl.org> wrote​:

Now fixed in 4741028​:

pmichaud@&#8203;kiwi&#8203;:\~/p6/rakudo$ cat g\.pl
grammar G \{
    token TOP \{\<letter> \+% \<sep>\}
    token letter\{\<\[a\.\.z\]>\}
    token sep\{\\,\}
\}

say G\.parse\("a,b,c,d"\)\.caps\.map\(\{$\_\.value\}\);

pmichaud@&#8203;kiwi&#8203;:\~/p6/rakudo$ \./perl6 g\.pl
a , b , c , d
pmichaud@&#8203;kiwi&#8203;:\~/p6/rakudo$

Needs tests to resolve the ticket.

@p6rt
Copy link
Author

p6rt commented Jun 9, 2013

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

@p6rt p6rt closed this as completed Jun 9, 2013
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant