Skip to content

Instantly share code, notes, and snippets.

@awwaiid

awwaiid/example.txt

Created Aug 24, 2016
Embed
What would you like to do?
> 5+5
10
> next
CONTROL: Died with CX::Next
EXCEPTION: control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
> last
CONTROL: Died with CX::Last
EXCEPTION: control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
> return
CONTROL: Died with CX::Return
EXCEPTION: control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
> die 'hmm'
EXCEPTION: hmm
in block <unit> at EVAL_4 line 1
in sub eval at simple-repl.p6 line 11
in block <unit> at simple-repl.p6 line 34
CONTROL: Died with CX::Next
in block at simple-repl.p6 line 40
in block <unit> at simple-repl.p6 line 21
control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
use MONKEY-SEE-NO-EVAL;
sub eval($code) {
CONTROL {
say "CONTROL: {$_.gist}";
die "control exception";
}
EVAL $code;
}
my @cmds =
"5+5",
"next",
"last",
"return",
"die 'hmm'";
REPL: loop {
print "> ";
# Normally this reads from STDIN, here read from list for test
# my $code = get;
my $code = shift @cmds;
say $code;
# EOF
if !$code.defined {
last REPL;
}
my $result = eval $code;
say $result;
CATCH {
say "EXCEPTION: {$_.gist}";
next REPL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.