From 5c9a8dab318eb42a641577bb1cc0040e62ea7af3 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 5 Sep 2024 11:36:55 -0400 Subject: [PATCH] Clean up --- dust-lang/src/context.rs | 6 +++--- dust-lang/src/parser.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dust-lang/src/context.rs b/dust-lang/src/context.rs index fbe9c58..1241da3 100644 --- a/dust-lang/src/context.rs +++ b/dust-lang/src/context.rs @@ -159,12 +159,12 @@ impl Context { /// program. Returns a boolean indicating whether the identifier was found. If the identifier is /// not found in the current context, the parent context is searched but parent context's /// position is not updated. - pub fn update_last_position( + pub fn set_position( &self, identifier: &Identifier, position: usize, ) -> Result { - self.inner.update_last_position(identifier, position) + self.inner.set_position(identifier, position) } /// Recovers the context from a poisoned state by recovering data from an error. @@ -457,7 +457,7 @@ impl ContextInner { /// program. Returns a boolean indicating whether the identifier was found. If the identifier is /// not found in the current context, the parent context is searched but parent context's /// position is not updated. - pub fn update_last_position( + pub fn set_position( &self, identifier: &Identifier, position: usize, diff --git a/dust-lang/src/parser.rs b/dust-lang/src/parser.rs index 85bd001..cb7f8b8 100644 --- a/dust-lang/src/parser.rs +++ b/dust-lang/src/parser.rs @@ -453,7 +453,7 @@ impl<'src> Parser<'src> { let identifier = Identifier::new(text); if let ParserMode::Condition = self.mode { - context.update_last_position(&identifier, start_position.1)?; + context.set_position(&identifier, start_position.1)?; return Ok(Expression::identifier(identifier, start_position)); } @@ -494,7 +494,7 @@ impl<'src> Parser<'src> { let position = (start_position.0, self.current_position.1); - context.update_last_position(&identifier, position.1)?; + context.set_position(&identifier, position.1)?; return Ok(Expression::r#struct( StructExpression::Fields { name, fields }, @@ -502,7 +502,7 @@ impl<'src> Parser<'src> { )); } - context.update_last_position(&identifier, start_position.1)?; + context.set_position(&identifier, start_position.1)?; Ok(Expression::identifier(identifier, start_position)) } @@ -986,7 +986,7 @@ impl<'src> Parser<'src> { self.next_token()?; - context.update_last_position(&identifier, position.1)?; + context.set_position(&identifier, position.1)?; Ok(Node::new(identifier, position)) } else {