Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created November 11, 2011 15:16
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 tadzik/1358234 to your computer and use it in GitHub Desktop.
Save tadzik/1358234 to your computer and use it in GitHub Desktop.
grammar bug {
token TOP {
<zebra> *
}
token zebra {
'zebra'
}
}
class bug::actions {
method TOP($/) {
say 'keys: ', $/.keys.perl;
say 'elems: ', $<zebra>.elems;
say 'elems2: ', $<zebra>[0].elems;
make 'whatever';
}
method zebra($/) {
make ~$/
}
}
my $a = 'zebrazebrazebra';
my $ast = bug.parse($a, :actions(bug::actions.new)).ast;
say $ast.perl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment