-
Notifications
You must be signed in to change notification settings - Fork 45
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
Metadata #2022
Metadata #2022
Conversation
cider-dap/src/adapter.rs
Outdated
@@ -120,13 +118,15 @@ impl MyAdapter { | |||
let map = status.get_status().clone(); | |||
// Declare line number beforehand |
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.
This clone shouldn't be necessary
interp/src/debugger/cidr.rs
Outdated
@@ -96,6 +101,10 @@ impl Debugger { | |||
let mut ctx = ir::from_ast::ast_to_ir(ws)?; | |||
let pm = PassManager::default_passes()?; | |||
|
|||
// Metadata stuff | |||
let metadata = ctx.metadata.clone().unwrap(); |
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.
This clone isn't necessary
interp/src/debugger/cidr.rs
Outdated
@@ -96,6 +101,10 @@ impl Debugger { | |||
let mut ctx = ir::from_ast::ast_to_ir(ws)?; | |||
let pm = PassManager::default_passes()?; | |||
|
|||
// Metadata stuff | |||
let metadata = ctx.metadata.clone().unwrap(); | |||
let mapping = parse_metadata(&metadata).unwrap(); |
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.
You want to use the map method of Option
so that we don't explode in the case
where the metadata isn't present, rather than using unwrap
interp/src/debugger/cidr.rs
Outdated
metadata: Option<NewSourceMap>, | ||
) -> InterpreterResult<(Self, NewSourceMap)> { |
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.
I think we can leave this constructor only returning a debugger for the time
being, and have the from_file
one be used when there is a need to return the
metadata table. There's also not much point in passing in the metadata map only
to return it as a non-option since this will break the code in places where the
metadata map isn't present
interp/src/debugger/new_parser.rs
Outdated
} | ||
fn group_name(input: Node) -> ParseResult<String> { | ||
input | ||
.as_str() | ||
.parse::<String>() | ||
.map_err(|_| input.error("Expected character")) | ||
} |
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.
&str
means it's a string slice, which can be easily turned into a String
with the to_string
method which is infallible. You can then wrap the whole
thing in an Ok(_)
to get the desired result
} | |
fn group_name(input: Node) -> ParseResult<String> { | |
input | |
.as_str() | |
.parse::<String>() | |
.map_err(|_| input.error("Expected character")) | |
} | |
.to_string() |
interp/src/debugger/new_parser.rs
Outdated
fn path(input: Node) -> ParseResult<String> { | ||
input | ||
.as_str() | ||
.parse::<String>() |
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.
Same note about strings as the prior one!
input | ||
.as_str() | ||
.parse::<u64>() | ||
.map_err(|_| input.error("Expected number")) |
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.
You can use match_nodes!
here to avoid needing to invoke parse
. If we've
reached this point it should already be parseable anyway so no need for this
failure path.
See
fn pc_ufx(input: Node) -> ParseResult<usize> { |
for an example
|
||
fn entry(input: Node) -> ParseResult<(String, GroupContents)> { | ||
Ok(match_nodes!(input.into_children(); | ||
[group_name(g), path(p),num(n)] => (g,GroupContents {path:p, line: n}) |
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: spacing
interp/src/main.rs
Outdated
let (cidb, _) = | ||
Debugger::new(&components, main_component, map, env, None)?; |
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.
See the other note about the constructor
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.
On the whole looks great! Really good work with this, there are a few minor issues to correct with the constructor and a few ways the parser code could be simplified but otherwise this is looking good
* Basic scaffolding for metadeta * Implemented new_metadata.pset and new_parser.rs * Added new_parser and test cases * Enabled debugger to debug any .futil file * Clippy complaints * Adjusted code to PR suggestions and added some comments
new_metadata.pest:
metadata #{
group1: /path/to/file LINE_NUMBER
group2: /path/to/file LINE_NUMBER
}#
new_parser.rs
Miscellaneous: