(
context: &mut ParserContext,
env: &mut Environment,
tokens: &[Token],
position: &mut usize,
)
| 1397 | } |
| 1398 | |
| 1399 | pub(crate) fn parse_is_null_expression( |
| 1400 | context: &mut ParserContext, |
| 1401 | env: &mut Environment, |
| 1402 | tokens: &[Token], |
| 1403 | position: &mut usize, |
| 1404 | ) -> Result<Box<dyn Expr>, Box<Diagnostic>> { |
| 1405 | let expression = parse_in_expression(context, env, tokens, position)?; |
| 1406 | if is_current_token(tokens, position, TokenKind::Is) { |
| 1407 | let is_location = tokens[*position].location; |
| 1408 | |
| 1409 | // Consume `IS` keyword |
| 1410 | *position += 1; |
| 1411 | |
| 1412 | let has_not_keyword = if is_current_token(tokens, position, TokenKind::Not) { |
| 1413 | // Consume `NOT` keyword |
| 1414 | *position += 1; |
| 1415 | true |
| 1416 | } else { |
| 1417 | false |
| 1418 | }; |
| 1419 | |
| 1420 | if is_current_token(tokens, position, TokenKind::Null) { |
| 1421 | // Consume `Null` keyword |
| 1422 | *position += 1; |
| 1423 | |
| 1424 | return Ok(Box::new(IsNullExpr { |
| 1425 | argument: expression, |
| 1426 | has_not: has_not_keyword, |
| 1427 | })); |
| 1428 | } |
| 1429 | |
| 1430 | return Err( |
| 1431 | Diagnostic::error("Expects `NULL` Keyword after `IS` or `IS NOT`") |
| 1432 | .with_location(is_location) |
| 1433 | .as_boxed(), |
| 1434 | ); |
| 1435 | } |
| 1436 | Ok(expression) |
| 1437 | } |
| 1438 | |
| 1439 | fn parse_in_expression( |
| 1440 | context: &mut ParserContext, |
no test coverage detected
searching dependent graphs…