Replace matches with functional constructs
This commit is contained in:
parent
aa705b4eee
commit
b62968379a
@ -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> {
|
fn parsing(input: Vec<tokenizing::Token>, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
||||||
use crate::parsing::Parser;
|
use crate::parsing::Parser;
|
||||||
|
|
||||||
let mut parser = match handle.active_parser.take() {
|
let mut parser = handle.active_parser.take().unwrap_or_else(|| Parser::new(input));
|
||||||
None => Parser::new(input),
|
|
||||||
Some(parser) => parser
|
|
||||||
};
|
|
||||||
|
|
||||||
let ast = parser.parse();
|
let ast = parser.parse();
|
||||||
let trace = parser.format_parse_trace();
|
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> {
|
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);
|
handle.symbol_table.borrow_mut().add_top_level_symbols(&input).map(|()| {
|
||||||
match add {
|
comp.map(|comp| {
|
||||||
Ok(()) => {
|
|
||||||
let debug = handle.symbol_table.borrow().debug_symbol_table();
|
let debug = handle.symbol_table.borrow().debug_symbol_table();
|
||||||
comp.map(|comp| comp.add_artifact(debug));
|
comp.add_artifact(debug);
|
||||||
Ok(input)
|
});
|
||||||
},
|
input
|
||||||
Err(msg) => Err(msg)
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn typechecking(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
fn typechecking(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user