From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
Date: Thu, 2 Aug 2018 09:32:08 +0200 [thread overview]
Message-ID: <CAKc7PVCHo5t8vsQr_YGVm-RZiZ6_Nv=mqCyDi1eGLo7BKpyFdw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bP_5ahuJZgswkmeyiF1Ozua0uznvZq0anzAVpA5c1kbw@mail.gmail.com>
On 1 August 2018 at 20:18, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Mon, Jul 30, 2018 at 12:09 AM, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
>>
>> not only (z) can handle quoting, turns out regular pattern with while
>> loop can do it too:
>
> Yes, this is actually quite commonly done when writing ad-hoc parsers
> in perl via variations on
>
> while (s/^(the-leading-part)//g) {
> do something with $1;
> }
I think my code is different. It matches distinct chars (not sure if
words are possible, sometimes I think yes, sometimes it seems a no
go, I would have to write it) that we are interested in at the same
time handling backslash, " and '. So user can query for set of chars,
with their positions in buffer, without bothering with "are
backslashes even or odd" and other such problems. It turns out this
comes down to handling backslash, because of obvious "\\\A" problems
(parity of the slash), but also \" – it is also backslash that
controls whether double-quoting ends or begins. This is the [\\](*)
part of the pattern and restarting with ${match[3]}.
I realized that \', i.e. backslash and single quote, aren't special
within single quote. So the code needs update. But it is totally
possible, in the ${match[3]} block (the first one) one has to check if
state==in-single-quote, and decide to skip next char accordingly.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
prev parent reply other threads:[~2018-08-02 7:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 7:09 Sebastian Gniazdowski
2018-07-31 4:16 ` Sebastian Gniazdowski
2018-07-31 5:13 ` Sebastian Gniazdowski
2018-08-01 18:18 ` Bart Schaefer
2018-08-02 7:32 ` Sebastian Gniazdowski [this message]
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='CAKc7PVCHo5t8vsQr_YGVm-RZiZ6_Nv=mqCyDi1eGLo7BKpyFdw@mail.gmail.com' \
--to=sgniazdowski@gmail.com \
--cc=schaefer@brasslantern.com \
--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).