mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-10 16:06:22 +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
|
/// Parse an expression prefix
|
||||||
pub fn parse_prefix(&mut self) -> Result<ASTNode, ParserError> {
|
pub fn parse_prefix(&mut self) -> Result<ASTNode, ParserError> {
|
||||||
match self.next_token() {
|
let tok = self
|
||||||
Some(t) => match t {
|
.next_token()
|
||||||
|
.ok_or_else(|| ParserError::ParserError("Unexpected EOF".to_string()))?;
|
||||||
|
match tok {
|
||||||
Token::SQLWord(w) => match w.keyword.as_ref() {
|
Token::SQLWord(w) => match w.keyword.as_ref() {
|
||||||
"TRUE" | "FALSE" | "NULL" => {
|
"TRUE" | "FALSE" | "NULL" => {
|
||||||
self.prev_token();
|
self.prev_token();
|
||||||
|
@ -185,10 +187,8 @@ impl Parser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unexpected => {
|
unexpected => {
|
||||||
return self.expected(
|
return self
|
||||||
"an identifier or a '*' after '.'",
|
.expected("an identifier or a '*' after '.'", unexpected);
|
||||||
unexpected,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,9 +217,7 @@ impl Parser {
|
||||||
expr: Box::new(self.parse_subexpr(p)?),
|
expr: Box::new(self.parse_subexpr(p)?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Token::Number(_)
|
Token::Number(_) | Token::SingleQuotedString(_) | Token::NationalStringLiteral(_) => {
|
||||||
| Token::SingleQuotedString(_)
|
|
||||||
| Token::NationalStringLiteral(_) => {
|
|
||||||
self.prev_token();
|
self.prev_token();
|
||||||
self.parse_sql_value()
|
self.parse_sql_value()
|
||||||
}
|
}
|
||||||
|
@ -233,9 +231,7 @@ impl Parser {
|
||||||
self.expect_token(&Token::RParen)?;
|
self.expect_token(&Token::RParen)?;
|
||||||
Ok(expr)
|
Ok(expr)
|
||||||
}
|
}
|
||||||
_ => self.expected("an expression", Some(t)),
|
unexpected => self.expected("an expression", Some(unexpected)),
|
||||||
},
|
|
||||||
None => parser_err!("Prefix parser expected a keyword but hit EOF"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue