mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-24 18:10:56 -05:00
fix(varcon)!: Shift delimiter parsing out of Pos
BREAKING CHANGE: `Pos::parse` now parses `A` instead of `<A>`
This commit is contained in:
parent
855ac08da3
commit
a4494fe54f
1 changed files with 10 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use winnow::combinator::delimited;
|
||||||
use winnow::combinator::trace;
|
use winnow::combinator::trace;
|
||||||
use winnow::prelude::*;
|
use winnow::prelude::*;
|
||||||
|
|
||||||
|
@ -992,7 +993,7 @@ impl Entry {
|
||||||
fn parse_description(input: &mut &str) -> PResult<Self, ()> {
|
fn parse_description(input: &mut &str) -> PResult<Self, ()> {
|
||||||
trace("description", move |input: &mut &str| {
|
trace("description", move |input: &mut &str| {
|
||||||
let (pos, archaic, note, description) = (
|
let (pos, archaic, note, description) = (
|
||||||
winnow::combinator::opt((winnow::ascii::space1, Pos::parse_)),
|
winnow::combinator::opt((winnow::ascii::space1, delimited('<', Pos::parse_, '>'))),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "(-)")),
|
winnow::combinator::opt((winnow::ascii::space1, "(-)")),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "--")),
|
winnow::combinator::opt((winnow::ascii::space1, "--")),
|
||||||
winnow::combinator::opt((
|
winnow::combinator::opt((
|
||||||
|
@ -1767,10 +1768,10 @@ impl Pos {
|
||||||
fn parse_(input: &mut &str) -> PResult<Self, ()> {
|
fn parse_(input: &mut &str) -> PResult<Self, ()> {
|
||||||
trace("pos", move |input: &mut &str| {
|
trace("pos", move |input: &mut &str| {
|
||||||
winnow::combinator::alt((
|
winnow::combinator::alt((
|
||||||
"<N>".value(Pos::Noun),
|
"N".value(Pos::Noun),
|
||||||
"<V>".value(Pos::Verb),
|
"V".value(Pos::Verb),
|
||||||
"<Adj>".value(Pos::Adjective),
|
"Adj".value(Pos::Adjective),
|
||||||
"<Adv>".value(Pos::Adverb),
|
"Adv".value(Pos::Adverb),
|
||||||
))
|
))
|
||||||
.parse_next(input)
|
.parse_next(input)
|
||||||
})
|
})
|
||||||
|
@ -1788,8 +1789,8 @@ mod test_pos {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_valid() {
|
fn test_valid() {
|
||||||
let (input, actual) = Pos::parse_.parse_peek("<N>").unwrap();
|
let (input, actual) = Pos::parse_.parse_peek("N>").unwrap();
|
||||||
assert_data_eq!(input, str![]);
|
assert_data_eq!(input, str![">"]);
|
||||||
assert_data_eq!(
|
assert_data_eq!(
|
||||||
actual.to_debug(),
|
actual.to_debug(),
|
||||||
str![[r#"
|
str![[r#"
|
||||||
|
@ -1801,8 +1802,8 @@ Noun
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_extra() {
|
fn test_extra() {
|
||||||
let (input, actual) = Pos::parse_.parse_peek("<Adj> foobar").unwrap();
|
let (input, actual) = Pos::parse_.parse_peek("Adj> foobar").unwrap();
|
||||||
assert_data_eq!(input, str![" foobar"]);
|
assert_data_eq!(input, str!["> foobar"]);
|
||||||
assert_data_eq!(
|
assert_data_eq!(
|
||||||
actual.to_debug(),
|
actual.to_debug(),
|
||||||
str![[r#"
|
str![[r#"
|
||||||
|
|
Loading…
Reference in a new issue