Comments (4)
This is behaving as expected. When you say "the next input should not be ascii_string([?A..?Z], min: 1) |> string("/")
", there is a completely valid answer for this, which is to just parse "M" or just parse "MI" and so on. All of them will have the minimum of characters you desire and they won't have the trailing "/" at the end, therefore they are all a valid answers for your negative lookahead.
from nimble_parsec.
I understand what you're saying. It's pretty undefined though - it's equally valid to say that since the combinator given to lookahead_not() does indeed match the upcoming text, the lookadhead_not() should trigger. It would perhaps be a good idea to make a note about the "minimal matching" nature of lookahead_not() in the documentation, if the current way it works is the desired one?
This makes it really hard to parse "free text", i.e. where you can't list all the allowed characters because it would be impractical, but instead would list the few non-allowed characters :)
EDIT: What do you think about adding an option to the lookahead_not() to let us make it "greedy"?
from nimble_parsec.
Note you can do ascii_string(not: ...)
, so there are other ways to do negation. Most times the best way is to just assert what you want, exactly because lookaheads may get expensive. Docs to clarify the current behaviour are definitely welcome though.
from nimble_parsec.
Cheers, I will see about other ways to reach the goal and perhaps file a little PR once I get a more complete picture of the situation. Thanks!
from nimble_parsec.
Related Issues (20)
- Is such a grammar supported? HOT 3
- Can't use remote combinators defined with defparsec HOT 7
- Library Abuse or Slow Compilation Times HOT 1
- `repeat_while` passing the wrong `context` in nested context
- Warning emitted by integer combinator HOT 3
- Add a default value to `optional` combinator HOT 2
- "Combinators are built during runtime" HOT 1
- When choice after repeat, not work HOT 2
- Fail to create combinator of consecutive repeats HOT 2
- No combinator for the beginning of a string
- MatchError from choice with integer and string. HOT 1
- Accept atoms as labels HOT 2
- Documentation: Error in second example under `repeat_while/4`
- NimbleParsec does not respect clauses order with OTP 26.0 (Elixir 1.14.4) HOT 3
- Potential "The pattern can never match the type." issue found by dialyxir HOT 3
- [proposal] Improve integer parsing HOT 2
- Add missing git tag for 1.3.1 HOT 1
- Bug with lookahead handling
- Parsing empty string raises `MatchError` for `integer(min: 0)` HOT 4
- Opaque type mismatch on `lookahead/2` since 1.2.0 HOT 5
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 nimble_parsec.