From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>,
"zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: grammar triviality with '&&'
Date: Sun, 01 Mar 2015 23:48:14 +0300 [thread overview]
Message-ID: <440741425242894@web21h.yandex.ru> (raw)
In-Reply-To: <54F365AB.4070802@eastlink.ca>
01.03.2015, 22:48, "Ray Andrews" <rayandrews@eastlink.ca>:
> On 03/01/2015 10:48 AM, Bart Schaefer wrote:
>> On Mar 1, 9:01am, Ray Andrews wrote:
>> }
>> } I see, so it's not a 'hard' syntactic issue
>>
>> Actually it IS a "hard" syntactic issue, in the sense that the grammar
>> for all *nix shells [1] both immemorial and standard, formally defines
>> newline as equivalent to semicolon.
>
> I see. If newline == semicolon, then the acceptable variations in line
> wrap that I've
> noticed have simply been within that rule and there is no look ahead as
> I presumed.
> This is a good thing to know. As usual I refer in my head back to C
> where line wrap
> issues virtually never exist, but that's obviously far more complicated
> to parse.
C is far easier to parse. Two main complications are preprocessor and state: you cannot parse some constructs without knowing about typedefs and you can parse nothing without #defines. But C grammar is not as complicated as zsh one.
Handling newlines here is not a complication, not a tiny bit of this: after preprocessor you can simply translate newline to space (except when inside quotes). For preprocessor newline without `\` always ends the statement, `\\\n` is ignored.
Though it would not be so easy if you wanted to make C interpreted. Dunno how existing C interpreters handle this: never tried them, but it would be logical to run something when interpreter received newline and has a complete top-level statement.
> What that rule looses in formatting flexibility it gains in brevity and
> easier parsing
> so it becomes clear why an interpreted language makes that choice.
next prev parent reply other threads:[~2015-03-01 20:54 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 16:07 Ray Andrews
2015-03-01 16:43 ` ZyX
2015-03-01 17:01 ` Ray Andrews
2015-03-01 18:48 ` Bart Schaefer
2015-03-01 19:00 ` ZyX
2015-03-01 19:16 ` Ray Andrews
2015-03-01 20:48 ` ZyX [this message]
2015-03-01 18:49 ` Lawrence Velázquez
2015-03-02 2:27 ` Vincent Lefevre
2015-03-02 3:12 ` Ray Andrews
2015-03-02 5:22 ` Lawrence Velázquez
2015-03-02 3:53 ` Kurtis Rader
2015-03-02 4:18 ` Ray Andrews
2015-03-02 5:22 ` Kurtis Rader
2015-03-02 16:17 ` Ray Andrews
2015-03-02 18:52 ` Kurtis Rader
2015-03-02 19:03 ` ZyX
2015-03-02 20:16 ` Kurtis Rader
2015-03-03 4:15 ` ZyX
2015-03-03 4:43 ` Kurtis Rader
2015-03-04 15:03 ` Vincent Lefevre
2015-03-04 19:07 ` ZyX
2015-03-02 19:25 ` Ray Andrews
2015-03-02 10:46 ` Vincent Lefevre
2015-03-02 11:06 ` Peter Stephenson
2015-03-02 19:19 ` Bart Schaefer
2015-03-04 14:47 ` Vincent Lefevre
2015-03-05 1:51 ` Bart Schaefer
2015-03-05 10:06 ` Peter Stephenson
2015-03-02 8:54 ` Bart Schaefer
2015-03-02 10:31 ` Vincent Lefevre
2015-03-02 16:31 ` Ray Andrews
2015-03-02 16:49 ` Bart Schaefer
2015-03-02 17:38 ` Ray Andrews
2015-03-02 18:51 ` Bart Schaefer
2015-03-04 8:55 ` Vincent Lefevre
2015-03-04 17:12 ` Ray Andrews
2015-03-06 4:59 ` Bart Schaefer
2015-03-06 16:10 ` Ray Andrews
2015-03-06 20:23 ` Lawrence Velázquez
2015-03-06 21:25 ` Ray Andrews
2015-03-06 16:32 ` Vincent Lefevre
2015-03-06 17:43 ` Bart Schaefer
2015-03-06 21:01 ` Ray Andrews
2015-03-09 11:26 ` Vincent Lefevre
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=440741425242894@web21h.yandex.ru \
--to=kp-pav@yandex.ru \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@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).