From 4a33e7d123d7c68900313a1077582da80c71c309 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 4 Aug 2025 14:51:17 +0300 Subject: [PATCH] Fix binop parsing from last commit --- reid/src/ast/token_stream.rs | 12 +++++++++--- reid/src/lib.rs | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/reid/src/ast/token_stream.rs b/reid/src/ast/token_stream.rs index 89f5c48..9b8e550 100644 --- a/reid/src/ast/token_stream.rs +++ b/reid/src/ast/token_stream.rs @@ -199,9 +199,9 @@ impl<'a, 'b> TokenStream<'a, 'b> { } } - pub fn parse_with(&mut self, fun: T) -> U + pub fn parse_with(&mut self, fun: T) -> Result where - T: FnOnce(TokenStream) -> U, + T: FnOnce(TokenStream) -> Result, { let mut ref_pos = self.position; @@ -213,7 +213,13 @@ impl<'a, 'b> TokenStream<'a, 'b> { 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 { diff --git a/reid/src/lib.rs b/reid/src/lib.rs index 37610c4..587777a 100644 --- a/reid/src/lib.rs +++ b/reid/src/lib.rs @@ -134,6 +134,8 @@ pub fn compile_module<'map>( is_main, }; + dbg!(&ast_module); + if errors.len() > 0 { // dbg!(&ast_module); return Ok(Err((