Skip to content

Instantly share code, notes, and snippets.

@softmoth
Created September 25, 2017 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save softmoth/e63b4920d89970620bcd96d4ce065420 to your computer and use it in GitHub Desktop.
Save softmoth/e63b4920d89970620bcd96d4ce065420 to your computer and use it in GitHub Desktop.
match within action method?
#! /usr/bin/env perl6
grammar G {
rule TOP { <hi>+ %% <.line-end> }
token hi { hi }
token line-end { \n }
}
class A {
method TOP ($/) {
my $res = $<hi>.join(' ');
# Cannot assign to a readonly variable ($/) or a value
if $res.match(/ "hi hi" /) {
note "HI HI";
}
}
}
G.parse("hi\nhi\r\nhi\rhi\r\n", :actions(A.new));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment