-
Notifications
You must be signed in to change notification settings - Fork 51
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
Parser #2353
Parser #2353
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff! I left some notes to address but once those are handled we should be good to go. Just remember to tag me for a re-review when you submit those
interp/src/debugger/commands/core.rs
Outdated
self.nodes.clone() | ||
} | ||
|
||
pub fn from_iter<I>(iter: I) -> ParsePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As clippy points out, there is a trait called FromIterator
which you should move this implementation into.
See: https://doc.rust-lang.org/std/iter/trait.FromIterator.html
pub fn get_path(&self) -> Vec<ParseNodes> { | ||
self.nodes.clone() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend making this a standard accessor which returns a reference to the vec
or a slice and cloning externally when necessary
@@ -0,0 +1,13 @@ | |||
root = { "." } | |||
|
|||
seperator = { "-" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo
|
||
// Parse the path | ||
pub fn parse_path(input_str: &str) -> Result<ParsePath, Error<Rule>> { | ||
let entries = PathParser::parse(Rule::path, input_str)?; | ||
let entry = entries.single()?; | ||
|
||
PathParser::path(entry) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add #[allow(dead_code)]
here for the moment since this PR doesn't use the
function. This will quiet clippy down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix the size issue change the return type to Box<Error<Rule>>
and add
.map_err(Box::new)
to the final line
Created a parser to process the path we've described such as: ".-0-1-b"