Git Product home page Git Product logo

Comments (4)

wwoods avatar wwoods commented on July 18, 2024

If this is a limitation of parsy due to its flexibility, documenting that it cannot represent this class of languages (or can't express them in this way, rather) somewhere like https://parsy.readthedocs.io/en/latest/tutorial.html#alternatives-and-backtracking would be helpful.

from parsy.

wwoods avatar wwoods commented on July 18, 2024

Eh, I guess it is covered, just in a way that's a bit difficult to reason about. Would there be any way to emulate the sort of backtracking required to handle that case within parsy? In a real scenario, the b parser might be significantly more complicated.

from parsy.

spookylukey avatar spookylukey commented on July 18, 2024

So the | operator (and alt combinator which does the same) is the only built-in way to do backtracking in parsy, and it tries the second option only if the first fails, as documented. I could make this fact a bit clearer.

I don't think there would be an easy way to make parsy do backtracking by default over everything, and for the example you give, it seems impossible in fact: for it to succeed, we would somehow have to instruct the regex engine (i.e. Python's normal regex library) to not consume the za part, or to yield every possible match from the .* instead of the default greedy one, which I don't even think is possible.

Even if we could achieve this, it would drastically change performance characteristics, including the possibility of catastrophic backtracking. So there isn't likely to be a change here.

from parsy.

wwoods avatar wwoods commented on July 18, 2024

Alright, that makes sense.

I'm going to close the issue, since the only thing to do would be doc improvements. Thanks for your work on Parsy!

from parsy.

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.