MCPcopy Create free account
hub / github.com/cloudflare/saffron / ors_expr

Function ors_expr

saffron/src/parse.rs:690–717  ·  view source on GitHub ↗

A parser that can parse a single value, a range of values, or a step expression

(f: F)

Source from the content-addressed store, hash-verified

688
689/// A parser that can parse a single value, a range of values, or a step expression
690fn ors_expr<E, F>(f: F) -> impl Fn(&str) -> IResult<&str, OrsExpr<E>>
691where
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
720fn tail_ors_exprs<'a, E, F>(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…