-
Notifications
You must be signed in to change notification settings - Fork 106
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
Improve documentation and examples how to handle strings properly #314
Comments
The
though if you want to copy it into an owned
You can compose these into something that parses a sequence of strings:
or inline the rule if you don't want the separate rule:
If by "string" you mean something like a quoted string literal, it gets a little more complicated to handle escape sequences rather than a simple slice of the input:
Hope that helps. Leaving this issue open for these examples to be integrated somewhere in the documentation. |
That's great. Maybe a bit more details about the semantics of the |
The
expands into a function like
In #299 (probably for 0.9), the name will be customizable instead of hard-coded, making it seem a little less magical. |
How can we match unicode identifiers? Is it possible to use |
Yes, rule identifier() -> &'input str = $([c if is_xid_start(c)] [c if is_xid_continue(c)]*) |
The documentation only shows examples of parsing numbers and single characters. Almost all the tests also don't parse strings, which makes it hard to know what one needs to do, especially if one is a bit of a beginner in Rust and rust-peg.
The information about the
'input
lifetime annotation is a bit elusive (not documented), and it is not clear how this affects the lifetime annotations needed for any structs receiving the parsed str or Vec of str.It would also be great if there were some recommendations as to how strings should be parsed, and if zero-copy can be achieved in any way.
Some proper documentation with a few examples of parsing singular or vec of strings (with operators such as ** and ++) would be really helpful.
The text was updated successfully, but these errors were encountered: