Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created August 25, 2016 11:48
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 bduggan/dbd656d9e6280331fccb141295798b65 to your computer and use it in GitHub Desktop.
Save bduggan/dbd656d9e6280331fccb141295798b65 to your computer and use it in GitHub Desktop.
use lib '.';
use Dogdo;
dog { say "woof" }
use nqp;
use QAST:from<NQP>;
# Slang to make "dog" a synonym for "do"
role Dogdo::Grammar {
token statement_prefix:sym<dog> { <sym><.kok> <blorst> }
}
role Dogdo::Actions {
method statement_prefix:sym<dog>(Mu $/) {
say $/.dump;
make QAST::Op.new( :op('call'), $<blorst>.ast );
}
}
sub EXPORT {
nqp::bindkey(%*LANG, 'MAIN', %*LANG<MAIN>.HOW.mixin(%*LANG<MAIN>, Dogdo::Grammar));
nqp::bindkey(%*LANG, 'MAIN-actions', %*LANG<MAIN-actions>.HOW.mixin(%*LANG<MAIN-actions>, Dogdo::Actions));
{}
}
===SORRY!===
X::Multi::NoMatch exception produced no message
- sym: dog
- blorst: { say "woof" }
- block: { say "woof" }
- blockoid: { say "woof" }
- statementlist: say "woof"
- statement: 1 matches
- EXPR: say "woof"
- longname: say
- name: say
- identifier: say
- args: "woof"
- arglist: "woof"
- EXPR: "woof"
- value: "woof"
- quote: "woof"
- nibble: woof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment