zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>, Zsh Users <zsh-users@zsh.org>
Subject: Re: lexing
Date: Sun, 29 Nov 2015 20:13:17 +0300	[thread overview]
Message-ID: <970401448817197@web3h.yandex.ru> (raw)
In-Reply-To: <565B18C6.6090707@eastlink.ca>

29.11.2015, 18:26, "Ray Andrews" <rayandrews@eastlink.ca>:
> Gentlemen:
>
> The syntax highlighting in my editors makes the predictable mistake when
> it bumps into these:
>
> (#b)
> (#c1,2)
> (#a3)
>
> because the lexing mostly follows bash rules. The people who write the
> highlighter are interested in fixing that for zsh, but they want a
> rigorous description of the rule. As far as I know the only rule there
> is that if the hash is preceded by an open parenthesis then it is not a
> comment. Is that sufficient or are there further subtleties?

With `setopt extendedglob` `echo ech#test` errors with `zsh: no match`: AFAIR this is something like `*` in PCRE (and `##` is `+` in PCRE). With `unsetopt extendedglob` `echo ech#test` echoes `ech#test`, `interactivecomments` option is set in both cases. So the rule I think would be that `#` starts a comment if it is preceded by a whitespace.

Also:

1. ${(kv#)var}
2. ${#var}: usual thing, also in POSIX shells
3. $#var
4. ${(s. # .)var}
5. $(( #var )) (usually causes Vim highlighting to fail) (also $[ #var ])
6. ${var// # /test}
7. ${var//# /test} (hash means different thing here)
8. ${var%#}, ${var:-#}, etc (POSIX)
9. '#', "#", \# (POSIX, ways of escaping hash)


Note that `posh -c 'echo foo#bar'` (also bash, dash, busybox and ksh) echoes `foo#bar`. So without `setopt extendedglob` this is not zsh-specific. So if they show a “predictable mistake” in this case as well then they are false regardless of the shell they write highlighting for.


  reply	other threads:[~2015-11-29 17:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-29 15:24 lexing Ray Andrews
2015-11-29 17:13 ` ZyX [this message]
2015-11-29 18:07 ` lexing Bart Schaefer
2015-11-30  2:10   ` lexing Ray Andrews
2015-11-30  3:33     ` lexing Daniel Shahaf
2015-11-30  4:20       ` lexing Ray Andrews
2015-11-30  4:47         ` lexing Ray Andrews
2015-11-30 16:23           ` lexing Bart Schaefer
2015-11-30 16:50             ` lexing Ray Andrews
2015-12-04 19:15             ` master class Ray Andrews

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=970401448817197@web3h.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).