fn expr_substring_from_pairs(&mut self, pairs: Pairs<'_, Rule>) -> Result<Expr, S<Error>> {
        use functions::string::{Substring, Unit};

        let mut function = &Substring(Unit::Characters);
        let mut input = S::default();
        let mut from = None;
        let mut length = None;

        for pair in pairs {
            let rule = pair.as_rule();
            match rule {
                Rule::kw_substring | Rule::kw_from | Rule::kw_for | Rule::kw_using => {}
                Rule::kw_octets => function = &Substring(Unit::Octets),
                Rule::kw_characters => function = &Substring(Unit::Characters),
                Rule::substring_input | Rule::substring_from | Rule::substring_for => {
                    let span = pair.as_span();
                    let expr = self.expr_group_from_pairs(pair.into_inner())?.span(self.register(span));
                    match rule {
                        Rule::substring_input => input = expr,
                        Rule::substring_from => from = Some(expr),
                        Rule::substring_for => length = Some(expr),
                        _ => unreachable!(),
                    }
                }
                r => unreachable!("Unexpected rule {:?}", r),
            }
        }

        let mut args = vec![
            input,
            from.unwrap_or_else(|| Expr::Value(1.into()).span(Span::default())),
        ];
        if let Some(length) = length {
            args.push(length);
        }
        Ok(Expr::Function { function, args })
    }
/// Creates a `substring` function expression.
Creates a `substring` function expression.
Creates a ` substring ` function expression .
fn expr_substring_from_pairs(&mut self, pairs: Pairs<'_, Rule>) -> Result<Expr, S<Error>> {
        use functions::string::{Substring, Unit};
        let mut function = &Substring(Unit::Characters);
        let mut input = S::default();
        let mut from = None;
        let mut length = None;
        for pair in pairs {
            let rule = pair.as_rule();
            match rule {
                Rule::kw_substring | Rule::kw_from | Rule::kw_for | Rule::kw_using => {}
                Rule::kw_octets => function = &Substring(Unit::Octets),
                Rule::kw_characters => function = &Substring(Unit::Characters),
                Rule::substring_input | Rule::substring_from | Rule::substring_for => {
                    let span = pair.as_span();
                    let expr = self.expr_group_from_pairs(pair.into_inner())?.span(self.register(span));
                    match rule {
                        Rule::substring_input => input = expr,
                        Rule::substring_from => from = Some(expr),
                        Rule::substring_for => length = Some(expr),
                        _ => unreachable!(),
                    }
                }
                r => unreachable!("Unexpected rule {:?}", r),
            }
        }
        let mut args = vec![
            input,
            from.unwrap_or_else(|| Expr::Value(1.into()).span(Span::default())),
        ];
        if let Some(length) = length {
            args.push(length);
        }
        Ok(Expr::Function { function, args })
    }
fn expr_substring_from_pairs ( & mut self , pairs : Pairs < ' _ , Rule > ) -> Result < Expr , S < Error > > { use functions :: string :: { Substring , Unit } ; let mut function = & Substring ( Unit :: Characters ) ; let mut input = S :: default ( ) ; let mut from = None ; let mut length = None ; for pair in pairs { let rule = pair . as_rule ( ) ; match rule { Rule :: kw_substring | Rule :: kw_from | Rule :: kw_for | Rule :: kw_using => { } Rule :: kw_octets => function = & Substring ( Unit :: Octets ) , Rule :: kw_characters => function = & Substring ( Unit :: Characters ) , Rule :: substring_input | Rule :: substring_from | Rule :: substring_for => { let span = pair . as_span ( ) ; let expr = self . expr_group_from_pairs ( pair . into_inner ( ) ) ? . span ( self . register ( span ) ) ; match rule { Rule :: substring_input => input = expr , Rule :: substring_from => from = Some ( expr ) , Rule :: substring_for => length = Some ( expr ) , _ => unreachable ! ( ) , } } r => unreachable ! ( " " r ) , } } let mut args = vec ! [ input from unwrap_or_else ( Expr Value ( 1 into ( ) ) span ( Span default ( ) ) ) ] ; if let Some ( length ) = length { args . push ( length ) ; } Ok ( Expr :: Function { function , args } ) }
Creates a `substring` function expression.
Creates a ` substring ` function expression .
&mut self
pairs
Pairs<'_, Rule>
&mut self
pairs
Pairs<'_, Rule>