Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
empty expression should error.
  • Loading branch information
coke committed Dec 4, 2009
1 parent 14329c2 commit b1c7707
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
6 changes: 0 additions & 6 deletions TODO
Expand Up @@ -4,12 +4,6 @@ Big Goals

Tasks/Bugs:

* empty expr should die:

% expr ""
empty expression
in expression ""

* regexp $re $str (blocker for t/tcl_time.t)
* regsub -all <exp> <string> <replace>
* Need to throw an exception when trying to convert something to an
Expand Down
28 changes: 16 additions & 12 deletions src/Partcl/commands/main.pm
Expand Up @@ -118,19 +118,23 @@ our sub exit(*@args) {

our sub expr(*@args) {
my $code := pir::join(' ', @args);
our %EXPRCACHE;
my &sub := %EXPRCACHE{$code};
unless pir::defined__IP(&sub) {
my $parse :=
Partcl::Grammar.parse(
$code,
:rule('TOP_expr'),
:actions(Partcl::Actions)
);
&sub := PAST::Compiler.compile($parse.ast);
%EXPRCACHE{$code} := &sub;
if $code ne '' {
our %EXPRCACHE;
my &sub := %EXPRCACHE{$code};
unless pir::defined__IP(&sub) {
my $parse :=
Partcl::Grammar.parse(
$code,
:rule('TOP_expr'),
:actions(Partcl::Actions)
);
&sub := PAST::Compiler.compile($parse.ast);
%EXPRCACHE{$code} := &sub;
}
&sub();
} else {
error("empty expression\nin expression \"\"");
}
&sub();
}

our sub for(*@args) {
Expand Down

0 comments on commit b1c7707

Please sign in to comment.