Parse union operations with precedence
(tokens: &[Token])
| 3352 | |
| 3353 | // Parse union operations with precedence |
| 3354 | fn union_expr(tokens: &[Token]) -> IResult<&[Token], GraphExpression> { |
| 3355 | let (tokens, left) = primary_graph_expr(tokens)?; |
| 3356 | |
| 3357 | // Check for UNION operators |
| 3358 | let mut current = left; |
| 3359 | let mut remaining = tokens; |
| 3360 | |
| 3361 | while let Ok((tokens_after_union, _)) = expect_token(Token::Union)(remaining) { |
| 3362 | let (tokens_after_all, union_all) = opt(expect_token(Token::All))(tokens_after_union)?; |
| 3363 | let all = union_all.is_some(); |
| 3364 | let (tokens_after_right, right) = primary_graph_expr(tokens_after_all)?; |
| 3365 | |
| 3366 | current = GraphExpression::Union { |
| 3367 | left: Box::new(current), |
| 3368 | right: Box::new(right), |
| 3369 | all, |
| 3370 | }; |
| 3371 | remaining = tokens_after_right; |
| 3372 | } |
| 3373 | |
| 3374 | Ok((remaining, current)) |
| 3375 | } |
| 3376 | |
| 3377 | // Parse primary graph expressions (non-union) |
| 3378 | fn primary_graph_expr(tokens: &[Token]) -> IResult<&[Token], GraphExpression> { |
no test coverage detected