Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Forked from anonymous/gist:e0befbf2f05fd84e1c5b
Last active March 15, 2016 21:10
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 FROGGS/8c9556cf97fb301f8f84 to your computer and use it in GitHub Desktop.
Save FROGGS/8c9556cf97fb301f8f84 to your computer and use it in GitHub Desktop.
v6;
grammar BUU {
token TOP { <abc>+ };
token abc { ('a') <bc>* };
token bc { [ ('b') <c>* ]+ }
token c { 'c' };
};
class BuuAbc {
method TOP($/) { make "TOP" => $<abc>>>.ast; }
method abc($/) { make ~$0 => $<bc>>>.ast; }
method bc($/) { make ~$0 => $<c>>>.ast; }
method c($/) { make 3; }
};
my $r = BUU.parse( "abcabccabbccaababc", :actions( BuuAbc ) );
say $r.ast;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment