mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 02:20:58 -05:00
chore: Update winnow
This commit is contained in:
parent
08f154e45b
commit
243b4efc9e
5 changed files with 45 additions and 27 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -1612,7 +1612,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
"winnow 0.3.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1650,7 +1650,7 @@ dependencies = [
|
|||
"thiserror",
|
||||
"unicode-segmentation",
|
||||
"unicode-xid",
|
||||
"winnow",
|
||||
"winnow 0.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1833,7 +1833,7 @@ name = "varcon-core"
|
|||
version = "2.2.9"
|
||||
dependencies = [
|
||||
"enumflags2",
|
||||
"winnow",
|
||||
"winnow 0.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2057,9 +2057,18 @@ checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.3.3"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658"
|
||||
checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "deac0939bd6e4f24ab5919fbf751c97a8cfc8543bb083a305ed5c0c10bb241d1"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
|
@ -14,7 +14,7 @@ include.workspace = true
|
|||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
winnow = "0.3.3"
|
||||
winnow = "0.4.0"
|
||||
unicode-xid = "0.2.4"
|
||||
once_cell = "1.17.1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -142,7 +142,7 @@ mod parser {
|
|||
<T as Stream>::Slice: AsBStr + SliceLen + Default,
|
||||
<T as Stream>::Token: AsChar + Copy,
|
||||
{
|
||||
preceded(ignore, identifier)(input)
|
||||
preceded(ignore, identifier).parse_next(input)
|
||||
}
|
||||
|
||||
fn identifier<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -155,7 +155,7 @@ mod parser {
|
|||
// `{XID_Continue}+` because XID_Continue is a superset of XID_Start and rather catch odd
|
||||
// or unexpected cases than strip off start characters to a word since we aren't doing a
|
||||
// proper word boundary parse
|
||||
take_while1(is_xid_continue)(input)
|
||||
take_while1(is_xid_continue).parse_next(input)
|
||||
}
|
||||
|
||||
fn ignore<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -180,7 +180,8 @@ mod parser {
|
|||
c_escape,
|
||||
printf,
|
||||
other,
|
||||
)))(input)
|
||||
)))
|
||||
.parse_next(input)
|
||||
}
|
||||
|
||||
fn sep1<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -192,7 +193,8 @@ mod parser {
|
|||
alt((
|
||||
one_of(|c| !is_xid_continue(c)).recognize(),
|
||||
eof.map(|_| <T as Stream>::Slice::default()),
|
||||
))(input)
|
||||
))
|
||||
.parse_next(input)
|
||||
}
|
||||
|
||||
fn other<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -234,7 +236,7 @@ mod parser {
|
|||
<T as Stream>::Slice: AsBStr + SliceLen + Default,
|
||||
<T as Stream>::Token: AsChar + Copy,
|
||||
{
|
||||
take_while1(is_dec_digit_with_sep)(input)
|
||||
take_while1(is_dec_digit_with_sep).parse_next(input)
|
||||
}
|
||||
|
||||
fn hex_literal<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -243,7 +245,7 @@ mod parser {
|
|||
<T as Stream>::Slice: AsBStr + SliceLen + Default,
|
||||
<T as Stream>::Token: AsChar + Copy,
|
||||
{
|
||||
preceded(('0', alt(('x', 'X'))), take_while1(is_hex_digit_with_sep))(input)
|
||||
preceded(('0', alt(('x', 'X'))), take_while1(is_hex_digit_with_sep)).parse_next(input)
|
||||
}
|
||||
|
||||
fn css_color<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -258,7 +260,8 @@ mod parser {
|
|||
terminated(take_while_m_n(3, 8, is_lower_hex_digit), peek(sep1)),
|
||||
terminated(take_while_m_n(3, 8, is_upper_hex_digit), peek(sep1)),
|
||||
)),
|
||||
)(input)
|
||||
)
|
||||
.parse_next(input)
|
||||
}
|
||||
|
||||
fn uuid_literal<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -315,7 +318,8 @@ mod parser {
|
|||
alt((
|
||||
take_while_m_n(IGNORE_HEX_MIN, IGNORE_HEX_MAX, is_lower_hex_digit),
|
||||
take_while_m_n(IGNORE_HEX_MIN, IGNORE_HEX_MAX, is_upper_hex_digit),
|
||||
))(input)
|
||||
))
|
||||
.parse_next(input)
|
||||
}
|
||||
|
||||
fn base64_literal<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -324,7 +328,7 @@ mod parser {
|
|||
<T as Stream>::Slice: AsBStr + SliceLen + Default,
|
||||
<T as Stream>::Token: AsChar + Copy,
|
||||
{
|
||||
let (padding, captured) = take_while1(is_base64_digit)(input.clone())?;
|
||||
let (padding, captured) = take_while1(is_base64_digit).parse_next(input.clone())?;
|
||||
|
||||
const CHUNK: usize = 4;
|
||||
let padding_offset = input.offset_to(&padding);
|
||||
|
@ -341,11 +345,12 @@ mod parser {
|
|||
.all(|c| !['/', '+'].contains(&c.as_char()))
|
||||
{
|
||||
return Err(winnow::error::ErrMode::Backtrack(
|
||||
winnow::error::Error::new(input, winnow::error::ErrorKind::LengthValue),
|
||||
winnow::error::Error::new(input, winnow::error::ErrorKind::Slice),
|
||||
));
|
||||
}
|
||||
|
||||
let (after, _) = take_while_m_n(padding_len, padding_len, is_base64_padding)(padding)?;
|
||||
let (after, _) =
|
||||
take_while_m_n(padding_len, padding_len, is_base64_padding).parse_next(padding)?;
|
||||
|
||||
let after_offset = input.offset_to(&after);
|
||||
Ok(input.next_slice(after_offset))
|
||||
|
@ -416,7 +421,7 @@ mod parser {
|
|||
// regular string that does escaping. The escaped letter might be part of a word, or it
|
||||
// might not be. Rather than guess and be wrong part of the time and correct people's words
|
||||
// incorrectly, we opt for just not evaluating it at all.
|
||||
preceded(take_while1(is_escape), take_while0(is_xid_continue))(input)
|
||||
preceded(take_while1(is_escape), take_while0(is_xid_continue)).parse_next(input)
|
||||
}
|
||||
|
||||
fn printf<T>(input: T) -> IResult<T, <T as Stream>::Slice>
|
||||
|
@ -425,7 +430,7 @@ mod parser {
|
|||
<T as Stream>::Slice: AsBStr + SliceLen + Default,
|
||||
<T as Stream>::Token: AsChar + Copy,
|
||||
{
|
||||
preceded('%', take_while1(is_xid_continue))(input)
|
||||
preceded('%', take_while1(is_xid_continue)).parse_next(input)
|
||||
}
|
||||
|
||||
fn take_many0<I, E, F>(mut f: F) -> impl FnMut(I) -> IResult<I, <I as Stream>::Slice, E>
|
||||
|
|
|
@ -16,7 +16,7 @@ parser = ["winnow"]
|
|||
flags = ["enumflags2"]
|
||||
|
||||
[dependencies]
|
||||
winnow = { version = "0.3.3", optional = true }
|
||||
winnow = { version = "0.4.0", optional = true }
|
||||
enumflags2 = { version = "0.7", optional = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
@ -146,18 +146,20 @@ A B C: coloration's / B. Cv: colouration's
|
|||
impl Entry {
|
||||
pub fn parse(input: &str) -> IResult<&str, Self> {
|
||||
let var_sep = (winnow::character::space0, '/', winnow::character::space0);
|
||||
let (input, variants) = winnow::multi::separated1(Variant::parse, var_sep)(input)?;
|
||||
let (input, variants) =
|
||||
winnow::multi::separated1(Variant::parse, var_sep).parse_next(input)?;
|
||||
|
||||
let desc_sep = (winnow::character::space0, '|');
|
||||
let (input, description) =
|
||||
winnow::combinator::opt((desc_sep, Self::parse_description))(input)?;
|
||||
winnow::combinator::opt((desc_sep, Self::parse_description)).parse_next(input)?;
|
||||
|
||||
let comment_sep = (winnow::character::space0, '#');
|
||||
let (input, comment) = winnow::combinator::opt((
|
||||
comment_sep,
|
||||
winnow::character::space1,
|
||||
winnow::character::not_line_ending,
|
||||
))(input)?;
|
||||
))
|
||||
.parse_next(input)?;
|
||||
|
||||
let mut e = match description {
|
||||
Some((_, description)) => description,
|
||||
|
@ -298,7 +300,8 @@ impl Variant {
|
|||
pub fn parse(input: &str) -> IResult<&str, Self> {
|
||||
let types = winnow::multi::separated1(Type::parse, winnow::character::space1);
|
||||
let sep = (winnow::bytes::tag(":"), winnow::character::space0);
|
||||
let (input, (types, word)) = winnow::sequence::separated_pair(types, sep, word)(input)?;
|
||||
let (input, (types, word)) =
|
||||
winnow::sequence::separated_pair(types, sep, word).parse_next(input)?;
|
||||
let v = Self { types, word };
|
||||
Ok((input, v))
|
||||
}
|
||||
|
@ -380,8 +383,8 @@ mod test_variant {
|
|||
impl Type {
|
||||
pub fn parse(input: &str) -> IResult<&str, Type> {
|
||||
let (input, category) = Category::parse(input)?;
|
||||
let (input, tag) = winnow::combinator::opt(Tag::parse)(input)?;
|
||||
let (input, num) = winnow::combinator::opt(winnow::character::digit1)(input)?;
|
||||
let (input, tag) = winnow::combinator::opt(Tag::parse).parse_next(input)?;
|
||||
let (input, num) = winnow::combinator::opt(winnow::character::digit1).parse_next(input)?;
|
||||
let num = num.map(|s| s.parse().expect("parser ensured its a number"));
|
||||
let t = Type { category, tag, num };
|
||||
Ok((input, t))
|
||||
|
@ -517,7 +520,8 @@ impl Pos {
|
|||
verb.value(Pos::Verb),
|
||||
adjective.value(Pos::Adjective),
|
||||
adverb.value(Pos::Adverb),
|
||||
))(input)
|
||||
))
|
||||
.parse_next(input)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue