(
context: &mut ParserContext,
env: &mut Environment,
tokens: &[Token],
position: &mut usize,
has_row_keyword: bool,
)
| 3511 | } |
| 3512 | |
| 3513 | fn parse_column_or_row_expression( |
| 3514 | context: &mut ParserContext, |
| 3515 | env: &mut Environment, |
| 3516 | tokens: &[Token], |
| 3517 | position: &mut usize, |
| 3518 | has_row_keyword: bool, |
| 3519 | ) -> Result<Box<dyn Expr>, Box<Diagnostic>> { |
| 3520 | // Consume 'row' keyword if present |
| 3521 | if has_row_keyword { |
| 3522 | *position += 1; |
| 3523 | } |
| 3524 | |
| 3525 | let exprs = parse_zero_or_more_values_with_comma_between( |
| 3526 | context, |
| 3527 | env, |
| 3528 | tokens, |
| 3529 | position, |
| 3530 | "Column or Row", |
| 3531 | )?; |
| 3532 | |
| 3533 | if exprs.is_empty() { |
| 3534 | return Err(Diagnostic::error("Column or Row expression can't be empty") |
| 3535 | .with_location(calculate_safe_location(tokens, *position)) |
| 3536 | .as_boxed()); |
| 3537 | } |
| 3538 | |
| 3539 | if has_row_keyword || exprs.len() > 1 { |
| 3540 | let mut column_types = Vec::with_capacity(exprs.len()); |
| 3541 | for expr in exprs.iter() { |
| 3542 | column_types.push(expr.expr_type()); |
| 3543 | } |
| 3544 | let row_type = RowType::new(column_types); |
| 3545 | Ok(Box::new(RowExpr { exprs, row_type })) |
| 3546 | } else { |
| 3547 | let expr = exprs[0].clone(); |
| 3548 | Ok(Box::new(ColumnExpr { expr })) |
| 3549 | } |
| 3550 | } |
| 3551 | |
| 3552 | fn parse_case_expression( |
| 3553 | context: &mut ParserContext, |
no test coverage detected
searching dependent graphs…