Fix let syntax

This commit is contained in:
madmaurice 2021-04-02 01:02:35 +02:00
parent 72141ffde6
commit 222c8dfc8b

View file

@ -202,21 +202,32 @@ sub macro_let {
while ($ts->[0]->{type} != RPAREN)
{
my $ident = shift @$ts;
die "Expected identifier in let" unless $ident->{type} == IDENT;
$tok = shift @$ts;
die "Expected pair in parameter list in let" unless $tok->{type} == LPAREN;
my $assignment = parser_expr($ts);
my $ident = shift @$ts;
die "Expected identifier in pair in parameter list in let" unless $ident->{type} == IDENT;
my $assignment;
if ($ts->[0]->{type} == RPAREN)
{
$assignment = sub { return undef };
}
else
{
$assignment = parser_expr($ts)
}
$tok = shift @$ts;
die "Expected ) after parameter pair" unless $tok->{type} == RPAREN;
$pctx->{$ident->{value}} = $assignment;
}
$tok = shift @$ts;
die "Expected ) after assignments in let" unless $tok->{type} == RPAREN;
die "Expected ) after parameter list in let" unless $tok->{type} == RPAREN;
my $inner = parser_expr($ts);
$tok = shift @$ts;
die "Expected ) after let" unless $tok->{type} == RPAREN;
my $inner = macro_progn($ts);
return sub {
my $octx = shift;