diff --git a/Cargo.toml b/Cargo.toml index 923867a..a35aabc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ default-features = false features = ["clock", "std", "wasmbind"] [dependencies.nom] -version = "7" +version = "8.0.0-alpha2" optional = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies.uuid] diff --git a/src/parser/components.rs b/src/parser/components.rs index f985068..4997953 100644 --- a/src/parser/components.rs +++ b/src/parser/components.rs @@ -245,7 +245,7 @@ pub fn read_component(input: &str) -> Result, String> { pub fn component<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Component, E> { - let (input, name) = line("BEGIN:", valid_key_sequence_cow)(input)?; + let (input, name) = line("BEGIN:", valid_key_sequence_cow).parse(input)?; let (input, (properties, components)) = many_till( cut(context( @@ -270,7 +270,7 @@ pub fn component<'a, E: ParseError<&'a str> + ContextError<&'a str>>( }) .parse(input)?; - let (input, _) = many0(tag("\n"))(input)?; + let (input, _) = many0(tag("\n")).parse(input)?; Ok(( input, @@ -513,5 +513,5 @@ fn test_faulty_component() { pub fn components<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Vec, E> { - complete(many0(all_consuming(component)))(input) + complete(many0(all_consuming(component))).parse(input) } diff --git a/src/parser/parameters.rs b/src/parser/parameters.rs index 423e305..d55e8e6 100644 --- a/src/parser/parameters.rs +++ b/src/parser/parameters.rs @@ -5,7 +5,7 @@ use nom::{ combinator::{eof, opt}, error::{convert_error, ContextError, ParseError, VerboseError}, multi::many0, - sequence::{delimited, preceded, separated_pair, tuple}, + sequence::{delimited, preceded, separated_pair}, Finish, IResult, Parser, }; @@ -130,14 +130,14 @@ fn remove_empty_string_parsed(input: Option>) -> Option + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Parameter<'a>, E> { - alt((pair_parameter, base_parameter))(input) + alt((pair_parameter, base_parameter)).parse(input) } fn pair_parameter<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Parameter<'a>, E> { preceded( - tuple((tag(";"), space0)), + (tag(";"), space0), separated_pair( valid_key_sequence_cow, //key tag("="), @@ -159,9 +159,9 @@ fn pair_parameter<'a, E: ParseError<&'a str> + ContextError<&'a str>>( fn base_parameter<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Parameter<'a>, E> { - tuple(( + ( preceded( - tuple((tag(";"), space0)), + (tag(";"), space0), valid_key_sequence_cow, //key ), opt(preceded( @@ -174,9 +174,9 @@ fn base_parameter<'a, E: ParseError<&'a str> + ContextError<&'a str>>( .map(ParseString::from), )) .map(remove_empty_string_parsed), - )) - .map(|(key, val)| Parameter { key, val }) - .parse(input) + ) + .map(|(key, val)| Parameter { key, val }) + .parse(input) } // parameter list @@ -215,5 +215,5 @@ pub fn parse_parameter_list() { pub fn parameters<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, Vec, E> { - many0(parameter)(input) + many0(parameter).parse(input) } diff --git a/src/parser/properties.rs b/src/parser/properties.rs index 4bc0bcd..5730601 100644 --- a/src/parser/properties.rs +++ b/src/parser/properties.rs @@ -16,7 +16,7 @@ use nom::{ character::complete::{line_ending, multispace0}, combinator::{cut, opt}, error::{context, convert_error, ContextError, ParseError, VerboseError}, - sequence::{preceded, separated_pair, tuple}, + sequence::{preceded, separated_pair}, Finish, IResult, Parser, }; @@ -371,10 +371,10 @@ pub fn property<'a, E: ParseError<&'a str> + ContextError<&'a str>>( ) -> IResult<&'a str, Property, E> { context( "property", - cut(tuple(( + cut(( alt(( separated_pair( - tuple(( + ( // preceded(multispace0, alpha_or_dash), // key cut(context( // this must be interpreted as component by `component()` @@ -383,7 +383,7 @@ pub fn property<'a, E: ParseError<&'a str> + ContextError<&'a str>>( preceded(multispace0, property_key).map(ParseString::from), )), // key parameters, // params - )), + ), context("property separator", tag(":")), // separator context( "property value", @@ -411,7 +411,7 @@ pub fn property<'a, E: ParseError<&'a str> + ContextError<&'a str>>( }; Property { name, val, params } - })), + }), ) .parse(input) } diff --git a/src/parser/utils.rs b/src/parser/utils.rs index c019fbf..570e035 100644 --- a/src/parser/utils.rs +++ b/src/parser/utils.rs @@ -45,16 +45,16 @@ pub fn valid_key_sequence_cow<'a, E: ParseError<&'a str> + ContextError<&'a str> .parse(input) } -pub fn line<'a, O, E: ParseError<&'a str>, F: Parser<&'a str, O, E>>( +pub fn line<'a, O, E: ParseError<&'a str>, F: Parser<&'a str, Output = O, Error = E>>( prefix: &'a str, f: F, -) -> impl FnMut(&'a str) -> IResult<&'a str, O, E> { +) -> impl Parser<&'a str, Output = O, Error = E> { line_separated(complete(preceded(tag_no_case(prefix), f))) } -pub fn line_separated<'a, O, E: ParseError<&'a str>, F: Parser<&'a str, O, E>>( +pub fn line_separated<'a, O, E: ParseError<&'a str>, F: Parser<&'a str, Output = O, Error = E>>( f: F, -) -> impl FnMut(&'a str) -> IResult<&'a str, O, E> { +) -> impl Parser<&'a str, Output = O, Error = E> { delimited(many0(line_ending), f, many0(line_ending)) }