diff --git a/schala-lang/language/src/debugging.rs b/schala-lang/language/src/debugging.rs new file mode 100644 index 0000000..d4e8d10 --- /dev/null +++ b/schala-lang/language/src/debugging.rs @@ -0,0 +1,10 @@ +use crate::ast::*; + +impl AST { + pub fn compact_debug(&self) -> String { + format!("{:?}", self) + } + pub fn expanded_debug(&self) -> String { + format!("{:#?}", self) + } +} diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 8afe164..ac96a04 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -26,6 +26,7 @@ macro_rules! bx { mod util; #[macro_use] mod typechecking; +mod debugging; mod tokenizing; mod ast; diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index 167f0cb..0940401 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -103,12 +103,12 @@ fn parsing(input: Vec, handle: &mut Schala, comp: Option<&mut comp.map(|comp| { let debug_format = comp.parsing.as_ref().unwrap_or(&CompactAST); let debug_info = match debug_format { - CompactAST => match ast { - Ok(ref ast) => format!("{:?}", ast), + CompactAST => match ast{ + Ok(ref ast) => ast.compact_debug(), Err(_) => "Error - see output".to_string(), }, - ExpandedAST => match ast { - Ok(ref ast) => format!("{:#?}", ast), + ExpandedAST => match ast{ + Ok(ref ast) => ast.expanded_debug(), Err(_) => "Error - see output".to_string(), }, Trace => parser.format_parse_trace(),