Update nom from 7.1.3 to 8.0.0

This commit is contained in:
Oliver Hamlet
2025-01-27 20:06:23 +00:00
parent 18150b76c1
commit 784af50540
4 changed files with 39 additions and 23 deletions
Generated
+11 -2
View File
@@ -229,7 +229,7 @@ checksum = "d5be744c54f80f535dc03a47c6a12c5116525edfa8a1365f13e91c42a0ad4d55"
dependencies = [
"encoding_rs",
"memchr",
"nom",
"nom 7.1.3",
"unicase",
]
@@ -326,7 +326,7 @@ dependencies = [
"crc32fast",
"criterion",
"esplugin",
"nom",
"nom 8.0.0",
"pelite",
"regex",
"tempfile",
@@ -369,6 +369,15 @@ dependencies = [
"minimal-lexical",
]
[[package]]
name = "nom"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]]
name = "num-traits"
version = "0.2.18"
+1 -1
View File
@@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
crc32fast = "1.4.2"
esplugin = "6.1.1"
nom = "7.0.0"
nom = "8.0.0"
pelite = "0.10.0"
regex = "1.11.1"
unicase = "2.8.1"
+17 -13
View File
@@ -5,8 +5,8 @@ use nom::branch::alt;
use nom::bytes::complete::{is_not, tag};
use nom::character::complete::hex_digit1;
use nom::combinator::{map, map_parser, value};
use nom::sequence::{delimited, tuple};
use nom::{Err, IResult};
use nom::sequence::delimited;
use nom::{Err, IResult, Parser};
use regex::{Regex, RegexBuilder};
use super::{ComparisonOperator, Function};
@@ -22,7 +22,8 @@ impl ComparisonOperator {
value(ComparisonOperator::GreaterThanOrEqual, tag(">=")),
value(ComparisonOperator::LessThan, tag("<")),
value(ComparisonOperator::GreaterThan, tag(">")),
))(input)
))
.parse(input)
}
}
@@ -60,7 +61,8 @@ fn parse_path(input: &str) -> IResult<&str, PathBuf> {
map(
delimited(tag("\""), is_not(INVALID_PATH_CHARS), tag("\"")),
PathBuf::from,
)(input)
)
.parse(input)
}
fn parse_version_args(input: &str) -> ParsingResult<(PathBuf, String, ComparisonOperator)> {
@@ -69,15 +71,15 @@ fn parse_version_args(input: &str) -> ParsingResult<(PathBuf, String, Comparison
|version: &str| version.to_string(),
);
let parser = tuple((
let parser = (
parse_path,
whitespace(tag(",")),
version_parser,
whitespace(tag(",")),
ComparisonOperator::parse,
));
);
let (remaining_input, (path, _, version, _, comparator)) = map_err(parser)(input)?;
let (remaining_input, (path, _, version, _, comparator)) = map_err(parser).parse(input)?;
if is_in_game_path(&path) {
Ok((remaining_input, (path, version, comparator)))
@@ -93,13 +95,13 @@ fn parse_crc(input: &str) -> ParsingResult<u32> {
}
fn parse_checksum_args(input: &str) -> ParsingResult<(PathBuf, u32)> {
let mut parser = tuple((
let mut parser = (
map_err(parse_path),
map_err(whitespace(tag(","))),
map_parser(hex_digit1, parse_crc),
));
);
let (remaining_input, (path, _, crc)) = parser(input)?;
let (remaining_input, (path, _, crc)) = parser.parse(input)?;
if is_in_game_path(&path) {
Ok((remaining_input, (path, crc)))
@@ -111,7 +113,8 @@ fn parse_checksum_args(input: &str) -> ParsingResult<(PathBuf, u32)> {
fn parse_non_regex_path(input: &str) -> ParsingResult<PathBuf> {
let (remaining_input, path) = map(is_not(INVALID_NON_REGEX_PATH_CHARS), |path: &str| {
PathBuf::from(path)
})(input)?;
})
.parse(input)?;
if is_in_game_path(&path) {
Ok((remaining_input, path))
@@ -148,7 +151,7 @@ fn parse_regex_path(input: &str) -> ParsingResult<(PathBuf, Regex)> {
}
fn parse_regex_filename(input: &str) -> ParsingResult<Regex> {
map_parser(is_not(INVALID_REGEX_PATH_CHARS), parse_regex)(input)
map_parser(is_not(INVALID_REGEX_PATH_CHARS), parse_regex).parse(input)
}
impl Function {
@@ -242,7 +245,8 @@ impl Function {
),
|(path, crc)| Function::Checksum(path, crc),
),
))(input)
))
.parse(input)
}
}
+10 -7
View File
@@ -14,7 +14,7 @@ use nom::character::complete::space0;
use nom::combinator::map;
use nom::multi::separated_list0;
use nom::sequence::{delimited, preceded};
use nom::IResult;
use nom::{IResult, Parser};
use error::ParsingError;
pub use error::{Error, MoreDataNeeded, ParsingErrorKind};
@@ -171,7 +171,8 @@ fn parse_expression(input: &str) -> ParsingResult<Expression> {
map(
separated_list0(map_err(whitespace(tag("or"))), CompoundCondition::parse),
Expression,
)(input)
)
.parse(input)
}
impl fmt::Display for Expression {
@@ -199,7 +200,8 @@ impl CompoundCondition {
map(
separated_list0(map_err(whitespace(tag("and"))), Condition::parse),
CompoundCondition,
)(input)
)
.parse(input)
}
}
@@ -251,7 +253,8 @@ impl Condition {
),
Condition::InvertedExpression,
),
))(input)
))
.parse(input)
}
}
@@ -268,14 +271,14 @@ impl fmt::Display for Condition {
}
fn map_err<'a, O>(
mut parser: impl FnMut(&'a str) -> IResult<&'a str, O, nom::error::Error<&'a str>>,
mut parser: impl Parser<&'a str, Output = O, Error = nom::error::Error<&'a str>>,
) -> impl FnMut(&'a str) -> ParsingResult<'a, O> {
move |i| parser(i).map_err(nom::Err::convert)
move |i| parser.parse(i).map_err(nom::Err::convert)
}
fn whitespace<'a, O>(
parser: impl Fn(&'a str) -> IResult<&'a str, O>,
) -> impl FnMut(&'a str) -> IResult<&'a str, O> {
) -> impl Parser<&'a str, Output = O, Error = nom::error::Error<&'a str>> {
delimited(space0, parser, space0)
}