Skip to content

Commit

Permalink
fixup [expr]
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Sep 8, 2012
1 parent b0ae2f9 commit f2aa12c
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Partcl/commands/expr.pm
@@ -1,25 +1,25 @@
#sub expr(*@args) {
# my $code := pir::join(' ', @args);
# error("empty expression\nin expression \"\"")
# if $code eq '';
#
# our %EXPRCACHE;
# my &sub := %EXPRCACHE{$code};
# unless pir::defined(&sub) {
# my $parse :=
# Partcl::Grammar.parse(
# $code,
# :rule('TOP_expr'),
# :actions(Partcl::Actions)
# );
# if $parse {
# &sub := PAST::Compiler.compile($parse.ast);
# %EXPRCACHE{$code} := ⊂
# } else {
# error("Invalid expression");
# }
# }
# &sub();
#}
#
## vim: expandtab shiftwidth=4 ft=perl6:
sub expr(*@args) {
my $code := nqp::join(' ', @args);
error("empty expression\nin expression \"\"")
if $code eq '';

our %EXPRCACHE;
my &sub := %EXPRCACHE{$code};
unless nqp::defined(&sub) {
my $parse :=
Partcl::Grammar.parse(
$code,
:rule('TOP_expr'),
:actions(Partcl::Actions)
);
if $parse {
&sub := PAST::Compiler.compile($parse.ast);
%EXPRCACHE{$code} := ⊂
} else {
error("Invalid expression");
}
}
&sub();
}

# vim: expandtab shiftwidth=4 ft=perl6:

0 comments on commit f2aa12c

Please sign in to comment.