cleaner match and returning

This commit is contained in:
mos 2024-07-28 09:50:12 +02:00
parent 2531b4ac0d
commit 32d068649c
1 changed files with 4 additions and 6 deletions

View File

@ -221,11 +221,11 @@ impl<'a> Parser<'a> {
match *self.peek()? {
Symbol::Eq => {
self.next();
return Ok(Node::new(NodeOp::Assign, vec![lhs, self.parse_expr()?]));
Ok(Node::new(NodeOp::Assign, vec![lhs, self.parse_expr()?]))
}
Symbol::Term => {
self.next();
return Ok(lhs);
Ok(lhs)
}
Symbol::Id(_) | Symbol::Int(_) => {
loop {
@ -238,12 +238,10 @@ impl<'a> Parser<'a> {
}
self.expect(Symbol::Term, ParseError::ExpectedTerm)?;
self.next();
return Ok(lhs);
Ok(lhs)
}
_ => (),
_ => Err(ParseError::Eof),
}
Err(ParseError::Eof)
}
pub fn parse(&mut self) -> ParseResult<Vec<Node>> {