From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4869 invoked by alias); 7 Aug 2017 14:45:05 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41503 Received: (qmail 12095 invoked by uid 1010); 7 Aug 2017 14:45:05 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f175.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.216.175):SA:0(0.5/5.0):. Processed in 1.876059 secs); 07 Aug 2017 14:45:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FDEZPArK2rLuNsBM7oEBVWfBnaIgsVbJxfEg9kVVb1U=; b=mAxXoKRcVJpEk/MfwB/HC8dg4ooZMk0AxL+WXS+GkM1lRFG/Mk9qxGLgubPYZE8IWc oejTvUDGoqMcWz2VbHjWNrn47g0/WiYmR1+L6WafLwE72nalNCE0JDpdDuiho+oot8nD zRUbl/FJaiDPzQS6cqEThKa4wWdaP2RMr18RfX2O0r05O2wM+IPGJWMjdMoluSnlzr3b O61Cz+XYn4MllSAAHpok5Dn6aWQLnQ40MUWxyioXCrygvnKE31GfslZo2ixFD+UtP+b9 yviLFevdF8tYcl8AW+qxCvoBN89MCfNj3b4kcK5z/a6iOe5iM0thmOKnorg8PrXTfxA6 1L7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FDEZPArK2rLuNsBM7oEBVWfBnaIgsVbJxfEg9kVVb1U=; b=dGYzWPZ01Melkm2tmi8bMfLU3GnDF6/uxuSqIUyhlg+iGHSEA5roi5SPHbToIKW2rB F5r6FHiQaoLmVPsfk6Qd4uiwh0MYOGmgo7sKxcma/rRmzQFG8YLPYHUETpOQIM3tNc9X 3qaK4HFfOCbLhWSa0APY7BOaXygCowlf1axuF7llT6nuS54eXkctR42QcvfPPgQG6M/J 11ZQ4BD4uIdhiqsF5zX7uDuAkEG7mhT2q9iHTH0uIMn6UHXWeTtLaNd88FgKCKul9BnU Lmz/GhhO/NsGy0WrrQsyW94JMfBmt16twOAxCLYmshLZGe5O7bszYucQz52j45R1REft OvVQ== X-Gm-Message-State: AHYfb5i5cD2zcL9jNtkOaaf48cu0ltMgm6OlrrCMndkZcrddM2zG44/G h/qlvEYpu0JNYfQM4OXEUWTBXec3nFjK X-Received: by 10.200.51.129 with SMTP id c1mr1142763qtb.71.1502117098764; Mon, 07 Aug 2017 07:44:58 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20170807152649.6a5e7d70@pwslap01u.europe.root.pri> References: <20170807135559.odtceysgqn5qeqql@tarpaulin.shahaf.local2> <20170807152649.6a5e7d70@pwslap01u.europe.root.pri> From: Bart Schaefer Date: Mon, 7 Aug 2017 07:44:58 -0700 Message-ID: Subject: Re: parsing empty alternatives: case foo|) :;; To: Peter Stephenson Cc: Daniel Shahaf , "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" On Mon, Aug 7, 2017 at 7:26 AM, Peter Stephenson wrote: > On Mon, 7 Aug 2017 13:55:59 +0000 > Daniel Shahaf 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.