Created
September 4, 2012 16:14
-
-
Save pmichaud/3622948 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
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