Skip to content

Instantly share code, notes, and snippets.

@ugexe

ugexe/z.pl6 Secret

Last active August 29, 2015 14:24
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 ugexe/b3de0a3a78290061f116 to your computer and use it in GitHub Desktop.
Save ugexe/b3de0a3a78290061f116 to your computer and use it in GitHub Desktop.
use nqp;
use Perl6::Grammar:from<NQP>;
use Perl6::Actions:from<NQP>;
use Perl6::Compiler:from<NQP>;
my $self = $?FILE.IO;
sub compile(*@files, Bool :$moar, Bool :$jvm, :$encoding, :$output, |c) {
for <moar jvm> -> $backend {
next if $backend eq 'jvm' && !$jvm;
next if $backend eq 'moar' && !$moar;
my ($target, $ext) = $backend.starts-with('moar')
?? ('mbc','moarvm')
!! $backend.starts-with('jvm')
?? ('jvm', 'jar')
!! ('ast', 'ast');
for @files -> $file {
my $output = "{$file}.{$ext}";
my $grammar = Perl6::Grammar.new;
my $actions = Perl6::Actions.new;
my $compiler = Perl6::Compiler.new;
$compiler.parseactions($actions);
$compiler.parsegrammar($grammar);
$compiler.compile($file, :$output, :$target, :$encoding, |c);
}
}
}
compile($self.IO.basename, :moar, :ll-exception(1), :encoding('utf8'));
@ugexe
Copy link
Author

ugexe commented Jul 8, 2015

nickl@localhost:~/perl6$ perl6 z.pl6
===SORRY!=== Error while compiling z.pl6
Undeclared routine:
    z used at line 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment