Comments (7)
Not really from what I can think of, you may want to make a custom "sep_by" parser to handle that.
With the current parsers combine provides though I think you might be able to hack around it with the recently added look_ahead
parser though.
sep_by(look_ahead(satisfy(|c| c != ',')).with(parser(other)), char(','))
It looks a bit weird but I think it should do what you want (might be some edge case I haven't considered though).
EDIT: No that will not actually work. I am not sure that what you want is actually possible in combine.
from combine.
I don't believe that what you want is easily possible with combine which uses recursive descent for parsing. If your other
parser is able to successfully consume a ',' at some point during its parsing it needs to be "aware" in some way that the sep_by parser should take precedence which is at odds with combine's model in which each parser is unaware of where it is used.
from combine.
I don't think it's necessarily at odds. The parser just needs to store and consume all tokens until it reaches the tokens that get consumed by the separator parser, then feed everything up to that point into the item parser. It's kind of cheating at LALR, but it might work okay.
from combine.
It might work but if you have a grammar which requires you to work around it like that it might be better to use a more powerful tool/library instead (lalrpop comes to mind but I don't know how mature it is yet).
from combine.
Closing. Feel free to reopen if there is more to be said on this topic
from combine.
When searching for precendence in this repo, this is the only result, but it seems the combine_language crate enables this? (https://docs.rs/combine-language/3.0.1/combine_language/struct.Assoc.html#structfield.precedence)
from combine.
That's a slightly different meaning of precedence but yes. If you need to parse one is expressions, combine-language supports that.
from combine.
Related Issues (20)
- Is there a way to get `Stream<Token=char>` from `io::Read`? HOT 1
- Tools for debugging recursion problems? HOT 4
- Some issue with error reporting
- Errors include unprintable or awkwardly printed characters. HOT 6
- `expected` error strings always quote what was expected, even if it isn't a literal HOT 3
- How about offset into some data? HOT 3
- Outdated tutorial HOT 1
- Native/abstracted sub-parsers HOT 6
- XML parsing for React.js to Solid.js conversion HOT 4
- Comparison with LALRPOP
- Unbounded mutual recursion in Parser impl HOT 3
- Adivce on reducing code size in WASM target HOT 7
- Docs unclear whether `parser!` should be used on nightly rust HOT 2
- Parse `std::process::Child` stdout
- Successful parser will not clear the error stack HOT 1
- build failure
- Implement Pratt parsing or precedence climbing HOT 4
- Choice with Vec of parsers HOT 4
- Documentation request: no_partial
- Worse performance after parsing 2 large values HOT 9
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 combine.