Remove parse_expr_list, as it's now trivial

This commit is contained in:
Nickolay Ponomarev 2019-07-07 04:20:14 +03:00
parent 03efcf6fa6
commit 9314371d3b

View file

@ -285,7 +285,7 @@ impl Parser {
self.expect_token(&Token::LParen)?; self.expect_token(&Token::LParen)?;
let partition_by = if self.parse_keywords(vec!["PARTITION", "BY"]) { let partition_by = if self.parse_keywords(vec!["PARTITION", "BY"]) {
// a list of possibly-qualified column names // a list of possibly-qualified column names
self.parse_expr_list()? self.parse_comma_separated(Parser::parse_expr)?
} else { } else {
vec![] vec![]
}; };
@ -597,7 +597,7 @@ impl Parser {
} else { } else {
Expr::InList { Expr::InList {
expr: Box::new(expr), expr: Box::new(expr),
list: self.parse_expr_list()?, list: self.parse_comma_separated(Parser::parse_expr)?,
negated, negated,
} }
}; };
@ -1568,7 +1568,7 @@ impl Parser {
}; };
let group_by = if self.parse_keywords(vec!["GROUP", "BY"]) { let group_by = if self.parse_keywords(vec!["GROUP", "BY"]) {
self.parse_expr_list()? self.parse_comma_separated(Parser::parse_expr)?
} else { } else {
vec![] vec![]
}; };
@ -1734,7 +1734,7 @@ impl Parser {
let mut with_hints = vec![]; let mut with_hints = vec![];
if self.parse_keyword("WITH") { if self.parse_keyword("WITH") {
if self.consume_token(&Token::LParen) { if self.consume_token(&Token::LParen) {
with_hints = self.parse_expr_list()?; with_hints = self.parse_comma_separated(Parser::parse_expr)?;
self.expect_token(&Token::RParen)?; self.expect_token(&Token::RParen)?;
} else { } else {
// rewind, as WITH may belong to the next statement's CTE // rewind, as WITH may belong to the next statement's CTE
@ -1818,16 +1818,11 @@ impl Parser {
Ok(Assignment { id, value }) Ok(Assignment { id, value })
} }
/// Parse a comma-delimited list of SQL expressions
pub fn parse_expr_list(&mut self) -> Result<Vec<Expr>, ParserError> {
Ok(self.parse_comma_separated(Parser::parse_expr)?)
}
pub fn parse_optional_args(&mut self) -> Result<Vec<Expr>, ParserError> { pub fn parse_optional_args(&mut self) -> Result<Vec<Expr>, ParserError> {
if self.consume_token(&Token::RParen) { if self.consume_token(&Token::RParen) {
Ok(vec![]) Ok(vec![])
} else { } else {
let args = self.parse_expr_list()?; let args = self.parse_comma_separated(Parser::parse_expr)?;
self.expect_token(&Token::RParen)?; self.expect_token(&Token::RParen)?;
Ok(args) Ok(args)
} }
@ -1911,9 +1906,9 @@ impl Parser {
pub fn parse_values(&mut self) -> Result<Values, ParserError> { pub fn parse_values(&mut self) -> Result<Values, ParserError> {
let values = self.parse_comma_separated(|parser| { let values = self.parse_comma_separated(|parser| {
parser.expect_token(&Token::LParen)?; parser.expect_token(&Token::LParen)?;
let e = parser.parse_expr_list()?; let exprs = parser.parse_comma_separated(Parser::parse_expr)?;
parser.expect_token(&Token::RParen)?; parser.expect_token(&Token::RParen)?;
Ok(e) Ok(exprs)
})?; })?;
Ok(Values(values)) Ok(Values(values))
} }