Skip to content

Instantly share code, notes, and snippets.

@Skarsnik
Created November 19, 2021 20:21
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 Skarsnik/b6ada1e5249106024bc3bb373d8f1e8c to your computer and use it in GitHub Desktop.
Save Skarsnik/b6ada1e5249106024bc3bb373d8f1e8c to your computer and use it in GitHub Desktop.
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