Skip to content

Instantly share code, notes, and snippets.

@msporleder
Created January 11, 2016 16:19
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 msporleder/ae031c2829d58f5d7267 to your computer and use it in GitHub Desktop.
Save msporleder/ae031c2829d58f5d7267 to your computer and use it in GitHub Desktop.
#!/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