Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: lexing
- X-seq: zsh-users 21008
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: lexing
- Date: Sun, 29 Nov 2015 20:13:17 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1448817198; bh=fhvCg2HlGAT2cGv4r56Mij5jLUK7KhW1LlucbtGcI2g=; h=From:To:In-Reply-To:References:Subject:Date; b=OBxdVV+kTT0mGaXQ13VMI/Gi7hX7nHbHTDIL57dp59m71Ty3xpAzjHo6n8Zn5+YDt Wvlzbj+iS5zFLQ1F8hBaSRup2D7YPqPGUTb6cFs5ccYC8KfVL7TJ99/14eJUBxdqKA g/t3A++t5yzRlVdyXY+LqUpfeYXr49xEK7gel4j8=
- In-reply-to: <565B18C6.6090707@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <565B18C6.6090707@eastlink.ca>
29.11.2015, 18:26, "Ray Andrews" <rayandrews@xxxxxxxxxxx>:
> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author