More parsing debugging changes
This commit is contained in:
parent
bf3dcc18d0
commit
aae2ee53cd
10
schala-lang/language/src/debugging.rs
Normal file
10
schala-lang/language/src/debugging.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
@ -103,12 +103,12 @@ fn parsing(input: Vec<tokenizing::Token>, handle: &mut Schala, comp: Option<&mut
|
|||||||
comp.map(|comp| {
|
comp.map(|comp| {
|
||||||
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(),
|
||||||
|
Loading…
Reference in New Issue
Block a user