bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] inconsistent syntax error with comparison operators


From: david kerns
Subject: Re: [bug-gawk] inconsistent syntax error with comparison operators
Date: Thu, 13 Dec 2018 06:39:37 -0700

On Thu, Dec 13, 2018 at 6:32 AM Stéphane Campinas <
address@hidden> wrote:

> Hi,
>
> I have found some inconsistencies regarding syntax errors for comparison
> operators.
>
> For example, the following script works:
>
>         { print 1 2 == 2 > 3 }
>
> However, replacing '>' with '<' returns an error (with error code 1):
>
>         { print 1 2 == 2 < 3 }
>         gawk: cmd. line:1: { print 1 2 == 2 < 3 }
>         gawk: cmd. line:1:                  ^ syntax error
>
> This happens with the version `GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1,
> GNU MP 6.1.2)`.
>
> The script doesn't mean anything but the goal is to know what input are
> accepted since I'm trying to create a AWK interpreter and found this
> inconsistency while creating the parser.
>
> Cheers,
>
> --
> Stephane Campinas
>


I think you're being "tricked" by operator overload of ">" ...

 { print 1 2 == 2 > 3 }

in the above example ">" is not seen as greater-than but as I/O redirection

but when you replace it with "<", which is not overloaded, you get the
syntax error


reply via email to

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