Improve macro parsing
This commit is contained in:
parent
c909c8880d
commit
ed59a6a04e
1 changed files with 8 additions and 10 deletions
|
@ -420,7 +420,10 @@ sub parser_call {
|
|||
if (defined $macros{$name})
|
||||
{
|
||||
shift @$ts;
|
||||
return $macros{$name}->($ts);
|
||||
my $parsed = $macros{$name}->($ts);
|
||||
my $rpar = shift @$ts;
|
||||
die "Expected ) after macro $name" unless $rpar->{type} == RPAREN;
|
||||
return $parsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,8 +479,8 @@ sub macro_let {
|
|||
$pctx->{$ident->{value}} = $assignment;
|
||||
}
|
||||
|
||||
$tok = shift @$ts;
|
||||
die "Expected ) after parameter list in let" unless $tok->{type} == RPAREN;
|
||||
die "Expected ) after parameter list in let" unless $ts->[0]->{type} == RPAREN;
|
||||
shift @$ts;
|
||||
|
||||
my $inner = macro_progn($ts);
|
||||
|
||||
|
@ -510,8 +513,7 @@ sub macro_lambda {
|
|||
|
||||
my $body = parser_expr($ts);
|
||||
|
||||
$tok = shift @$ts;
|
||||
die "Expected ) after lambda" unless $tok->{type} == RPAREN;
|
||||
die "Expected ) after lambda" unless $ts->[0]->{type} == RPAREN;
|
||||
|
||||
return sub {
|
||||
my $octx = shift;
|
||||
|
@ -542,9 +544,7 @@ sub macro_if {
|
|||
|
||||
my $fbranch = parser_expr($ts);
|
||||
|
||||
my $tok = shift @$ts;
|
||||
|
||||
die "Expected ) after else expression" unless $tok->{type} == RPAREN;
|
||||
die "Expected ) after else expression" unless $ts->[0]->{type} == RPAREN;
|
||||
|
||||
return sub {
|
||||
my $ctx = shift;
|
||||
|
@ -569,8 +569,6 @@ sub macro_progn {
|
|||
push @steps, parser_expr($ts);
|
||||
}
|
||||
|
||||
shift @$ts; # Remove RPAREN
|
||||
|
||||
return sub {
|
||||
my $ctx = shift;
|
||||
|
||||
|
|
Loading…
Reference in a new issue