diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index fd733c7..b0260a1 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -96,11 +96,7 @@ fn tokenizing(input: &str, _handle: &mut Schala, comp: Option<&mut PassDebugArti fn parsing(input: Vec, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result { use crate::parsing::Parser; - let mut parser = match handle.active_parser.take() { - None => Parser::new(input), - Some(parser) => parser - }; - + let mut parser = handle.active_parser.take().unwrap_or_else(|| Parser::new(input)); let ast = parser.parse(); let trace = parser.format_parse_trace(); @@ -133,15 +129,13 @@ fn format_parse_error(error: parsing::ParseError, handle: &mut Schala) -> String } fn symbol_table(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result { - let add = handle.symbol_table.borrow_mut().add_top_level_symbols(&input); - match add { - Ok(()) => { + handle.symbol_table.borrow_mut().add_top_level_symbols(&input).map(|()| { + comp.map(|comp| { let debug = handle.symbol_table.borrow().debug_symbol_table(); - comp.map(|comp| comp.add_artifact(debug)); - Ok(input) - }, - Err(msg) => Err(msg) - } + comp.add_artifact(debug); + }); + input + }) } fn typechecking(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result {