Created
September 25, 2017 22:58
-
-
Save softmoth/e63b4920d89970620bcd96d4ce065420 to your computer and use it in GitHub Desktop.
match within action method?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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