Implement progn style base level

This commit is contained in:
madmaurice 2021-04-02 02:45:49 +02:00
parent 39d791fcf4
commit 65f17aba82

View file

@ -121,7 +121,7 @@ my %stdctx = (
sub parser {
my @tokens = @_;
my $expr = parser_expr(\@tokens);
my $expr = parser_prog(\@tokens);
return sub {
my $ctx = shift;
@ -131,6 +131,24 @@ sub parser {
}
}
sub parser_prog {
my $ts = shift;
my @steps;
while (scalar @$ts)
{
push @steps, parser_expr($ts);
}
return sub {
my $ctx = shift;
my $result;
$result = $_->($ctx) foreach (@steps);
return $result;
}
}
sub parser_expr {
my $ts = shift;
my $tok = shift @$ts;