(
context: &mut ParserContext,
env: &mut Environment,
tokens: &[Token],
position: &mut usize,
)
| 3284 | } |
| 3285 | |
| 3286 | fn parse_primary_expression( |
| 3287 | context: &mut ParserContext, |
| 3288 | env: &mut Environment, |
| 3289 | tokens: &[Token], |
| 3290 | position: &mut usize, |
| 3291 | ) -> Result<Box<dyn Expr>, Box<Diagnostic>> { |
| 3292 | if *position >= tokens.len() { |
| 3293 | return Err(un_expected_expression_error(tokens, position)); |
| 3294 | } |
| 3295 | |
| 3296 | match &tokens[*position].kind { |
| 3297 | TokenKind::Integer(value) => { |
| 3298 | *position += 1; |
| 3299 | Ok(Box::new(NumberExpr::int(*value))) |
| 3300 | } |
| 3301 | TokenKind::Float(value) => { |
| 3302 | *position += 1; |
| 3303 | Ok(Box::new(NumberExpr::float(*value))) |
| 3304 | } |
| 3305 | TokenKind::Infinity => parse_float_infinity_or_nan_expression(tokens, position), |
| 3306 | TokenKind::NaN => parse_float_infinity_or_nan_expression(tokens, position), |
| 3307 | TokenKind::Symbol(_) => parse_symbol_expression(context, env, tokens, position), |
| 3308 | TokenKind::Array => parse_array_value_expression(context, env, tokens, position), |
| 3309 | TokenKind::LeftBracket => parse_array_value_expression(context, env, tokens, position), |
| 3310 | TokenKind::LeftParen => { |
| 3311 | parse_column_or_row_expression(context, env, tokens, position, false) |
| 3312 | } |
| 3313 | TokenKind::Row => parse_column_or_row_expression(context, env, tokens, position, true), |
| 3314 | TokenKind::Case => parse_case_expression(context, env, tokens, position), |
| 3315 | TokenKind::Cast => parse_cast_call_expression(context, env, tokens, position), |
| 3316 | TokenKind::Benchmark => parse_benchmark_call_expression(context, env, tokens, position), |
| 3317 | TokenKind::GlobalVariable(_) => parse_global_variable_expression(env, tokens, position), |
| 3318 | TokenKind::Interval => parse_interval_expression(tokens, position), |
| 3319 | TokenKind::String(str) => { |
| 3320 | *position += 1; |
| 3321 | let value = str.to_string(); |
| 3322 | Ok(Box::new(StringExpr { value })) |
| 3323 | } |
| 3324 | TokenKind::True => { |
| 3325 | *position += 1; |
| 3326 | Ok(Box::new(BooleanExpr { is_true: true })) |
| 3327 | } |
| 3328 | TokenKind::False => { |
| 3329 | *position += 1; |
| 3330 | Ok(Box::new(BooleanExpr { is_true: false })) |
| 3331 | } |
| 3332 | TokenKind::Null => { |
| 3333 | *position += 1; |
| 3334 | Ok(Box::new(NullExpr {})) |
| 3335 | } |
| 3336 | _ => Err(un_expected_expression_error(tokens, position)), |
| 3337 | } |
| 3338 | } |
| 3339 | |
| 3340 | fn parse_float_infinity_or_nan_expression( |
| 3341 | tokens: &[Token], |
no test coverage detected
searching dependent graphs…