zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: Parse error (lack thereof) on incomplete loops
Date: Fri, 05 Oct 2018 17:04:39 +0000	[thread overview]
Message-ID: <1538759079.2901416.1532150520.23638520@webmail.messagingengine.com> (raw)
In-Reply-To: <20181005134800eucas1p22010dd23c9b937d3435e1b757c48f43d~aun_y-rQy2277122771eucas1p2E@eucas1p2.samsung.com>

Peter Stephenson wrote on Fri, 05 Oct 2018 13:47 +0000:
> On Fri, 2018-10-05 at 13:26 +0000, Daniel Shahaf wrote:
> > Can we come up with a one-sided parsing rule for syntactically valid cases?
> > That is, a rule that says guarantees that some constructs are syntactically
> > valid, but doesn't necessarily say anything about other constructs.
> 
> That's pretty much what the the parser in practice does.  If you look at
> the code, it's got tests that read...
> 
> - If SHORTLOOPS isn't set panic at this point.
> 
> - Otherwise go on and see if we can get anything sensible out of what
> we did find.
> 
> So for example the while loop code has...
> 
>     } else if (unset(SHORTLOOPS)) {
> 	YYERRORV(oecused);
>     } else
> 	par_save_list1(cmplx);
> 
> The case that brought this up is that we don't check the return value
> from par_save_list1() (actually a macro at the moment).
> 
> For more explicit rules it's a question of decoding the tests above (if
> we got a "do" then blah, else if we got a "{" then etc. etc.).

Thanks, but that's not quite what I meant.

I meant, we should have a documented rule for which constructs are
syntactically valid when SHORT_LOOPS is set.  Then whenever a question
such as "should <this case> raise a parse error?" comes up, we'd answer
that according to the rule we'd decided upon in advance.  This way the
syntax will be predictable.

The rule should not be defined in terms of the implementation, since it needs
to be able to be used to decide whether the change from 5.5 to 5.6 was a bugfix
or a regression.

Cheers,

Daniel

  reply	other threads:[~2018-10-05 17:17 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 [this message]
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
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=1538759079.2901416.1532150520.23638520@webmail.messagingengine.com \
    --to=d.s@daniel.shahaf.name \
    --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).