ast: Remove vestigial "ignore" in Expr

This commit is contained in:
John 2023-10-27 00:19:19 -05:00
parent ac540ebd22
commit 35d214c9f6
2 changed files with 6 additions and 8 deletions

View File

@ -210,9 +210,7 @@ pub mod expression {
/// # Syntax /// # Syntax
/// [`Expr`]` := `[`math::Operation`] /// [`Expr`]` := `[`math::Operation`]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Expr { pub struct Expr (pub math::Operation);
pub ignore: math::Operation,
}
/// A [Primary] Expression is the expression with the highest precedence (i.e. the deepest /// A [Primary] Expression is the expression with the highest precedence (i.e. the deepest
/// derivation) /// derivation)
@ -693,7 +691,7 @@ pub mod visitor {
} }
impl<T: Visitor<Result<(), E>> + ?Sized, E> Walk<T, Result<(), E>> for Expr { impl<T: Visitor<Result<(), E>> + ?Sized, E> Walk<T, Result<(), E>> for Expr {
fn walk(&self, visitor: &mut T) -> Result<(), E> { fn walk(&self, visitor: &mut T) -> Result<(), E> {
visitor.visit_operation(&self.ignore) visitor.visit_operation(&self.0)
} }
} }
impl<T: Visitor<Result<(), E>> + ?Sized, E> Walk<T, Result<(), E>> for Group { impl<T: Visitor<Result<(), E>> + ?Sized, E> Walk<T, Result<(), E>> for Group {
@ -804,7 +802,7 @@ pub mod visitor {
/// Visit an [Expression](Expr) /// Visit an [Expression](Expr)
fn visit_expr(&mut self, expr: &Expr) -> R { fn visit_expr(&mut self, expr: &Expr) -> R {
self.visit_operation(&expr.ignore) self.visit_operation(&expr.0)
} }
// Block expression // Block expression
/// Visit a [Block] expression /// Visit a [Block] expression

View File

@ -229,13 +229,13 @@ impl Parser {
Ok(token) Ok(token)
} }
/// Consumes, without returning, a token with the given [Keyword], or returns an error. /// 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] /// Useful if you only want to check the existence of a [Keyword]
fn keyword(&mut self, keyword: Keyword) -> PResult<&mut Self> { fn keyword(&mut self, keyword: Keyword) -> PResult<&mut Self> {
self.consume_type(Type::Keyword(keyword)) self.consume_type(Type::Keyword(keyword))
} }
/// Consumes, without returning, a token with the given [Type], or returns an error. /// 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. /// Useful if you only want to check the existence of a token.
fn consume_type(&mut self, t: Type) -> PResult<&mut Self> { fn consume_type(&mut self, t: Type) -> PResult<&mut Self> {
self.matches(t)?; self.matches(t)?;
@ -381,7 +381,7 @@ impl Parser {
/// Parses an [expression](expression::Expr) /// Parses an [expression](expression::Expr)
fn expr(&mut self) -> PResult<expression::Expr> { fn expr(&mut self) -> PResult<expression::Expr> {
use expression::Expr; use expression::Expr;
Ok(Expr { ignore: self.assign()? }) Ok(Expr(self.assign()?))
} }
/// Parses a [block expression](expression::Block) /// Parses a [block expression](expression::Block)
fn block(&mut self) -> PResult<expression::Block> { fn block(&mut self) -> PResult<expression::Block> {