Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created September 4, 2012 16:14
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 pmichaud/3622948 to your computer and use it in GitHub Desktop.
Save pmichaud/3622948 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/nqp$ cat eek.nqp
use NQPHLL;
class thing::Grammar is HLL::Grammar {
token TOP { <command> }
token command { 'eek' }
}
class thing::Actions is HLL::Actions {
method TOP($/) {
make QAST::CompUnit.new(QAST::Block.new($<command>.ast));
}
method command($/) {
make QAST::IVal.new( :value(3) )
}
}
class thing::Compiler is HLL::Compiler {}
sub MAIN(*@ARGS) {
my $compiler := thing::Compiler.new();
$compiler.language('thing');
$compiler.parsegrammar(thing::Grammar);
$compiler.parseactions(thing::Actions);
$compiler.command_line(@ARGS);
}
pmichaud@kiwi:~/p6/nqp$ ./nqp eek.nqp
> eek
3
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment