-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sep_by(any(), char(',')) #52
Comments
Not really from what I can think of, you may want to make a custom "sep_by" parser to handle that.
EDIT: No that will not actually work. I am not sure that what you want is actually possible in combine. |
I don't believe that what you want is easily possible with combine which uses recursive descent for parsing. If your |
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. |
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). |
Closing. Feel free to reopen if there is more to be said on this topic |
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) |
That's a slightly different meaning of precedence but yes. If you need to parse one is expressions, combine-language supports that. |
Is there an uncomplicated way to achieve a parser that does
sep_by(any(), char(','))
?I currently have something like
sep_by(parser(other), char(','))
whereother
is a separate parser that just matchesany()
, but that blows right through every instance of,
due to theany()
parser.What I want is something that works the same as sep_by, but parsing the separator takes precedence over parsing the separated values. I don't want the
other
parser to need to be aware of the context in which it is used.The text was updated successfully, but these errors were encountered: