mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-08 23:20:34 +00:00
Reduce indentation in parse_prefix()
This commit is contained in:
parent
f82dc74e38
commit
e7949d493c
1 changed files with 73 additions and 77 deletions
|
@ -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)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue