Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 59 lines (51 sloc) 1.246 kb
#!/usr/bin/env perl6
use v6;
use Yapsi;
my @TARGETS = <run future sic>;
sub run-code($program, :$target) {
try {
my @output;
given Yapsi::Compiler.new {
@output = $target eq 'future'
?? .to-future($program)
!! .compile($program);
warn $_ for .warnings;
}
if $target eq 'run' {
my Yapsi::Runtime $runtime .= new;
$runtime.run(@output);
}
else {
.say for @output;
}
}
say $! if $!;
}
if @*ARGS && @*ARGS[0] eq '--version' {
my $revision = qx[git describe];
say "This is Yapsi, revision $revision";
shift @*ARGS;
}
my $target = 'run';
if @*ARGS && @*ARGS[0] ~~ /'--target='(\w+)/ {
die "Recognized targets: {@TARGETS}"
unless $0.lc eq any @TARGETS;
$target = $0.lc;
shift @*ARGS;
}
if @*ARGS == 2 && @*ARGS[0] eq '-e' {
run-code(@*ARGS[1], :$target);
}
elsif @*ARGS == 1 {
run-code(slurp(@*ARGS[0]), :$target);
}
elsif @*ARGS == 0 {
while prompt(">>> ") -> $program {
run-code($program, :$target);
}
say '';
}
else {
die
"Usage: `$*PROGRAM_NAME \[<file>\]` or `$*PROGRAM_NAME -e '<program>'`";
}
Jump to Line
Something went wrong with that request. Please try again.