cleaner match and returning
This commit is contained in:
parent
2531b4ac0d
commit
32d068649c
|
@ -221,11 +221,11 @@ impl<'a> Parser<'a> {
|
||||||
match *self.peek()? {
|
match *self.peek()? {
|
||||||
Symbol::Eq => {
|
Symbol::Eq => {
|
||||||
self.next();
|
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 => {
|
Symbol::Term => {
|
||||||
self.next();
|
self.next();
|
||||||
return Ok(lhs);
|
Ok(lhs)
|
||||||
}
|
}
|
||||||
Symbol::Id(_) | Symbol::Int(_) => {
|
Symbol::Id(_) | Symbol::Int(_) => {
|
||||||
loop {
|
loop {
|
||||||
|
@ -238,12 +238,10 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
self.expect(Symbol::Term, ParseError::ExpectedTerm)?;
|
self.expect(Symbol::Term, ParseError::ExpectedTerm)?;
|
||||||
self.next();
|
self.next();
|
||||||
return Ok(lhs);
|
Ok(lhs)
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => Err(ParseError::Eof),
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(ParseError::Eof)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(&mut self) -> ParseResult<Vec<Node>> {
|
pub fn parse(&mut self) -> ParseResult<Vec<Node>> {
|
||||||
|
|
Loading…
Reference in New Issue