From 3597ad4eef2b7015d3b8455c7b5fc881b3ee7da6 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 4 Jul 2018 19:46:36 -0700 Subject: [PATCH] Compact parsing --- schala-lang/src/lib.rs | 10 ++++++++-- schala-repl/src/lib.rs | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index dc53b22..e07f954 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -81,8 +81,14 @@ fn parsing(_handle: &mut Schala, input: Vec, 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) } diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index e0231f0..3c7edfb 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -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); }