Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created June 22, 2016 17:57
Show Gist options
  • Save bduggan/ffa974a931e592ad61c8e5e012297225 to your computer and use it in GitHub Desktop.
Save bduggan/ffa974a931e592ad61c8e5e012297225 to your computer and use it in GitHub Desktop.
use nqp;
use QAST:from<NQP>;
sub EXPORT(|) {
role MOSDEF::Grammar {
token def { [ \'.*?\' || \".*?\" || .]*? )> <before ';'> } # '
rule routine_declarator:def { <sym> <routine_def('def')> }
rule routine_declarator:sym<def> { <sym> <def> }
}
role MOSDEF::Actions {
method routine_declarator:sym<def>($/) {
# self.routine_declarator:def:sym<sub>($/);
# say 'making def';
# make $<routine_def>.ast;
}
}
nqp::bindkey(%*LANG, 'MAIN', %*LANG<MAIN>.HOW.mixin(%*LANG<MAIN>, MOSDEF::Grammar));
nqp::bindkey(%*LANG, 'MAIN-actions', %*LANG<MAIN-actions>.HOW.mixin(%*LANG<MAIN-actions>, MOSDEF::Actions));
{}
}
use v6;
use lib '.';
use mosdef;
BEGIN {
say 'declaring with def';
}
def foo {
say 'hi'
};
say 'calling foo';
foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment