From 35d214c9f60ab5c6783ab65df369ecf381e64520 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 27 Oct 2023 00:19:19 -0500 Subject: [PATCH] ast: Remove vestigial "ignore" in Expr --- libconlang/src/ast.rs | 8 +++----- libconlang/src/parser.rs | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libconlang/src/ast.rs b/libconlang/src/ast.rs index 5b3a5eb..21c2580 100644 --- a/libconlang/src/ast.rs +++ b/libconlang/src/ast.rs @@ -210,9 +210,7 @@ pub mod expression { /// # Syntax /// [`Expr`]` := `[`math::Operation`] #[derive(Clone, Debug)] - pub struct Expr { - pub ignore: math::Operation, - } + pub struct Expr (pub math::Operation); /// A [Primary] Expression is the expression with the highest precedence (i.e. the deepest /// derivation) @@ -693,7 +691,7 @@ pub mod visitor { } impl> + ?Sized, E> Walk> for Expr { fn walk(&self, visitor: &mut T) -> Result<(), E> { - visitor.visit_operation(&self.ignore) + visitor.visit_operation(&self.0) } } impl> + ?Sized, E> Walk> for Group { @@ -804,7 +802,7 @@ pub mod visitor { /// Visit an [Expression](Expr) fn visit_expr(&mut self, expr: &Expr) -> R { - self.visit_operation(&expr.ignore) + self.visit_operation(&expr.0) } // Block expression /// Visit a [Block] expression diff --git a/libconlang/src/parser.rs b/libconlang/src/parser.rs index 0e84b83..123f49b 100644 --- a/libconlang/src/parser.rs +++ b/libconlang/src/parser.rs @@ -229,13 +229,13 @@ impl Parser { Ok(token) } /// Consumes, without returning, a token with the given [Keyword], or returns an error. - /// + /// /// Useful if you only want to check the existence of a [Keyword] fn keyword(&mut self, keyword: Keyword) -> PResult<&mut Self> { self.consume_type(Type::Keyword(keyword)) } /// Consumes, without returning, a token with the given [Type], or returns an error. - /// + /// /// Useful if you only want to check the existence of a token. fn consume_type(&mut self, t: Type) -> PResult<&mut Self> { self.matches(t)?; @@ -381,7 +381,7 @@ impl Parser { /// Parses an [expression](expression::Expr) fn expr(&mut self) -> PResult { use expression::Expr; - Ok(Expr { ignore: self.assign()? }) + Ok(Expr(self.assign()?)) } /// Parses a [block expression](expression::Block) fn block(&mut self) -> PResult {