[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] [1003.1(2008)/Issue 7 0000226]: Questions on awk grammar
From: |
Ranjit Singh |
Subject: |
Re: [bug-gawk] [1003.1(2008)/Issue 7 0000226]: Questions on awk grammar |
Date: |
Fri, 13 Jun 2014 19:59:28 +0100 |
On Thu, Apr 17, 2014 at 03:25:56PM +0000, Austin Group Bug Tracker wrote:
>
> A NOTE has been added to this issue.
> ======================================================================
> http://austingroupbugs.net/view.php?id=226
> ======================================================================
..
> (0002226) nick (manager) - 2014-04-17 15:25
> http://austingroupbugs.net/view.php?id=226#c2226
> ----------------------------------------------------------------------
> > From: Aharon Robbins
> > Subject: Re: [bug-gawk] use of ;; as terminator, request for grammar
> help
> > Date: 17 April 2014 09:45:07 BST
> > X-Diagnostic: Not on the accept list
> >
> >> Date: Thu, 03 Apr 2014 10:18:54 -0600
> >> From: Eric Blake
> >> Subject: [bug-gawk] use of ;; as terminator, request for grammar help
> >>
> >> 2. Based on existing implementations, there is consensus that the POSIX
> >> grammar is overly restrictive, and that we should change it to permit:
> >> awk '{print} {print}'
> >> and:
> >> awk '/foo/; {print}'
> >>
> >> since existing implementations all support it. But to do that, we need
> >> someone with help in writing grammars to propose the changes to the one
> >> appearing on the POSIX page. Any input would be appreciated.
> >
> > I disagree with the first desired change. The ground I'm standing on
> here is
> > firmer. The 1988 awk book disallowed rules without any separators, on
> the
> > grounds that rules and statements within them should be syntactically
> > consistent (a semicolon is required when multiple Xs [rules or statments]
> appear
> > on one line). And the very early released versions of nawk in fact
> enforced
> > this rule. (I remember testing against it.)
> >
> > Later on, after the awk book, Brian changed his awk. If you look at his
> FIXES
> > file, you will see:
> >
> > Nov 27, 1988:
> > With fear and trembling, modified the grammar to permit
> > multiple pattern-action statements on one line without
> > an explicit separator. By definition, this capitulation
> > to the ghost of ancient implementations remains undefined
> > and thus subject to change without notice or apology.
> > DO NOT COUNT ON IT.
> >
> > The sentiment here is quite clear - while it might work, it should
> > not be formalized.
> >
> > The gawk documentation follows this example, documenting clearly that
> > a semicolon is required between multiple rules on one line, and NOT
> > documenting that it can be left off. I do not plan to change this,
> either.
I have to disagree; there is no syntactic ambiguity and it's very
useful in awk one-liners. It's as unambiguous as any other braced
statement in terms of where it ends, so there is no problem in the
parser, and I don't see the utility in forbidding it.
It would be like requiring a semi-colon after: if (cond) { .. };
in C, or at least that's how it feels: puzzling.
Certainly the vast majority of usage I see in #awk when I am in there,
uses the implicit separation of the grammar. And one-liner usage has
always been a strong aspect of awk. It just feels odd for POSIX to
require a terminator, when the reference impl took a different path,
albeit with trepidation.
I'd say it worked out quite well, and as you said gawk allows it
already. In standardisation terms, it seems similar to sed -E, which
was also undocumented, and also supported from the beginning.
It certainly counts as idiomatic usage for one-liners, imo.
Thanks for your work,
Regards,
Ranjit.
--
"One can be a gentleman, without being a push-over."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [bug-gawk] [1003.1(2008)/Issue 7 0000226]: Questions on awk grammar,
Ranjit Singh <=