Reduce indentation in parse_prefix()

This commit is contained in:
Nickolay Ponomarev 2019-04-27 18:38:12 +03:00
parent f82dc74e38
commit e7949d493c

View file

@ -155,8 +155,10 @@ impl Parser {
/// Parse an expression prefix
pub fn parse_prefix(&mut self) -> Result<ASTNode, ParserError> {
match self.next_token() {
Some(t) => match t {
let tok = self
.next_token()
.ok_or_else(|| ParserError::ParserError("Unexpected EOF".to_string()))?;
match tok {
Token::SQLWord(w) => match w.keyword.as_ref() {
"TRUE" | "FALSE" | "NULL" => {
self.prev_token();
@ -185,10 +187,8 @@ impl Parser {
break;
}
unexpected => {
return self.expected(
"an identifier or a '*' after '.'",
unexpected,
);
return self
.expected("an identifier or a '*' after '.'", unexpected);
}
}
}
@ -217,9 +217,7 @@ impl Parser {
expr: Box::new(self.parse_subexpr(p)?),
})
}
Token::Number(_)
| Token::SingleQuotedString(_)
| Token::NationalStringLiteral(_) => {
Token::Number(_) | Token::SingleQuotedString(_) | Token::NationalStringLiteral(_) => {
self.prev_token();
self.parse_sql_value()
}
@ -233,9 +231,7 @@ impl Parser {
self.expect_token(&Token::RParen)?;
Ok(expr)
}
_ => self.expected("an expression", Some(t)),
},
None => parser_err!("Prefix parser expected a keyword but hit EOF"),
unexpected => self.expected("an expression", Some(unexpected)),
}
}