Created
January 11, 2016 16:19
-
-
Save msporleder/ae031c2829d58f5d7267 to your computer and use it in GitHub Desktop.
This file contains 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 | |
use v6; | |
my $one = "hello one\ntwo three"; | |
grammar Foo { | |
#token TOP { <thebeginning>.+$ } #will not trigger the 'theend' action method | |
#token TOP { ^.+<theend> } #will not trigger 'thebeginning' action method | |
token TOP { <thebeginning>.+<theend> } #will trigger both | |
token thebeginning { ^ } | |
token theend { $ } | |
} | |
class FooAction { | |
method thebeginning($/) { | |
say "in the beginning"; | |
} | |
method theend($/) { | |
say "there is an end"; | |
} | |
} | |
say "parsing"; | |
my $a = FooAction.new; | |
my $m = Foo.parse($one, :actions($a)); | |
say "it's over"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment