-
-
Save Skarsnik/b6ada1e5249106024bc3bb373d8f1e8c 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; | |
module SNES-SLANG { | |
my role SNES-ASM { | |
token statement_control:sym<SNES> { | |
<sym> | |
<thing>+ | |
';' | |
} | |
token thing { | |
<instruction> <.ws> <endofinstr> | |
} | |
token endofinstr { | |
':' | |
} | |
token instruction { | |
<singleop> | <opwitharg> | |
} | |
token singleop { | |
'rtl' | |
} | |
token opwitharg { | |
<twoopcode> <.ws> <argop> | |
} | |
token twoopcode { | |
'lda' | 'sta' | 'jmp' | |
} | |
token argop { | |
'$' <.xdigit>+ | |
} | |
} | |
my role SNES-Action { | |
method statement_control:sym<SNES>(Mu $/) { | |
make-snes-bytecode($/); | |
} | |
} | |
sub make-snes-bytecode($match) { | |
say "make bytecode", $match; | |
} | |
sub EXPORT (|) { | |
say "Export"; | |
$*LANG.define_slang('MAIN', | |
$*LANG.slang_grammar('MAIN').^mixin(SNES-ASM), | |
$*LANG.actions.^mixin(SNES-Action)); | |
{} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment