Comments (4)
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.
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.
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.
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)
- Fix or remove Python 3.3 tests HOT 2
- New release? HOT 2
- Weird bind implementation? HOT 7
- Strange peek behaviour/generator exception handling? HOT 4
- Tagged unions/product types for results HOT 11
- >>= for bind HOT 14
- Missing documentation for eof parser? HOT 1
- Improve debugging: peek show next data in errors HOT 5
- Recompute line number for ParseError passed up from .bind
- Improve debugging ergonomics HOT 3
- Inline (explicit) and implicit tracing
- Missing seq import statement in tutorial HOT 1
- Help with parsing that "hangs" HOT 3
- Parsy 1.3.0 fails to support 'group' keyword of `regex` function HOT 1
- async/await support in generate() HOT 6
- Release HOT 2
- Interested in a version of parsy with type annotations? HOT 3
- Allow providing a default to optional() HOT 2
- maintaining state while parsing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parsy.