More parsing debugging changes

This commit is contained in:
greg 2019-08-12 09:51:36 -07:00
parent bf3dcc18d0
commit aae2ee53cd
3 changed files with 15 additions and 4 deletions

View File

@ -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)
}
}

View File

@ -26,6 +26,7 @@ macro_rules! bx {
mod util; mod util;
#[macro_use] #[macro_use]
mod typechecking; mod typechecking;
mod debugging;
mod tokenizing; mod tokenizing;
mod ast; mod ast;

View File

@ -104,11 +104,11 @@ fn parsing(input: Vec<tokenizing::Token>, handle: &mut Schala, comp: Option<&mut
let debug_format = comp.parsing.as_ref().unwrap_or(&CompactAST); let debug_format = comp.parsing.as_ref().unwrap_or(&CompactAST);
let debug_info = match debug_format { let debug_info = match debug_format {
CompactAST => match ast{ CompactAST => match ast{
Ok(ref ast) => format!("{:?}", ast), Ok(ref ast) => ast.compact_debug(),
Err(_) => "Error - see output".to_string(), Err(_) => "Error - see output".to_string(),
}, },
ExpandedAST => match ast{ ExpandedAST => match ast{
Ok(ref ast) => format!("{:#?}", ast), Ok(ref ast) => ast.expanded_debug(),
Err(_) => "Error - see output".to_string(), Err(_) => "Error - see output".to_string(),
}, },
Trace => parser.format_parse_trace(), Trace => parser.format_parse_trace(),