zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Parse error (lack thereof) on incomplete loops
Date: Sat, 6 Oct 2018 20:51:45 -0700	[thread overview]
Message-ID: <CAH+w=7b_fi822eQvXe1cQbw4DYXPR=ZPbjWK_S6sZjFQLY8KpQ@mail.gmail.com> (raw)
In-Reply-To: <20181006192104.4a66da1a@pws-HP.localdomain>

So ... I've been looking through the git history of Doc/Zsh/grammar.yo ...

On Sat, Oct 6, 2018 at 11:21 AM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> On Fri, 5 Oct 2018 18:47:01 -0700
> Bart Schaefer <schaefer@brasslantern.com> wrote:
> >   For the if, while and until commands, in both these cases the test part
> >   of the loop must also be suitably delimited, such as by `[[ ... ]]' or
> >   `(( ... )), else the end of the test will not be recognized.
>
> Looked at this a bit more and I have fairly major doubts about the
> documentation (although I don't mean about the intention suggested by
> Bart which does seem reaonsble).

   2001-07-05  Peter Stephenson  <pws@csr.com>

  +       * 15264: Doc/Zsh/grammar.yo: improve description of use of
  +       variant complex command forms to avoid confusing the present
  +       writer.
  +

So apparently you've had doubts about this for a long time.

>   The short versions below only work if var(sublist) is of the form `tt({)
>   var(list) tt(})' or if the tt(SHORT_LOOPS) option is set.

This appears to be a reference to
  item(tt(if) var(list) var(sublist))
and similar doc of "for", "repeat", and "select".

These also have the "{ list }" forms documented separately so I don't
know why the "sublist" form of while and until was never made explicit
(see guess at it below).

> so maybe that "{ list }" should really be "sublist"?

Or the form should just be added for congruence with the doc of the
other complex commands.  If they'd all been there separately in the
first place, the sentence about "var(sublist) is of the form ..."
might never have been needed.  It's also quite likely (I haven't dug
into this in the Src commits) that "while" and "until" originally did
NOT work with only a sublist and that they do is another accidental
feature from some even earlier parser change.

> It's also not clearly (or at all?  I can't see it) documented that you
> only get the SHORT_LOOPS effect if there's no delimiter --- if you stick
> one in it looks like a normal command list which it'll just go on parsing.

True that this is not called out, but implicitly from the grammar:
var(list) var(sep) var(sublist) matches a production yielding
var(list), so if there is a var(sep) then the var(list) isn't done
yet.  You have to have a grammatically concluded var(list) as the
conditional before you can tack on a var(sublist) as the body.

> Perhapse someone who may have to be Bart (I can't say I consider myself
> an expert in this having only just found out what's going on and I can't
> say anyone else is likely to, either) should suggest some words of
> wisdom to document SHORT_LOOPS as separate text rather than as part of
> the variant syntax section?  I don't mind writing this up.

I may have time to take a stab at this tomorrow, can't promise.  Maybe
the above is a start.  I also don't presently have a computer with
"yum" installed/working.

  reply	other threads:[~2018-10-07  3:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181004154947epcas4p2441e109a2c4e060bf39f0f6925e98241@epcas4p2.samsung.com>
2018-10-04 15:49 ` Bart Schaefer
2018-10-04 16:31   ` Peter Stephenson
2018-10-04 20:04     ` Marc Chantreux
2018-10-04 20:37       ` Bart Schaefer
2018-10-05  6:04         ` Marc Chantreux
2018-10-04 20:34     ` Bart Schaefer
2018-10-05  9:14       ` Peter Stephenson
2018-10-05 13:26         ` Daniel Shahaf
2018-10-05 13:47           ` Peter Stephenson
2018-10-05 17:04             ` Daniel Shahaf
2018-10-06  1:47         ` Bart Schaefer
2018-10-06 11:15           ` Peter Stephenson
2018-10-06 11:55             ` Peter Stephenson
2018-10-06 18:21           ` Peter Stephenson
2018-10-07  3:51             ` Bart Schaefer [this message]
2018-10-07 18:16               ` Bart Schaefer
2018-10-08 10:07               ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7b_fi822eQvXe1cQbw4DYXPR=ZPbjWK_S6sZjFQLY8KpQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).