Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Debug is human, de-fix divine.


devel / comp.lang.awk / A niggling bug in the GAWK parser

SubjectAuthor
* A niggling bug in the GAWK parserKenny McCormack
+* Re: A niggling bug in the GAWK parserMack The Knife
|`- Re: A niggling bug in the GAWK parserEd Morton
`* Re: A niggling bug in the GAWK parserKaz Kylheku
 `- Re: A niggling bug in the GAWK parserKenny McCormack

1
A niggling bug in the GAWK parser

<sjhuea$2v60b$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=933&group=comp.lang.awk#933

  copy link   Newsgroups: comp.lang.awk
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: A niggling bug in the GAWK parser
Date: Tue, 5 Oct 2021 16:27:54 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sjhuea$2v60b$1@news.xmission.com>
Injection-Date: Tue, 5 Oct 2021 16:27:54 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3119115"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 5 Oct 2021 16:27 UTC

I got bit by this today:

print SomeVar > stime ? "Error!" : "OK"

Perfectly reasonable, right? But GAWK flags this as a syntax error.
(Literally, as "syntax error - and see below)

And I know why. I also know the fix (which is to parenthesize the
conditional expression). So, I don't need anyone writing in to tell me why
it happens or what the fix is.

The point is, it just seems to me that the error message ought to be
clearer. I mean, this one has been around a long time, and it seems like
it could be caught better. In fact, it took me more than a few moments to
figure out that it wasn't a syntax error (in the conventional sense).
I.e., there wasn't really anything wrong with my code - I hadn't misspelled
anything or anything like that. Rather, it is just a (well-known) bugaboo.

Note: Tested with GAWK 5.0.1 - it is still there and still flagged as
"syntax error".

Anyway, just something to consider. Note that C compilers these days are
getting really explicit about telling you exactly what they think is wrong
with your code - and how to fix it. It seems GAWK might take a cue from
that...

--
To be evangelical is to spend every waking moment hovering around
two emotional states: fear and rage. Evangelicals are seriously the
angriest and most vicious bunch of self-pitying, constantly-moaning
whinybutts I've ever encountered.

Re: A niggling bug in the GAWK parser

<sjk3dl$7f6$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=934&group=comp.lang.awk#934

  copy link   Newsgroups: comp.lang.awk
Path: rocksolid2!i2pn.org!aioe.org!eXsOhAt/ESFYEBbn44DnpA.user.46.165.242.75.POSTED!not-for-mail
From: mack@the-knife.org (Mack The Knife)
Newsgroups: comp.lang.awk
Subject: Re: A niggling bug in the GAWK parser
Date: Wed, 6 Oct 2021 12:05:09 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sjk3dl$7f6$1@gioia.aioe.org>
References: <sjhuea$2v60b$1@news.xmission.com>
Injection-Info: gioia.aioe.org; logging-data="7654"; posting-host="eXsOhAt/ESFYEBbn44DnpA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Originator: aharon@aharon-ThinkPad-E580.(none) (Aharon Robbins)
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mack The Knife - Wed, 6 Oct 2021 12:05 UTC

From https://www.gnu.org/software/gawk/manual/html_node/Usenet.html:

| Please do not try to report bugs in gawk by posting to the Usenet/Internet
| newsgroup comp.lang.awk. Although some of the gawk developers occasionally
| read this news group, the primary gawk maintainer no longer does. Thus
| it’s virtually guaranteed that he will not see your posting.

Also, you might think about the kind of work involved in such changes
to the parser, and in particular about the size and nature (paid)
of the teams doing GCC development vs. the size and nature (volunteer)
of the team doing gawk development.

'nuff said.

In article <sjhuea$2v60b$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
>I got bit by this today:
>
> print SomeVar > stime ? "Error!" : "OK"
>
>Perfectly reasonable, right? But GAWK flags this as a syntax error.
>(Literally, as "syntax error - and see below)
>
>And I know why. I also know the fix (which is to parenthesize the
>conditional expression). So, I don't need anyone writing in to tell me why
>it happens or what the fix is.
>
>The point is, it just seems to me that the error message ought to be
>clearer. I mean, this one has been around a long time, and it seems like
>it could be caught better. In fact, it took me more than a few moments to
>figure out that it wasn't a syntax error (in the conventional sense).
>I.e., there wasn't really anything wrong with my code - I hadn't misspelled
>anything or anything like that. Rather, it is just a (well-known) bugaboo.
>
>Note: Tested with GAWK 5.0.1 - it is still there and still flagged as
>"syntax error".
>
>Anyway, just something to consider. Note that C compilers these days are
>getting really explicit about telling you exactly what they think is wrong
>with your code - and how to fix it. It seems GAWK might take a cue from
>that...

Re: A niggling bug in the GAWK parser

<20211006081936.667@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=936&group=comp.lang.awk#936

  copy link   Newsgroups: comp.lang.awk
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.awk
Subject: Re: A niggling bug in the GAWK parser
Date: Wed, 6 Oct 2021 15:21:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20211006081936.667@kylheku.com>
References: <sjhuea$2v60b$1@news.xmission.com>
Injection-Date: Wed, 6 Oct 2021 15:21:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a7ca56f9cfeb71e00362b787c9ec46d2";
logging-data="12851"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WlSgnHSs6fxWmT1goIHe9TbVPru5me+g="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Pvp6bwGaJ5oMFtJbPTpyhd2T9aI=
 by: Kaz Kylheku - Wed, 6 Oct 2021 15:21 UTC

On 2021-10-05, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> I got bit by this today:
>
> print SomeVar > stime ? "Error!" : "OK"
>
> Perfectly reasonable, right? But GAWK flags this as a syntax error.
> (Literally, as "syntax error - and see below)
>
> And I know why. I also know the fix (which is to parenthesize the
> conditional expression). So, I don't need anyone writing in to tell me why
> it happens or what the fix is.
>
> The point is, it just seems to me that the error message ought to be
> clearer. I mean, this one has been around a long time, and it seems like

I happen have a git directory with gawk 4.x sources from way back when,
all set up to build.

I tried a tiny patch, just for discussion:

$ ./gawk 'BEGIN { print SomeVar > stime ? "Error!" : "OK" }'
gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
gawk: cmd. line:1: ^ syntax error
gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
gawk: cmd. line:1: ^ I/O redirection possibly confused with relational operator
gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
gawk: cmd. line:1: ^ syntax error

It is:

$ git diff awkgram.y
diff --git a/awkgram.y b/awkgram.y
index 0b7e29f3..41952248 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -1312,6 +1312,12 @@ output_redir
yyerror(_("multistage two-way pipelines don't work"));
$$ = list_prepend($3, $1);
}
+ | IO_OUT common_exp error
+ {
+ yyerror(_("I/O redirection possibly confused with relational operator"));
+ yyerrok;
+ $$ = NULL;
+ }
;

if_statement

See what you make of it.

Re: A niggling bug in the GAWK parser

<sjki0s$30dbu$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=937&group=comp.lang.awk#937

  copy link   Newsgroups: comp.lang.awk
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: A niggling bug in the GAWK parser
Date: Wed, 6 Oct 2021 16:14:20 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sjki0s$30dbu$1@news.xmission.com>
References: <sjhuea$2v60b$1@news.xmission.com> <20211006081936.667@kylheku.com>
Injection-Date: Wed, 6 Oct 2021 16:14:20 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3159422"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 6 Oct 2021 16:14 UTC

In article <20211006081936.667@kylheku.com>,
Kaz Kylheku <480-992-1380@kylheku.com> wrote:
....
>I happen have a git directory with gawk 4.x sources from way back when,
>all set up to build.
>
>I tried a tiny patch, just for discussion:
>
>$ ./gawk 'BEGIN { print SomeVar > stime ? "Error!" : "OK" }'
>gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
>gawk: cmd. line:1: ^ syntax error
>gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
>gawk: cmd. line:1: ^ I/O redirection possibly
>confused with relational operator
>gawk: cmd. line:1: BEGIN { print SomeVar > stime ? "Error!" : "OK" }
>gawk: cmd. line:1: ^ syntax error
>
>
>It is:
>
>$ git diff awkgram.y
>diff --git a/awkgram.y b/awkgram.y
>index 0b7e29f3..41952248 100644
>--- a/awkgram.y
>+++ b/awkgram.y
>@@ -1312,6 +1312,12 @@ output_redir
> yyerror(_("multistage two-way pipelines don't work"));
> $$ = list_prepend($3, $1);
> }
>+ | IO_OUT common_exp error
>+ {
>+ yyerror(_("I/O redirection possibly confused with relational
>operator"));
>+ yyerrok;
>+ $$ = NULL;
>+ }
> ;
>
> if_statement
>
>See what you make of it.

Very interesting. Thanks.

--
No puppet.
No puppet.
You're a puppet.

Re: A niggling bug in the GAWK parser

<sjkk9b$l75$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=938&group=comp.lang.awk#938

  copy link   Newsgroups: comp.lang.awk
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortonspam@gmail.com (Ed Morton)
Newsgroups: comp.lang.awk
Subject: Re: A niggling bug in the GAWK parser
Date: Wed, 6 Oct 2021 11:52:59 -0500
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <sjkk9b$l75$1@dont-email.me>
References: <sjhuea$2v60b$1@news.xmission.com> <sjk3dl$7f6$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 6 Oct 2021 16:52:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="57c070c94731bfd9cc5220e77794faa6";
logging-data="21733"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+u43bKPVOoR7HhQQVdT0YV"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:VcZikbvrs2wQTC+nwwdkGYaAPWY=
In-Reply-To: <sjk3dl$7f6$1@gioia.aioe.org>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 211006-2, 10/6/2021), Outbound message
 by: Ed Morton - Wed, 6 Oct 2021 16:52 UTC

On 10/6/2021 7:05 AM, Mack The Knife wrote:
<snip>
> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> I got bit by this today:
>>
>> print SomeVar > stime ? "Error!" : "OK"
>>
>> Perfectly reasonable, right?

Wrong

> But GAWK flags this as a syntax error.

Good. Any unparenthesized expression on the right side of input or
output redirection is undefined behavior per POSIX and a syntax error is
a good response to that code.

Ed.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor