-
-
Save zoffixznet/b5197dec7acc1c40b07fe4e482bbe45d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
use NQPHLL:from<NQP>; | |
BEGIN $*LANG.refine_slang: 'MAIN', | |
role { | |
token scope_declarator:sym('I HAZ A') { | |
<sym> <scoped('my')> | |
} | |
token scope_declarator:sym('WE HAZ A') { | |
<sym> <scoped('our')> | |
} | |
token multi_declarator:sym<LOTZA> { | |
:my $*LINE_NO := HLL::Compiler.lineof(self.orig(), self.from(), :cache(1)); | |
<sym><.kok> :my $*MULTINESS := 'multi'; | |
[ <?before '('> { $*W.throw($/, 'X::Anon::Multi', multiness => $*MULTINESS) } ]? | |
[ <declarator> || <routine_def('sub')> || <.malformed('multi')> ] | |
} | |
token initializer:sym<ITZ> { | |
<sym> <.ws> <EXPR('e=')> | |
} | |
token term:sym<multi_declarator> { | |
<?before 'multi'|'proto'|'only'|'LOTZA'> <multi_declarator> | |
} | |
}, | |
role { | |
sub lookup-key(Mu \h, \k) { | |
nqp::atkey(nqp::findmethod(h, 'hash')(h), k) | |
} | |
method scope_declarator:sym('I HAZ A')(Mu $/) { | |
$/.make: lookup-key($/, 'scoped').ast | |
} | |
method scope_declarator:sym('WE HAZ A')(Mu $/) { | |
$/.make: lookup-key($/, 'scoped').ast | |
} | |
method multi_declarator:sym<LOTZA>(Mu $/) { | |
my \declarator = lookup-key($/, 'declarator'); | |
$/.make: declarator ?? declarator.ast !! lookup-key($/, 'routine_def').ast; | |
} | |
method initializer:sym<ITZ>(Mu $/) { | |
$/.make: lookup-key($/, 'EXPR').ast | |
} | |
} | |
{ | |
our sub HAI(|args) { say |args } | |
WE HAZ A $CHEEZBURGER ITZ 'HELLA FRICKIN EPIC'; | |
HAI $CHEEZBURGER; | |
{ | |
LOTZA sub HALLO { say 'HALLO' }; | |
HALLO; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment