Loading ...
Sorry, an error occurred while loading the content.

\@<= multiline bug?

Expand Messages
  • Alex Efros
    Hi! Is there any reason why ( n n ) @
    Message 1 of 6 , Dec 3, 2012
    • 0 Attachment
      Hi!

      Is there any reason why "\(\\\n\\\n\)\@<=U" fail to match this text:

      \
      \
      U

      while "\(\\\n\\\n\)U" will match it and "\(\\\n\)\@<=U" will match it too
      (without first line)?


      Vim 7.3.646, Gentoo Linux amd64

      --
      WBR, Alex.

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Benjamin R. Haskell
      ... I suspect you re running into (from: :help / @
      Message 2 of 6 , Dec 3, 2012
      • 0 Attachment
        On Tue, 4 Dec 2012, Alex Efros wrote:

        > Hi!
        >
        > Is there any reason why "\(\\\n\\\n\)\@<=U" fail to match this text:
        >
        > \
        > \
        > U
        >
        > while "\(\\\n\\\n\)U" will match it and "\(\\\n\)\@<=U" will match it
        > too (without first line)?

        I suspect you're running into (from: :help /\@<= ):

        """
        "\@<=" and "\@<!" check for matches just before what follows.
        Theoretically these matches could start anywhere before this position.
        But to limit the time needed, only the line where what follows matches
        is searched, and one line before that (if there is one). This should be
        sufficient to match most things and not be too slow.
        """

        Probably, as it suggests there, you could just use \zs instead:

        \\\n\\\n\zsU

        --
        Best,
        Ben

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Alex Efros
        Hi! ... You right, but zs doesn t work for me. I m writing syntax highlight rules for mkfile (OS Inferno/Plan9 variant of Makefile). It allow any amount of
        Message 3 of 6 , Dec 3, 2012
        • 0 Attachment
          Hi!

          On Mon, Dec 03, 2012 at 05:53:58PM -0500, Benjamin R. Haskell wrote:
          > Probably, as it suggests there, you could just use \zs instead:
          >
          > \\\n\\\n\zsU

          You right, but \zs doesn't work for me. I'm writing syntax highlight rules
          for mkfile (OS Inferno/Plan9 variant of Makefile). It allow any amount of \
          at EOL, so these are the same:

          VAR=U=value

          VAR\
          \
          =\
          \
          U\
          \
          =\
          \
          value

          So, I'm trying to match "U" between "=" with any amount of \\\n between them:

          syn match mkfileVarAttr contained "^\w\(\w\|\\\n\)*\(\s\|\\\n\)*=\(\(\\\n\)*\(=\|U\(\\\n\)*=\)\)\?"
          \ contains=mkfileVar,mkfileDelimiter,mkfileAttr
          syn match mkfileVar contained "^\(\w\|\\\n\)*\w"
          syn match mkfileDelimiter contained "="
          syn match mkfileAttr contained "\(=\(\\\n\)*\)\@<=U\(\(\\\n\)*=\)\@="

          and using \zs in mkfileAttr doesn't work.

          --
          WBR, Alex.

          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Ben Fritz
          ... Maybe just match the n sequences as a separate syntax item and use nextgroup to enforce ordering. It should work (probably even a little bit faster) and
          Message 4 of 6 , Dec 4, 2012
          • 0 Attachment
            On Monday, December 3, 2012 5:07:58 PM UTC-6, Alex Efros wrote:
            > Hi!
            >
            >
            >
            > On Mon, Dec 03, 2012 at 05:53:58PM -0500, Benjamin R. Haskell wrote:
            >
            > > Probably, as it suggests there, you could just use \zs instead:
            >
            > >
            >
            > > \\\n\\\n\zsU
            >
            >
            >
            > You right, but \zs doesn't work for me. I'm writing syntax highlight rules
            >
            > for mkfile (OS Inferno/Plan9 variant of Makefile). It allow any amount of \
            >
            > at EOL, so these are the same:
            >
            >
            >
            > VAR=U=value
            >
            >
            >
            > VAR\
            >
            > \
            >
            > =\
            >
            > \
            >
            > U\
            >
            > \
            >
            > =\
            >
            > \
            >
            > value
            >
            >
            >
            > So, I'm trying to match "U" between "=" with any amount of \\\n between them:
            >
            >

            Maybe just match the \\\n sequences as a separate syntax item and use nextgroup to enforce ordering. It should work (probably even a little bit faster) and also simplify your pattern.

            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Alex Efros
            Hi! ... As far as I understood, nextgroup is just a recommendation, while I ve tried to implement more strict syntax checking after that item can be only this
            Message 5 of 6 , Dec 5, 2012
            • 0 Attachment
              Hi!

              On Tue, Dec 04, 2012 at 08:29:39AM -0800, Ben Fritz wrote:
              > Maybe just match the \\\n sequences as a separate syntax item and use
              > nextgroup to enforce ordering. It should work (probably even a little
              > bit faster) and also simplify your pattern.

              As far as I understood, nextgroup is just a recommendation, while I've
              tried to implement more strict syntax checking "after that item can be
              only this one, and after this there can be only one of these items, etc.".
              Maybe I'm wrong in trying to go this way, because it's syntax highlighter,
              not real parser/compiler, it may be a little relaxed…

              --
              WBR, Alex.

              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            • Ben Fritz
              ... You already know from the mkfileVarAttr match that the pattern you are looking for matches strictly. Now you just need to match the components of it which
              Message 6 of 6 , Dec 5, 2012
              • 0 Attachment
                On Wednesday, December 5, 2012 9:37:26 PM UTC-6, Alex Efros wrote:
                > Hi!
                >
                >
                >
                > On Tue, Dec 04, 2012 at 08:29:39AM -0800, Ben Fritz wrote:
                >
                > > Maybe just match the \\\n sequences as a separate syntax item and use
                >
                > > nextgroup to enforce ordering. It should work (probably even a little
                >
                > > bit faster) and also simplify your pattern.
                >
                >
                >
                > As far as I understood, nextgroup is just a recommendation, while I've
                >
                > tried to implement more strict syntax checking "after that item can be
                >
                > only this one, and after this there can be only one of these items, etc.".
                >
                > Maybe I'm wrong in trying to go this way, because it's syntax highlighter,
                >
                > not real parser/compiler, it may be a little relaxed…
                >

                You already know from the mkfileVarAttr match that the pattern you are looking for matches strictly. Now you just need to match the components of it which can be done more lazily since you know it's there.

                --
                You received this message from the "vim_dev" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
              Your message has been successfully submitted and would be delivered to recipients shortly.