Skip to content

Instantly share code, notes, and snippets.

@TimToady
Created March 10, 2017 00:15
Show Gist options
  • Save TimToady/474bdc4ac6f6035015ec9745bdcdf62c to your computer and use it in GitHub Desktop.
Save TimToady/474bdc4ac6f6035015ec9745bdcdf62c to your computer and use it in GitHub Desktop.
use nqp;
grammar fee { }
my $b := fee."!cursor_init"("bar",:0p);
say "simple grammar has a " ~ nqp::getattr($b,Cursor,"\$!braid").^name;
nqp::getattr($b, Cursor, '$!braid')."!dump"('fee');
role foo { }
my $l := $?LANG;
my $NQPCursor;
for $l.^mro {
if .^name eq 'NQPCursor' { $NQPCursor := $_; last }
}
my $c := $l.HOW.mixin($l,foo)."!cursor_init"("bar",:p(0));
"mixed-in grammar attributes:".say;
.name.say for $c.^attributes;
say "Mixed in grammar .braid method returns a " ~ $c.braid.^name;
nqp::getattr($l, $NQPCursor, '$!braid')."!dump"('foo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment