summaryrefslogtreecommitdiffstats
path: root/build/rust/nom/lib.rs
blob: 2e851911134773119ab1499cb2ab4065a4296c77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Strict minimum to make glsl happy.
pub use nom::{branch, bytes, character, combinator, error, sequence, Err, IResult, ParseTo};

pub mod multi {
    use nom::multi::fold_many0 as nom_fold_many0;
    pub use nom::multi::{many0, many1, separated_list0};

    pub fn fold_many0<I, O, E, F, G, R>(
        f: F,
        init: R,
        g: G,
    ) -> impl FnMut(I) -> nom::IResult<I, R, E>
    where
        I: Clone + nom::InputLength,
        F: nom::Parser<I, O, E>,
        G: FnMut(R, O) -> R,
        E: nom::error::ParseError<I>,
        R: Clone,
    {
        nom_fold_many0(f, move || init.clone(), g)
    }
}