Debug stuff
This commit is contained in:
@@ -137,21 +137,15 @@ fn parsing(input: Vec<tokenizing::Token>, handle: &mut Schala, comp: Option<&mut
|
||||
};
|
||||
|
||||
let ast = parser.parse();
|
||||
let _trace = parser.format_parse_trace();
|
||||
let trace = parser.format_parse_trace();
|
||||
|
||||
comp.map(|comp| {
|
||||
comp.add_artifact(format!("{:#?}", ast));
|
||||
/*
|
||||
//TODO need to control which of these debug stages get added
|
||||
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 debug option: {}", x),
|
||||
let debug_info = match comp.parsing.as_ref().unwrap_or(&ParsingDebugType::CompactAST) {
|
||||
ParsingDebugType::CompactAST => format!("{:?}", ast),
|
||||
ParsingDebugType::ExpandedAST => format!("{:#?}", ast),
|
||||
ParsingDebugType::Trace => format!("{}", trace[0]) //TODO fix this
|
||||
};
|
||||
*/
|
||||
comp.add_artifact(debug_info);
|
||||
});
|
||||
ast.map_err(|err| format_parse_error(err, handle))
|
||||
}
|
||||
@@ -236,9 +230,17 @@ impl SourceReference {
|
||||
}
|
||||
}
|
||||
|
||||
enum ParsingDebugType {
|
||||
CompactAST,
|
||||
ExpandedAST,
|
||||
Trace
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct PassDebugArtifact {
|
||||
parsing: Option<ParsingDebugType>,
|
||||
artifacts: Vec<String>
|
||||
|
||||
}
|
||||
impl PassDebugArtifact {
|
||||
fn add_artifact(&mut self, artifact: String) {
|
||||
@@ -276,7 +278,12 @@ impl ProgrammingLanguageInterface for Schala {
|
||||
{
|
||||
let stage_names = stage_names();
|
||||
let ask = DebugAsk::ByStage { stage_name: stage_names[n].to_string() };
|
||||
let mut debug_artifact = tok.debug_requests.get(&ask).map(|_| PassDebugArtifact::default());
|
||||
let mut debug_artifact = tok.debug_requests.get(&ask).map(|_|
|
||||
PassDebugArtifact {
|
||||
parsing: if stage_names[n] == "parsing" { Some(ParsingDebugType::CompactAST) } else { None },
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
let output = func(input, tok.schala, debug_artifact.as_mut());
|
||||
|
||||
tok.stage_durations.push((stage_names[n].to_string(), tok.sw.elapsed()));
|
||||
|
||||
Reference in New Issue
Block a user