Compact parsing

This commit is contained in:
greg 2018-07-04 19:46:36 -07:00
parent 072eab1a80
commit 3597ad4eef
2 changed files with 14 additions and 4 deletions

View File

@ -81,8 +81,14 @@ fn parsing(_handle: &mut Schala, input: Vec<tokenizing::Token>, comp: Option<&mu
comp.map(|comp| {
println!("DEBUG OPTS: {:?}", comp.cur_debug_options);
//TODO need to control which of these debug stages get added
comp.add_artifact(TraceArtifact::new_parse_trace(trace));
comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast)));
let opt = comp.cur_debug_options.get(0).map(|s| s.clone());
match opt {
None => comp.add_artifact(TraceArtifact::new("ast", format!("{:?}", ast))),
Some(ref s) if s == "compact" => comp.add_artifact(TraceArtifact::new("ast", format!("{:?}", ast))),
Some(ref s) if s == "expanded" => comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast))),
Some(ref s) if s == "trace" => comp.add_artifact(TraceArtifact::new_parse_trace(trace)),
Some(ref x) => println!("Bad parsing option: {}", x),
};
});
ast.map_err(|err| err.msg)
}

View File

@ -299,7 +299,6 @@ impl Repl {
self.line_reader.set_prompt(&prompt_str);
match self.line_reader.read_line() {
//Err(ReadlineError::Eof) | Err(ReadlineError::Interrupted) => break,
Err(e) => {
println!("Terminal read error: {}", e);
},
@ -453,10 +452,15 @@ impl Repl {
Some(s) => s.to_string(),
None => return Some(format!("Must specify a stage to debug")),
};
let pass_opt = commands.get(3);
if let Some(stage) = passes.iter().find(|stage_name| **stage_name == debug_pass) {
let mut opts = vec![];
if let Some(opt) = pass_opt {
opts.push(opt.to_string());
}
let msg = format!("{} debug for stage {}", if show { "Enabling" } else { "Disabling" }, debug_pass);
if show {
self.options.debug_passes.insert(stage.clone(), PassDebugDescriptor { opts: vec![] });
self.options.debug_passes.insert(stage.clone(), PassDebugDescriptor { opts });
} else {
self.options.debug_passes.remove(stage);
}