Created
March 15, 2016 19:36
-
-
Save perlpilot/742924b6e1f6ffc6d1d6 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
v6; | |
grammar BUU { | |
token TOP { <abc>+ }; | |
token abc { 'a' <bc>* }; | |
token bc { [ 'b' <c>* ]+ } | |
token c { 'c' }; | |
}; | |
# default result | |
class BuuAbc1 { | |
method TOP($/) { make $<abc>>>.ast; } | |
method abc($/) { make $<bc>>>.ast; } | |
method bc($/) { make $<c>>>.ast; } | |
method c($/) { make ~$/; } | |
}; | |
class BuuAbc2 { | |
method TOP($/) { make $<abc>>>.ast; } | |
method abc($/) { make $<bc>>>.ast; } | |
method bc($/) { make ~@$<c>>>.ast; } | |
method c($/) { my $c = 3; make 3; } | |
}; | |
my $r = BUU.parse( "abcabccaabbc", :actions( BuuAbc2 ) ); | |
say $r.ast; | |
say $r; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment