Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
- X-seq: zsh-users 23552
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
- Date: Thu, 2 Aug 2018 09:32:08 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=XjhmXY3sEBWezXa6XC/oIOOMIRYh9TBmtFLASZNJ/aY=; b=D9ndrpF+FCiq7xn55U6SkVndJS+10xJCaaSDQFN05qBU51PQG2Qa0TmFQn5hbQfdnc PmqfxH4BP5CtY+pTf8JzpbTsw/LZCrjX3WoEG1764A3nwNuCIxgQ3Uzs6blfLdr1Pfvc WRm11cQCP8V695gl076X1VhextQ2DX6WsmcyxnMEDOOn/wqxiEdHSHRi2lgPi0HXitVy 8KgaAlyXIK745L0iXyuV0P4Lx8ZzVudhjy1EZCh7sDnwrxim67nhErBenb1UGkowIg3w G8lZRE7pKu1dhXGbkZbenJKSDwM3S44xfyUMs2POLBaTQluY0ghp0eoNkkBIDwB0/BsO vyYA==
- In-reply-to: <CAH+w=7bP_5ahuJZgswkmeyiF1Ozua0uznvZq0anzAVpA5c1kbw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAbwaZr6Pr8weACs7W7E1A6GF5y7QpwRanssYFdGnzSww@mail.gmail.com> <CAH+w=7bP_5ahuJZgswkmeyiF1Ozua0uznvZq0anzAVpA5c1kbw@mail.gmail.com>
On 1 August 2018 at 20:18, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Mon, Jul 30, 2018 at 12:09 AM, Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author