Replace matches with functional constructs

This commit is contained in:
greg 2019-07-28 11:10:20 -07:00
parent aa705b4eee
commit b62968379a
1 changed files with 7 additions and 13 deletions

View File

@ -96,11 +96,7 @@ fn tokenizing(input: &str, _handle: &mut Schala, comp: Option<&mut PassDebugArti
fn parsing(input: Vec<tokenizing::Token>, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
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<ast::AST, String> {
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<ast::AST, String> {