bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] bench: pacify script (invalid uses of undefined variable


From: Akim Demaille
Subject: Re: [PATCH 1/4] bench: pacify script (invalid uses of undefined variables)
Date: Mon, 21 Jan 2013 12:04:39 +0100

Le 21 janv. 2013 à 12:46, Theophile Ranquet <address@hidden> a écrit :

> * etc/bench.pl: Here.

I would like to have a more detailed commit message, please.
I don't understand why we sometimes have undefined variables,
it seems fishy.

> ---
> etc/bench.pl.in | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/etc/bench.pl.in b/etc/bench.pl.in
> index 83176d5..eb82691 100755
> --- a/etc/bench.pl.in
> +++ b/etc/bench.pl.in
> @@ -948,8 +948,11 @@ my @token;
> sub eat ($)
> {
>   my ($expected) = @_;
> -  die "expected $expected, unexpected: $token[0] (@token)\n"
> -    unless $token[0] eq $expected;
> +    if (defined $expected && defined $token[0])
> +    {
> +      die "expected $expected, unexpected: $token[0] (@token)\n"
> +      unless $token[0] eq $expected;
> +    }

I don't see how "undefined" is less a problem that "not what
we expected".

>   shift @token;
> }
> 
> @@ -970,7 +973,7 @@ sub parse (@)
> sub parse_expr ()
> {
>   my @res = parse_term ();
> -  while ($token[0] eq '|')
> +  while (defined $token[0] && $token[0] eq '|')
>     {
>       eat ('|');
>       # Alternation.
> @@ -982,7 +985,7 @@ sub parse_expr ()
> sub parse_term ()
> {
>   my @res = parse_fact ();
> -  while ($token[0] eq '&')
> +  while (defined $token[0] && $token[0] eq '&')
>     {
>       eat ('&');
>       # Cartesian product.
> @@ -1127,7 +1130,7 @@ if (defined $bench)
> else
> {
>   # Launch the bench marking.
> -  bench ($grammar, @ARGV);
> +  bench ($grammar, split (/ /, $ARGV[0]));

Err???  Details, please.

> }
> 
> ### Setup "GNU" style for perl-mode and cperl-mode.
> -- 
> 1.8.1.1
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]