Code Monkey home page Code Monkey logo

Comments (2)

RedCMD avatar RedCMD commented on June 5, 2024

Can confirm
seems like there are two different points being made

  1. \\k<2> does not behave the same as \\2 when backreferencing capture groups between begin/end rules.
    I would think is a non-issue as it would be annoying to have to count all the capture groups in begin when trying to reference one in end (through the usage of \\k<2>)
  2. an invalid group number in \\k<2> causes the textmate engine to crash.
    this is more or less consistent with all other textmate errors. eg. invalid \\g<4> groups
    seems like \\2 inside end has a special property, to not crash the engine when capture group 2 does not exist, but instead match against nothing .

\\h<2> matches against a hexadecimal number and the literal chars <2>
image

(Note: \2 is not a viable workaround when group numbers are ≥10)

\\14 works fine for me?
image

from vscode-textmate.

jeff-hykin avatar jeff-hykin commented on June 5, 2024

\14 works fine for me?

Oh interesting, I suppose (?:\14)4 would be equivlent to \k<14>4 in that case.
So there's still a bug, but there's a reliable workaround (which is great news for me)

causes the textmate engine to crash. this is more or less consistent with all other textmate errors

I'd argue that for both \k and \g, either the crash should show up in the debug console, or (if crashing is not an option) then the engine should fallback on matching as an empty string. Having it partially highlight document, while sliently crashing is what I would consider an issue.

I would think is a non-issue as it would be annoying to have to count all the capture groups in begin when trying to reference one in end (through the usage of \k<2>)

Many existing syntaxes, like Ruby and Shell, would break if that reference-groups-from-the-start feature never worked. Just cause a feature is hard to manually use doesn't make it being broken a non-issue.

it would be annoying to have to count all the capture groups

I agree which is why I never count capture groups, I made the ruby grammer builder do the heavy lifting. Some C++ patterns have over 100 capture groups so it would've been unrealistic for me to maintain any other way.

Screen Shot 2022-12-13 at 10 23 23 AM

from vscode-textmate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.