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

Suppressing capture of lexical regex with <.regex-name> doesn't work - works with <&regex-name> #1894

Closed
ronaldxs opened this issue Jun 1, 2018 · 2 comments

Comments

@ronaldxs
Copy link
Contributor

ronaldxs commented Jun 1, 2018

The Problem

$ perl6 -e 'my token t { t }; say so "t" ~~ /<.t>/'
No such method 't' for invocant of type 'Match'.

Update: it looks like this is a doc issue. If I don't hear back in a day or so I will move to doc ...

Expected Behavior

The Subrules section of the Regexes doc essentially suggests that capture suppression with <. should work on a lexical token but it does not.

Update: it looks like a doc error:
In roast S05-interpolation/lexicals.t#L10 it is done with my token abc {}; 'foo abc def' ~~ / <&abc> /

Steps to Reproduce

my regex line { \N*\n }
if "abc\ndef" ~~ /<line> def/ {
    say "First line: ", $<line>.chomp;      # OUTPUT: «First line: abc␤»
}

grammar G {
    regex g-line { \N*\n }
    regex line-def-cap { <g-line> def }
    regex line-def-no-cap { <.g-line> def }
}
say G.parse("abc\ndef", :rule('line-def-cap'));
say G.parse("abc\ndef", :rule('line-def-no-cap'));

# works ^ above but not \/ below
if "abc\ndef" ~~ /<.line> def/ {
    say "matched wo capture";
}

Environment

  • Operating system:
    Description: Ubuntu 14.04.5 LTS
    Codename: trusty

  • Compiler version (perl6 -v):
    This is Rakudo version 2018.05 built on MoarVM version 2018.05
    implementing Perl 6.c.

@ronaldxs ronaldxs changed the title Suppressing capture of lexical regex with <.regex-name> doesn't work Suppressing capture of lexical regex with <.regex-name> doesn't work - works with <&regex-name> Jun 1, 2018
@jnthn
Copy link
Member

jnthn commented Jun 1, 2018

Can conform that <.foo> is meant to always be a method call without capturing, and <&foo> always a lexical call without capturing.

@ronaldxs
Copy link
Contributor Author

ronaldxs commented Jun 1, 2018

Moved to doc issue #2087.

@ronaldxs ronaldxs closed this as completed Jun 1, 2018
JJ added a commit to Raku/doc that referenced this issue Jun 6, 2018
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

2 participants