From 4fd04e8fd3c98c94f32a032dbcb12bad5f4f2796 Mon Sep 17 00:00:00 2001 From: Seymur Bagirov Date: Fri, 3 Jan 2025 03:20:09 +0400 Subject: [PATCH] feat: finish challenge #1 from chapter 6 --- src/parser.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 0265a8c..fb97903 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,5 +1,3 @@ -use std::fmt::Display; - use crate::{ ast::Expr, token::{LiteralType, Token, TokenType}, @@ -26,7 +24,13 @@ impl Parser<'_> { } fn expression(&mut self) -> Result { - self.equality() + self.comma() + } + + // Challenge #1. We're writing comma before equality, because it has the lowest precedence + fn comma(&mut self) -> Result { + use TokenType::*; + self.left_association_binary(&[Comma], Parser::equality) } fn equality(&mut self) -> Result {