zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
Date: Tue, 31 Jul 2018 07:13:47 +0200	[thread overview]
Message-ID: <CAKc7PVASk-xPxtfv3YsMhBoO8DYO3Pvr7rMVx+2+XgvEXy0vAA@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVBhRQE0UzjNN9ZLYRN1F_3_RzTNYAqkhS56n3yx67ty0A@mail.gmail.com>

There was __idx assign missing, and I fine-tuned readibility, so final version:

_mybuf="A\AB'A'C" #input
while  [[ $_mybuf = (#b)[^ABC\"\'\\]#(([ABC\"\'])|[\\](*))(*) ]]; do
    [[ -n "${match[3]}" ]] && {
        __idx+=${mbegin[1]}+1
        _mybuf="${match[3]:1}" # also skip 1 quoted char
    } || {
        __idx+=${mbegin[1]}
        [[ -z "$__quoting" ]] && {
            if [[ "${match[1]}" = [ABC] ]]; then
                echo "Got ${match[1]}"
            fi
        }

        # Toggle quoting
        [[ "${match[1]}" = \" && "$__quoting" != \' ]] && {
                [[ "$__quoting" = \" ]] && __quoting= || __quoting=\";
        }
        [[ "${match[1]}" = \' && "$__quoting" != \" ]] && {
                [[ "$__quoting" = \' ]] && __quoting= || __quoting=\';
        }

        # The last (*) in the pattern, i.e. remaining
        # string, to become next input to while
        _mybuf="${match[4]}"
   }
done


  reply	other threads:[~2018-07-31  5:14 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 [this message]
2018-08-01 18:18 ` Bart Schaefer
2018-08-02  7:32   ` Sebastian Gniazdowski

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=CAKc7PVASk-xPxtfv3YsMhBoO8DYO3Pvr7rMVx+2+XgvEXy0vAA@mail.gmail.com \
    --to=sgniazdowski@gmail.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).