From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28378 invoked by alias); 2 Aug 2018 07:32:33 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23552 Received: (qmail 10664 invoked by uid 1010); 2 Aug 2018 07:32:33 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f52.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.218.52):SA:0(-1.9/5.0):. Processed in 1.916189 secs); 02 Aug 2018 07:32:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=XjhmXY3sEBWezXa6XC/oIOOMIRYh9TBmtFLASZNJ/aY=; b=Ov72ilsP80HSDwlIkynBHozULPoS0eMdexXU/jSHhazRUI5KOCuYS4l4fcSJ7VSH+f M2wDOlaq1n/vZGftunjkDVjTXi+X7GjySUoJ3mm7HRF9F7l+04Lxp1arULU4mTCALMk+ 9NbDwnEJ4lj6nx20RTPw728mU659Y5a1lvsP2+ogwhvn6qxmwPc87NhQSF2BRxK+3m4z /59feOZ4pe3w/5z8VXSwXe2UBEA/luLREe90rEqMikV3eEGEGCWEZ+stccfREw/D5iRD uItMjflYlZk1CjkUMr28DjM0jIDM0h2GWLuR5k4cF/RSTtgVnrV1tSFqI+6CT/dUUidD kpIA== X-Gm-Message-State: AOUpUlGEeAt+8SmpSuGdzaEMHm5cnkCxE8bDHt0/v+RqKfWwIWSFcss5 ajmq7JIPC4K5bfUugsgDIOfEC++oQbSds7BKENTfeg== X-Google-Smtp-Source: AAOMgpce3WF26W7CfEqzRHjufqT6VDYb/xzg2LmOYeZLLkAbyMGqOybHDGIZhpWNXVvdzmJ/mMSLfrjirE4Dcg+mHxc= X-Received: by 2002:aca:390a:: with SMTP id g10-v6mr1707151oia.145.1533195149204; Thu, 02 Aug 2018 00:32:29 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Sebastian Gniazdowski Date: Thu, 2 Aug 2018 09:32:08 +0200 Message-ID: Subject: Re: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH. To: Bart Schaefer Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 1 August 2018 at 20:18, Bart Schaefer wrote: > On Mon, Jul 30, 2018 at 12:09 AM, Sebastian Gniazdowski > 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 \" =E2=80=93 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=3D=3Din-single-quote, and decide to skip next char accordingly. --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin