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;
#[macro_use]
mod typechecking;
mod debugging;
mod tokenizing;
mod ast;

View File

@ -103,12 +103,12 @@ fn parsing(input: Vec<tokenizing::Token>, 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(),