diff options
Diffstat (limited to 'users/tazjin/rlox/src/treewalk/parser.rs')
-rw-r--r-- | users/tazjin/rlox/src/treewalk/parser.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/users/tazjin/rlox/src/treewalk/parser.rs b/users/tazjin/rlox/src/treewalk/parser.rs index 8117c29726c9..003cc34b4665 100644 --- a/users/tazjin/rlox/src/treewalk/parser.rs +++ b/users/tazjin/rlox/src/treewalk/parser.rs @@ -213,7 +213,9 @@ impl Parser { if params.len() >= 255 { return Err(Error { line: self.peek().line, - kind: ErrorKind::InternalError("255 parameter limit exceeded.".into()), + kind: ErrorKind::InternalError( + "255 parameter limit exceeded.".into(), + ), }); } @@ -427,7 +429,10 @@ impl Parser { return Err(Error { line: equals.line, - kind: ErrorKind::InvalidAssignmentTarget(format!("{:?}", equals)), + kind: ErrorKind::InvalidAssignmentTarget(format!( + "{:?}", + equals + )), }); } @@ -490,7 +495,9 @@ impl Parser { } fn unary(&mut self) -> ExprResult { - if self.match_token(&TokenKind::Bang) || self.match_token(&TokenKind::Minus) { + if self.match_token(&TokenKind::Bang) + || self.match_token(&TokenKind::Minus) + { return Ok(Expr::Unary(Unary { operator: self.previous().clone(), right: Box::new(self.unary()?), @@ -550,7 +557,10 @@ impl Parser { TokenKind::LeftParen => { let expr = self.expression()?; - self.consume(&TokenKind::RightParen, ErrorKind::UnmatchedParens)?; + self.consume( + &TokenKind::RightParen, + ErrorKind::UnmatchedParens, + )?; return Ok(Expr::Grouping(Grouping(Box::new(expr)))); } @@ -622,7 +632,11 @@ impl Parser { &self.tokens[self.current - 1] } - fn consume(&mut self, kind: &TokenKind, err: ErrorKind) -> Result<Token, Error> { + fn consume( + &mut self, + kind: &TokenKind, + err: ErrorKind, + ) -> Result<Token, Error> { if self.check_token(kind) { return Ok(self.advance()); } |