Fix binop parsing from last commit

This commit is contained in:
Sofia 2025-08-04 14:51:17 +03:00
parent 79ecb3b9ba
commit 4a33e7d123
2 changed files with 11 additions and 3 deletions

View File

@ -199,9 +199,9 @@ impl<'a, 'b> TokenStream<'a, 'b> {
} }
} }
pub fn parse_with<T, U>(&mut self, fun: T) -> U pub fn parse_with<T, U>(&mut self, fun: T) -> Result<U, Error>
where where
T: FnOnce(TokenStream) -> U, T: FnOnce(TokenStream) -> Result<U, Error>,
{ {
let mut ref_pos = self.position; let mut ref_pos = self.position;
@ -213,7 +213,13 @@ impl<'a, 'b> TokenStream<'a, 'b> {
position, position,
}; };
fun(clone) match fun(clone) {
Ok(res) => {
self.position = ref_pos.max(self.position);
Ok(res)
}
Err(e) => Err(e),
}
} }
pub fn get_range(&self) -> Option<TokenRange> { pub fn get_range(&self) -> Option<TokenRange> {

View File

@ -134,6 +134,8 @@ pub fn compile_module<'map>(
is_main, is_main,
}; };
dbg!(&ast_module);
if errors.len() > 0 { if errors.len() > 0 {
// dbg!(&ast_module); // dbg!(&ast_module);
return Ok(Err(( return Ok(Err((