Created
August 24, 2016 20:34
-
-
Save awwaiid/488cb1ef1d1b68eb6f7d86fcd314eaa8 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
> 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 | |
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
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