zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: parsing empty alternatives: case foo|) :;;
Date: Mon, 7 Aug 2017 07:44:58 -0700	[thread overview]
Message-ID: <CAH+w=7ZhywOm=W-jZqtGaA=fkHjsoOaBonhBrnEyyEYHzkaR3A@mail.gmail.com> (raw)
In-Reply-To: <20170807152649.6a5e7d70@pwslap01u.europe.root.pri>

On Mon, Aug 7, 2017 at 7:26 AM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Mon, 7 Aug 2017 13:55:59 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>> % case '' in (foo|) echo yes;; esac
>> yes
>> % case '' in foo|) echo yes;; esac
>> zsh: parse error near `)'
>>
>> Why does the second case fail to parse?  We (IRC) don't see any ambiguity
>> in it.
>
> I haven't checked, but I think it looks like a pipe --- at that point we
> haven't gone further down the case-specific code so that it parses the
> line specially.

Several things are going on here.
(1) The "case" syntax with no open paren and only a close paren is
from older Bourne shell
(2) The use of "|" to separate alternatives in a pattern is
zsh-specific globbing syntax, which is only active when parsing
patterns that contain a parenthesized grouping
(3) Because of both of the foregoing, when parsing the pattern in the
older syntax, recognition of "|' as a separator is not enabled -- it's
read as a simple pattern with no grouping
(4) When the newer "case" syntax with a fully parenthesized pattern
was added, the presence of the open paren gave us the parsing hook
needed to activate the grouping syntax

To put it another way, "in foo|)" is rejected for the same reason that
"in |foo)" is.


  reply	other threads:[~2017-08-07 14:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170807135641epcas3p4bc0a64f832ae7fcd76051ac198722045@epcas3p4.samsung.com>
2017-08-07 13:55 ` Daniel Shahaf
2017-08-07 14:26   ` Peter Stephenson
2017-08-07 14:44     ` Bart Schaefer [this message]
2017-08-07 14:58       ` Peter Stephenson
2017-08-07 18:03         ` 5.4 almost released Peter Stephenson
2017-08-07 18:25           ` Eric Cook
2017-08-07 18:34             ` Peter Stephenson
2017-08-08 10:26               ` Martijn Dekker
2017-08-08 11:00                 ` Peter Stephenson
2017-08-07 18:21         ` parsing empty alternatives: case foo|) :;; Peter Stephenson
2017-08-07 18:56           ` 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=7ZhywOm=W-jZqtGaA=fkHjsoOaBonhBrnEyyEYHzkaR3A@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=p.stephenson@samsung.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).