Skip to content

Commit

Permalink
semantic: Slight refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkajetanp committed Sep 2, 2024
1 parent 5829865 commit 03f5bb6
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,14 @@ fn clone_identifier_map(map: &IdentifierMap) -> IdentifierMap {
impl ast::Program {
pub fn validate(self) -> SemanticResult<Self> {
let mut ctx = SemanticCtx::new();
let ast = match self.resolve(&mut ctx) {
Ok(ast) => Ok(ast),
Err(err) => {
self.resolve(&mut ctx)
.inspect_err(|err| {
log::error!("Variable resolution error: {}", err);
Err(err)
}
};

let ast = match ast?.label(&mut ctx) {
Ok(ast) => Ok(ast),
Err(err) => {
})?
.label(&mut ctx)
.inspect_err(|err| {
log::error!("Loop labelling error: {}", err);
Err(err)
}
};

ast
})
}

pub fn resolve(self, ctx: &mut SemanticCtx) -> SemanticResult<Self> {
Expand Down

0 comments on commit 03f5bb6

Please sign in to comment.