(
context: &mut ParserContext,
env: &mut Environment,
tokens: &[Token],
position: &mut usize,
)
| 1039 | } |
| 1040 | |
| 1041 | fn parse_group_by_statement( |
| 1042 | context: &mut ParserContext, |
| 1043 | env: &mut Environment, |
| 1044 | tokens: &[Token], |
| 1045 | position: &mut usize, |
| 1046 | ) -> Result<Statement, Box<Diagnostic>> { |
| 1047 | // Consume `Group` keyword |
| 1048 | *position += 1; |
| 1049 | |
| 1050 | // Consume `By` keyword |
| 1051 | consume_token_or_error( |
| 1052 | tokens, |
| 1053 | position, |
| 1054 | TokenKind::By, |
| 1055 | "Expect keyword `BY` after keyword `group`", |
| 1056 | )?; |
| 1057 | |
| 1058 | // Parse one or more expression |
| 1059 | let mut values: Vec<Box<dyn Expr>> = vec![]; |
| 1060 | while *position < tokens.len() { |
| 1061 | values.push(parse_expression(context, env, tokens, position)?); |
| 1062 | if is_current_token(tokens, position, TokenKind::Comma) { |
| 1063 | // Consume Comma `,` |
| 1064 | *position += 1; |
| 1065 | continue; |
| 1066 | } |
| 1067 | break; |
| 1068 | } |
| 1069 | |
| 1070 | let mut has_with_rollup = false; |
| 1071 | if is_current_token(tokens, position, TokenKind::With) { |
| 1072 | // Consume Comma `WITH`` |
| 1073 | *position += 1; |
| 1074 | |
| 1075 | // Consume `Rollup` keyword |
| 1076 | consume_token_or_error( |
| 1077 | tokens, |
| 1078 | position, |
| 1079 | TokenKind::Rollup, |
| 1080 | "Expect keyword `ROLLUP` after keyword `with`", |
| 1081 | )?; |
| 1082 | |
| 1083 | has_with_rollup = true; |
| 1084 | } |
| 1085 | |
| 1086 | context.has_group_by_statement = true; |
| 1087 | Ok(Statement::GroupBy(GroupByStatement { |
| 1088 | values, |
| 1089 | has_with_roll_up: has_with_rollup, |
| 1090 | })) |
| 1091 | } |
| 1092 | |
| 1093 | fn parse_having_statement( |
| 1094 | context: &mut ParserContext, |
no test coverage detected
searching dependent graphs…