A parser that can parse a single value, a range of values, or a step expression
(f: F)
| 688 | |
| 689 | /// A parser that can parse a single value, a range of values, or a step expression |
| 690 | fn ors_expr<E, F>(f: F) -> impl Fn(&str) -> IResult<&str, OrsExpr<E>> |
| 691 | where |
| 692 | E: ExprValue + TryFrom<u8, Error = ValueOutOfRangeError> + Ord + Copy, |
| 693 | F: Fn(&str) -> IResult<&str, E>, |
| 694 | { |
| 695 | move |input: &str| { |
| 696 | let (input, value) = alt((&f, map(char('*'), |_| ExprValue::min())))(input)?; |
| 697 | match opt(alt((char('/'), char('-'))))(input)? { |
| 698 | (input, Some('/')) => map(step_digit::<E>(), |step| OrsExpr::Step { |
| 699 | start: value, |
| 700 | end: ExprValue::max(), |
| 701 | step, |
| 702 | })(input), |
| 703 | (input, Some('-')) => { |
| 704 | let (input, end) = f(input)?; |
| 705 | match opt(char('/'))(input)? { |
| 706 | (input, Some(_)) => map(step_digit::<E>(), |step| OrsExpr::Step { |
| 707 | start: value, |
| 708 | end, |
| 709 | step, |
| 710 | })(input), |
| 711 | (input, None) => Ok((input, OrsExpr::Range(value, end))), |
| 712 | } |
| 713 | } |
| 714 | (input, _) => Ok((input, OrsExpr::One(value))), |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | /// Consumes a set of trailing ORS expressions |
| 720 | fn tail_ors_exprs<'a, E, F>( |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…