Utilize peek_token where possible
This commit is contained in:
parent
f86caf6b5f
commit
42b5567c29
1 changed files with 10 additions and 10 deletions
|
@ -481,7 +481,7 @@ sub parser_list {
|
||||||
slurp_token($ts, LPAREN, "Expected ( after ' for list");
|
slurp_token($ts, LPAREN, "Expected ( after ' for list");
|
||||||
|
|
||||||
my @elements;
|
my @elements;
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
push @elements, parser_expr($ts);
|
push @elements, parser_expr($ts);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ my %macros;
|
||||||
sub parser_call {
|
sub parser_call {
|
||||||
my $ts = shift;
|
my $ts = shift;
|
||||||
|
|
||||||
if ($ts->[0]->{type} == IDENT)
|
if (peek_token($ts,IDENT))
|
||||||
{
|
{
|
||||||
my $name = $ts->[0]->{value};
|
my $name = $ts->[0]->{value};
|
||||||
if (defined $macros{$name})
|
if (defined $macros{$name})
|
||||||
|
@ -516,7 +516,7 @@ sub parser_call {
|
||||||
|
|
||||||
my @params;
|
my @params;
|
||||||
|
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
push @params, parser_expr($ts);
|
push @params, parser_expr($ts);
|
||||||
}
|
}
|
||||||
|
@ -539,14 +539,14 @@ sub gen_macro_let {
|
||||||
|
|
||||||
my @assignments;
|
my @assignments;
|
||||||
|
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
slurp_token($ts, LPAREN, "Expected ( before assignment in let");
|
slurp_token($ts, LPAREN, "Expected ( before assignment in let");
|
||||||
|
|
||||||
my $ident = slurp_token($ts, IDENT)->{value};
|
my $ident = slurp_token($ts, IDENT)->{value};
|
||||||
|
|
||||||
my $expr;
|
my $expr;
|
||||||
if ($ts->[0]->{type} == RPAREN)
|
if (peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
$expr = sub { return undef };
|
$expr = sub { return undef };
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,7 @@ sub macro_lambda {
|
||||||
slurp_token($ts, LPAREN, "Expected ( after lambda keyword");
|
slurp_token($ts, LPAREN, "Expected ( after lambda keyword");
|
||||||
|
|
||||||
my @param_list;
|
my @param_list;
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
my $ident = slurp_token($ts, IDENT)->{value};
|
my $ident = slurp_token($ts, IDENT)->{value};
|
||||||
push @param_list, $ident;
|
push @param_list, $ident;
|
||||||
|
@ -645,7 +645,7 @@ sub macro_progn {
|
||||||
|
|
||||||
my @steps;
|
my @steps;
|
||||||
|
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
push @steps, parser_expr($ts);
|
push @steps, parser_expr($ts);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ sub macro_cond {
|
||||||
my $ts = shift;
|
my $ts = shift;
|
||||||
|
|
||||||
my @cases;
|
my @cases;
|
||||||
while ($ts->[0]->{type} != RPAREN)
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
die "Expected ( before case in cond"
|
die "Expected ( before case in cond"
|
||||||
unless (shift @$ts)->{type} == LPAREN;
|
unless (shift @$ts)->{type} == LPAREN;
|
||||||
|
@ -783,7 +783,7 @@ sub macro_and {
|
||||||
my $ts = shift;
|
my $ts = shift;
|
||||||
|
|
||||||
my @operands_parsed;
|
my @operands_parsed;
|
||||||
while ( $ts->[0]->{type} != RPAREN )
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
push @operands_parsed, parser_expr($ts);
|
push @operands_parsed, parser_expr($ts);
|
||||||
}
|
}
|
||||||
|
@ -807,7 +807,7 @@ sub macro_or {
|
||||||
my $ts = shift;
|
my $ts = shift;
|
||||||
|
|
||||||
my @operands_parsed;
|
my @operands_parsed;
|
||||||
while ( $ts->[0]->{type} != RPAREN )
|
while (!peek_token($ts,RPAREN))
|
||||||
{
|
{
|
||||||
push @operands_parsed, parser_expr($ts);
|
push @operands_parsed, parser_expr($ts);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue