-
Notifications
You must be signed in to change notification settings - Fork 6
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
Suggestions: New features for version 0.2.0? #1
Comments
I think it is nice if it could add parsing guard feature in next version. eg: (just my 2 cents) html =
"<" <tag1: string> ">"
value
"<" "/" <tag1: string> ">" Basically it adds a runtime constraints to match the tag based on the tag name. And it can be used as a combinator. |
@zypeh Edit: Do you mean a way to ensure that the two strings/tags parsed are equal, and make the parser fail otherwise? This would definitely be useful for parsing non-regular grammars |
Yes. 😃 The example I had given is not so precise anyway, my bad. But I would like to know how to implement this feature. |
Hm, I'd probably make it a bit more general and optionally allow the code block at the end to return a Maybe something like this:
Note the |
It might be nice to be able to specify ranges of characters. I'm not entirely sure what the best way to do this would be, but something along the following would be really nice.
as an alternative to manually writing the nom parser for this, which would look like the following:
I'm also not sure whether it would be better to use characters here, or strings, or the number values (i.e. 0x20-0x21). Another alternative to this could be to use the |
Yeah, I've been thinking about this too, it's definitely one of the next features I wanna add. Having a specific syntax for One potential problem with that approach could be that, if I remember correctly, the semantics of regexes are slightly different than those of PEG grammars. So, interspersing them could become confusing and result in unintuitive results. |
normally, if I were just writing a nom parser and had repeated occurrences of this "all chars in x range" pattern, I'd write a function like the following:
However within the pattern declaration portion of the
Maybe allowing some syntax for pure rust blocks that return nom parsers within the macro would be an alternative way to implement this. |
Adding support for calling arbitrary nom parser functions in the |
Hey,
Just putting this issue here to list suggestions / ideas for the next version.
The text was updated successfully, but these errors were encountered: