diff --git a/crates/toml_edit/src/parser/array.rs b/crates/toml_edit/src/parser/array.rs
index b96827a5..1fb6ea8b 100644
--- a/crates/toml_edit/src/parser/array.rs
+++ b/crates/toml_edit/src/parser/array.rs
@@ -12,7 +12,7 @@ use crate::parser::prelude::*;
// ;; Array
// array = array-open array-values array-close
-pub(crate) fn array<'i>(check: RecursionCheck) -> impl Parser, Array, ParserError<'i>> {
+pub(crate) fn array<'i>(check: RecursionCheck) -> impl Parser, Array, ContextError<'i>> {
move |input| {
delimited(
ARRAY_OPEN,
@@ -39,7 +39,7 @@ const ARRAY_SEP: u8 = b',';
// array-value / ws-comment-newline ]
pub(crate) fn array_values<'i>(
check: RecursionCheck,
-) -> impl Parser, Array, ParserError<'i>> {
+) -> impl Parser, Array, ContextError<'i>> {
move |input| {
let check = check.recursing(input)?;
(
@@ -67,7 +67,7 @@ pub(crate) fn array_values<'i>(
pub(crate) fn array_value<'i>(
check: RecursionCheck,
-) -> impl Parser, Value, ParserError<'i>> {
+) -> impl Parser, Value, ContextError<'i>> {
move |input| {
(
ws_comment_newline.span(),
diff --git a/crates/toml_edit/src/parser/datetime.rs b/crates/toml_edit/src/parser/datetime.rs
index 098d5b74..de882c1d 100644
--- a/crates/toml_edit/src/parser/datetime.rs
+++ b/crates/toml_edit/src/parser/datetime.rs
@@ -20,7 +20,7 @@ use winnow::token::take_while;
// local-date = full-date
// local-time = partial-time
// full-time = partial-time time-offset
-pub(crate) fn date_time(input: Input<'_>) -> IResult, Datetime, ParserError<'_>> {
+pub(crate) fn date_time(input: Input<'_>) -> IResult, Datetime, ContextError<'_>> {
alt((
(full_date, opt((time_delim, partial_time, opt(time_offset))))
.map(|(date, opt)| {
@@ -48,14 +48,14 @@ pub(crate) fn date_time(input: Input<'_>) -> IResult, Datetime, Parser
}
// full-date = date-fullyear "-" date-month "-" date-mday
-pub(crate) fn full_date(input: Input<'_>) -> IResult, Date, ParserError<'_>> {
+pub(crate) fn full_date(input: Input<'_>) -> IResult, Date, ContextError<'_>> {
(date_fullyear, b'-', cut_err((date_month, b'-', date_mday)))
.map(|(year, _, (month, _, day))| Date { year, month, day })
.parse_next(input)
}
// partial-time = time-hour ":" time-minute ":" time-second [time-secfrac]
-pub(crate) fn partial_time(input: Input<'_>) -> IResult, Time, ParserError<'_>> {
+pub(crate) fn partial_time(input: Input<'_>) -> IResult, Time, ContextError<'_>> {
(
time_hour,
b':',
@@ -72,7 +72,7 @@ pub(crate) fn partial_time(input: Input<'_>) -> IResult, Time, ParserE
// time-offset = "Z" / time-numoffset
// time-numoffset = ( "+" / "-" ) time-hour ":" time-minute
-pub(crate) fn time_offset(input: Input<'_>) -> IResult, Offset, ParserError<'_>> {
+pub(crate) fn time_offset(input: Input<'_>) -> IResult, Offset, ContextError<'_>> {
alt((
one_of((b'Z', b'z')).value(Offset::Z),
(
@@ -95,14 +95,14 @@ pub(crate) fn time_offset(input: Input<'_>) -> IResult, Offset, Parser
}
// date-fullyear = 4DIGIT
-pub(crate) fn date_fullyear(input: Input<'_>) -> IResult, u16, ParserError<'_>> {
+pub(crate) fn date_fullyear(input: Input<'_>) -> IResult, u16, ContextError<'_>> {
unsigned_digits::<4, 4>
.map(|s: &str| s.parse::().expect("4DIGIT should match u8"))
.parse_next(input)
}
// date-month = 2DIGIT ; 01-12
-pub(crate) fn date_month(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn date_month(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
unsigned_digits::<2, 2>
.try_map(|s: &str| {
let d = s.parse::().expect("2DIGIT should match u8");
@@ -116,7 +116,7 @@ pub(crate) fn date_month(input: Input<'_>) -> IResult, u8, ParserError
}
// date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year
-pub(crate) fn date_mday(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn date_mday(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
unsigned_digits::<2, 2>
.try_map(|s: &str| {
let d = s.parse::().expect("2DIGIT should match u8");
@@ -130,14 +130,14 @@ pub(crate) fn date_mday(input: Input<'_>) -> IResult, u8, ParserError<
}
// time-delim = "T" / %x20 ; T, t, or space
-pub(crate) fn time_delim(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn time_delim(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
one_of(TIME_DELIM).parse_next(input)
}
const TIME_DELIM: (u8, u8, u8) = (b'T', b't', b' ');
// time-hour = 2DIGIT ; 00-23
-pub(crate) fn time_hour(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn time_hour(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
unsigned_digits::<2, 2>
.try_map(|s: &str| {
let d = s.parse::().expect("2DIGIT should match u8");
@@ -151,7 +151,7 @@ pub(crate) fn time_hour(input: Input<'_>) -> IResult, u8, ParserError<
}
// time-minute = 2DIGIT ; 00-59
-pub(crate) fn time_minute(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn time_minute(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
unsigned_digits::<2, 2>
.try_map(|s: &str| {
let d = s.parse::().expect("2DIGIT should match u8");
@@ -165,7 +165,7 @@ pub(crate) fn time_minute(input: Input<'_>) -> IResult, u8, ParserErro
}
// time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules
-pub(crate) fn time_second(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn time_second(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
unsigned_digits::<2, 2>
.try_map(|s: &str| {
let d = s.parse::().expect("2DIGIT should match u8");
@@ -179,7 +179,7 @@ pub(crate) fn time_second(input: Input<'_>) -> IResult, u8, ParserErro
}
// time-secfrac = "." 1*DIGIT
-pub(crate) fn time_secfrac(input: Input<'_>) -> IResult, u32, ParserError<'_>> {
+pub(crate) fn time_secfrac(input: Input<'_>) -> IResult, u32, ContextError<'_>> {
static SCALE: [u32; 10] = [
0,
100_000_000,
@@ -216,7 +216,7 @@ pub(crate) fn time_secfrac(input: Input<'_>) -> IResult, u32, ParserEr
pub(crate) fn unsigned_digits(
input: Input<'_>,
-) -> IResult, &str, ParserError<'_>> {
+) -> IResult, &str, ContextError<'_>> {
take_while(MIN..=MAX, DIGIT)
.map(|b: &[u8]| unsafe { from_utf8_unchecked(b, "`is_ascii_digit` filters out on-ASCII") })
.parse_next(input)
diff --git a/crates/toml_edit/src/parser/document.rs b/crates/toml_edit/src/parser/document.rs
index 9bf72b27..f66082f6 100644
--- a/crates/toml_edit/src/parser/document.rs
+++ b/crates/toml_edit/src/parser/document.rs
@@ -30,7 +30,7 @@ use crate::RawString;
// ( ws keyval ws [ comment ] ) /
// ( ws table ws [ comment ] ) /
// ws )
-pub(crate) fn document(input: Input<'_>) -> IResult, Document, ParserError<'_>> {
+pub(crate) fn document(input: Input<'_>) -> IResult, Document, ContextError<'_>> {
let state = RefCell::new(ParseState::default());
let state_ref = &state;
@@ -57,7 +57,7 @@ pub(crate) fn document(input: Input<'_>) -> IResult, Document, ParserE
.into_document()
.map(|document| (i, document))
.map_err(|err| {
- winnow::error::ErrMode::Backtrack(ParserError::from_external_error(
+ winnow::error::ErrMode::Backtrack(ContextError::from_external_error(
i,
winnow::error::ErrorKind::Verify,
err,
@@ -67,7 +67,7 @@ pub(crate) fn document(input: Input<'_>) -> IResult, Document, ParserE
pub(crate) fn parse_comment<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
(comment, line_ending)
.span()
@@ -80,7 +80,7 @@ pub(crate) fn parse_comment<'s, 'i>(
pub(crate) fn parse_ws<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
ws.span()
.map(|span| state.borrow_mut().on_ws(span))
@@ -90,7 +90,7 @@ pub(crate) fn parse_ws<'s, 'i>(
pub(crate) fn parse_newline<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
newline
.span()
@@ -101,7 +101,7 @@ pub(crate) fn parse_newline<'s, 'i>(
pub(crate) fn keyval<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
parse_keyval
.try_map(|(p, kv)| state.borrow_mut().on_keyval(p, kv))
@@ -112,7 +112,7 @@ pub(crate) fn keyval<'s, 'i>(
// keyval = key keyval-sep val
pub(crate) fn parse_keyval(
input: Input<'_>,
-) -> IResult, (Vec, TableKeyValue), ParserError<'_>> {
+) -> IResult, (Vec, TableKeyValue), ContextError<'_>> {
(
key,
cut_err((
diff --git a/crates/toml_edit/src/parser/errors.rs b/crates/toml_edit/src/parser/errors.rs
index 7ed9d11e..4ba7565b 100644
--- a/crates/toml_edit/src/parser/errors.rs
+++ b/crates/toml_edit/src/parser/errors.rs
@@ -16,7 +16,7 @@ pub struct TomlError {
}
impl TomlError {
- pub(crate) fn new(error: ParserError<'_>, original: Input<'_>) -> Self {
+ pub(crate) fn new(error: ContextError<'_>, original: Input<'_>) -> Self {
use winnow::stream::Offset;
use winnow::stream::Stream;
@@ -147,13 +147,13 @@ impl StdError for TomlError {
}
#[derive(Debug)]
-pub(crate) struct ParserError<'b> {
+pub(crate) struct ContextError<'b> {
input: Input<'b>,
context: Vec,
cause: Option>,
}
-impl<'b> winnow::error::ParserError> for ParserError<'b> {
+impl<'b> winnow::error::ParserError> for ContextError<'b> {
fn from_error_kind(input: Input<'b>, _kind: winnow::error::ErrorKind) -> Self {
Self {
input,
@@ -171,7 +171,7 @@ impl<'b> winnow::error::ParserError> for ParserError<'b> {
}
}
-impl<'b> winnow::error::ParserError<&'b str> for ParserError<'b> {
+impl<'b> winnow::error::ParserError<&'b str> for ContextError<'b> {
fn from_error_kind(input: &'b str, _kind: winnow::error::ErrorKind) -> Self {
Self {
input: Input::new(BStr::new(input)),
@@ -189,7 +189,7 @@ impl<'b> winnow::error::ParserError<&'b str> for ParserError<'b> {
}
}
-impl<'b> winnow::error::AddContext, StrContext> for ParserError<'b> {
+impl<'b> winnow::error::AddContext, StrContext> for ContextError<'b> {
fn add_context(mut self, _input: Input<'b>, ctx: StrContext) -> Self {
self.context.push(ctx);
self
@@ -197,7 +197,7 @@ impl<'b> winnow::error::AddContext, StrContext> for ParserError<'b> {
}
impl<'b, E: std::error::Error + Send + Sync + 'static>
- winnow::error::FromExternalError, E> for ParserError<'b>
+ winnow::error::FromExternalError, E> for ContextError<'b>
{
fn from_external_error(input: Input<'b>, _kind: winnow::error::ErrorKind, e: E) -> Self {
Self {
@@ -209,7 +209,7 @@ impl<'b, E: std::error::Error + Send + Sync + 'static>
}
impl<'b, E: std::error::Error + Send + Sync + 'static> winnow::error::FromExternalError<&'b str, E>
- for ParserError<'b>
+ for ContextError<'b>
{
fn from_external_error(input: &'b str, _kind: winnow::error::ErrorKind, e: E) -> Self {
Self {
@@ -221,7 +221,7 @@ impl<'b, E: std::error::Error + Send + Sync + 'static> winnow::error::FromExtern
}
// For tests
-impl<'b> std::cmp::PartialEq for ParserError<'b> {
+impl<'b> std::cmp::PartialEq for ContextError<'b> {
fn eq(&self, other: &Self) -> bool {
self.input == other.input
&& self.context == other.context
@@ -230,7 +230,7 @@ impl<'b> std::cmp::PartialEq for ParserError<'b> {
}
}
-impl<'a> std::fmt::Display for ParserError<'a> {
+impl<'a> std::fmt::Display for ContextError<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let expression = self.context.iter().find_map(|c| match c {
StrContext::Label(c) => Some(c),
diff --git a/crates/toml_edit/src/parser/inline_table.rs b/crates/toml_edit/src/parser/inline_table.rs
index 5429e39b..0c5de0ae 100644
--- a/crates/toml_edit/src/parser/inline_table.rs
+++ b/crates/toml_edit/src/parser/inline_table.rs
@@ -19,7 +19,7 @@ use indexmap::map::Entry;
// inline-table = inline-table-open inline-table-keyvals inline-table-close
pub(crate) fn inline_table<'i>(
check: RecursionCheck,
-) -> impl Parser, InlineTable, ParserError<'i>> {
+) -> impl Parser, InlineTable, ContextError<'i>> {
move |input| {
delimited(
INLINE_TABLE_OPEN,
@@ -98,7 +98,7 @@ pub(crate) const KEYVAL_SEP: u8 = b'=';
fn inline_table_keyvals<'i>(
check: RecursionCheck,
-) -> impl Parser, (Vec<(Vec, TableKeyValue)>, RawString), ParserError<'i>> {
+) -> impl Parser, (Vec<(Vec, TableKeyValue)>, RawString), ContextError<'i>> {
move |input| {
let check = check.recursing(input)?;
(
@@ -111,7 +111,7 @@ fn inline_table_keyvals<'i>(
fn keyval<'i>(
check: RecursionCheck,
-) -> impl Parser, (Vec, TableKeyValue), ParserError<'i>> {
+) -> impl Parser, (Vec, TableKeyValue), ContextError<'i>> {
move |input| {
(
key,
diff --git a/crates/toml_edit/src/parser/key.rs b/crates/toml_edit/src/parser/key.rs
index a8dffdde..36fd0205 100644
--- a/crates/toml_edit/src/parser/key.rs
+++ b/crates/toml_edit/src/parser/key.rs
@@ -16,7 +16,7 @@ use crate::RawString;
// key = simple-key / dotted-key
// dotted-key = simple-key 1*( dot-sep simple-key )
-pub(crate) fn key(input: Input<'_>) -> IResult, Vec, ParserError<'_>> {
+pub(crate) fn key(input: Input<'_>) -> IResult, Vec, ContextError<'_>> {
separated1(
(ws.span(), simple_key, ws.span()).map(|(pre, (raw, key), suffix)| {
Key::new(key)
@@ -41,7 +41,7 @@ pub(crate) fn key(input: Input<'_>) -> IResult, Vec, ParserError<
// quoted-key = basic-string / literal-string
pub(crate) fn simple_key(
input: Input<'_>,
-) -> IResult, (RawString, InternalString), ParserError<'_>> {
+) -> IResult, (RawString, InternalString), ContextError<'_>> {
dispatch! {peek(any);
crate::parser::strings::QUOTATION_MARK => basic_string
.map(|s: std::borrow::Cow<'_, str>| s.as_ref().into()),
@@ -57,7 +57,7 @@ pub(crate) fn simple_key(
}
// unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F ) ; A-Z / a-z / 0-9 / - / _
-fn unquoted_key(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+fn unquoted_key(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
take_while(1.., UNQUOTED_CHAR)
.map(|b| unsafe { from_utf8_unchecked(b, "`is_unquoted_char` filters out on-ASCII") })
.parse_next(input)
diff --git a/crates/toml_edit/src/parser/mod.rs b/crates/toml_edit/src/parser/mod.rs
index 7c0d0119..7ed57ca9 100644
--- a/crates/toml_edit/src/parser/mod.rs
+++ b/crates/toml_edit/src/parser/mod.rs
@@ -73,7 +73,7 @@ pub(crate) fn parse_value(raw: &str) -> Result {
}
pub(crate) mod prelude {
- pub(crate) use super::errors::ParserError;
+ pub(crate) use super::errors::ContextError;
pub(crate) use super::errors::StrContext;
pub(crate) use super::errors::StrContextValue;
pub(crate) use winnow::combinator::dispatch;
@@ -115,7 +115,7 @@ pub(crate) mod prelude {
pub(crate) fn recursing(
mut self,
input: Input<'_>,
- ) -> Result>> {
+ ) -> Result>> {
self.current += 1;
if self.current < 128 {
Ok(self)
@@ -144,7 +144,7 @@ pub(crate) mod prelude {
pub(crate) fn recursing(
self,
_input: Input<'_>,
- ) -> Result>> {
+ ) -> Result>> {
Ok(self)
}
}
diff --git a/crates/toml_edit/src/parser/numbers.rs b/crates/toml_edit/src/parser/numbers.rs
index 1849ec3d..efabde63 100644
--- a/crates/toml_edit/src/parser/numbers.rs
+++ b/crates/toml_edit/src/parser/numbers.rs
@@ -18,16 +18,16 @@ use crate::parser::trivia::from_utf8_unchecked;
// boolean = true / false
#[allow(dead_code)] // directly define in `fn value`
-pub(crate) fn boolean(input: Input<'_>) -> IResult, bool, ParserError<'_>> {
+pub(crate) fn boolean(input: Input<'_>) -> IResult, bool, ContextError<'_>> {
alt((true_, false_)).parse_next(input)
}
-pub(crate) fn true_(input: Input<'_>) -> IResult, bool, ParserError<'_>> {
+pub(crate) fn true_(input: Input<'_>) -> IResult, bool, ContextError<'_>> {
(peek(TRUE[0]), cut_err(TRUE)).value(true).parse_next(input)
}
const TRUE: &[u8] = b"true";
-pub(crate) fn false_(input: Input<'_>) -> IResult, bool, ParserError<'_>> {
+pub(crate) fn false_(input: Input<'_>) -> IResult, bool, ContextError<'_>> {
(peek(FALSE[0]), cut_err(FALSE))
.value(false)
.parse_next(input)
@@ -37,7 +37,7 @@ const FALSE: &[u8] = b"false";
// ;; Integer
// integer = dec-int / hex-int / oct-int / bin-int
-pub(crate) fn integer(input: Input<'_>) -> IResult, i64, ParserError<'_>> {
+pub(crate) fn integer(input: Input<'_>) -> IResult, i64, ContextError<'_>> {
dispatch! {peek(opt::<_, &[u8], _, _>(take(2usize)));
Some(b"0x") => cut_err(hex_int.try_map(|s| i64::from_str_radix(&s.replace('_', ""), 16))),
Some(b"0o") => cut_err(oct_int.try_map(|s| i64::from_str_radix(&s.replace('_', ""), 8))),
@@ -50,7 +50,7 @@ pub(crate) fn integer(input: Input<'_>) -> IResult, i64, ParserError<'
// dec-int = [ minus / plus ] unsigned-dec-int
// unsigned-dec-int = DIGIT / digit1-9 1*( DIGIT / underscore DIGIT )
-pub(crate) fn dec_int(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn dec_int(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(
opt(one_of((b'+', b'-'))),
alt((
@@ -84,7 +84,7 @@ const DIGIT1_9: RangeInclusive = b'1'..=b'9';
// hex-prefix = %x30.78 ; 0x
// hex-int = hex-prefix HEXDIG *( HEXDIG / underscore HEXDIG )
-pub(crate) fn hex_int(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn hex_int(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
preceded(
HEX_PREFIX,
cut_err((
@@ -113,7 +113,7 @@ const HEX_PREFIX: &[u8] = b"0x";
// oct-prefix = %x30.6F ; 0o
// oct-int = oct-prefix digit0-7 *( digit0-7 / underscore digit0-7 )
-pub(crate) fn oct_int(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn oct_int(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
preceded(
OCT_PREFIX,
cut_err((
@@ -143,7 +143,7 @@ const DIGIT0_7: RangeInclusive = b'0'..=b'7';
// bin-prefix = %x30.62 ; 0b
// bin-int = bin-prefix digit0-1 *( digit0-1 / underscore digit0-1 )
-pub(crate) fn bin_int(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn bin_int(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
preceded(
BIN_PREFIX,
cut_err((
@@ -176,7 +176,7 @@ const DIGIT0_1: RangeInclusive = b'0'..=b'1';
// float = float-int-part ( exp / frac [ exp ] )
// float =/ special-float
// float-int-part = dec-int
-pub(crate) fn float(input: Input<'_>) -> IResult, f64, ParserError<'_>> {
+pub(crate) fn float(input: Input<'_>) -> IResult, f64, ContextError<'_>> {
alt((
float_.and_then(cut_err(
rest.try_map(|s: &str| s.replace('_', "").parse())
@@ -188,7 +188,7 @@ pub(crate) fn float(input: Input<'_>) -> IResult, f64, ParserError<'_>
.parse_next(input)
}
-pub(crate) fn float_(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn float_(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(dec_int, alt((exp, (frac, opt(exp)).map(|_| ""))))
.recognize()
.map(|b: &[u8]| unsafe {
@@ -202,7 +202,7 @@ pub(crate) fn float_(input: Input<'_>) -> IResult, &str, ParserError<'
// frac = decimal-point zero-prefixable-int
// decimal-point = %x2E ; .
-pub(crate) fn frac(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn frac(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(
b'.',
cut_err(zero_prefixable_int)
@@ -219,7 +219,7 @@ pub(crate) fn frac(input: Input<'_>) -> IResult, &str, ParserError<'_>
}
// zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT )
-pub(crate) fn zero_prefixable_int(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn zero_prefixable_int(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(
digit,
repeat(
@@ -243,7 +243,7 @@ pub(crate) fn zero_prefixable_int(input: Input<'_>) -> IResult, &str,
// exp = "e" float-exp-part
// float-exp-part = [ minus / plus ] zero-prefixable-int
-pub(crate) fn exp(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn exp(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(
one_of((b'e', b'E')),
opt(one_of([b'+', b'-'])),
@@ -260,7 +260,7 @@ pub(crate) fn exp(input: Input<'_>) -> IResult, &str, ParserError<'_>>
}
// special-float = [ minus / plus ] ( inf / nan )
-pub(crate) fn special_float(input: Input<'_>) -> IResult, f64, ParserError<'_>> {
+pub(crate) fn special_float(input: Input<'_>) -> IResult, f64, ContextError<'_>> {
(opt(one_of((b'+', b'-'))), alt((inf, nan)))
.map(|(s, f)| match s {
Some(b'+') | None => f,
@@ -270,24 +270,24 @@ pub(crate) fn special_float(input: Input<'_>) -> IResult, f64, ParserE
.parse_next(input)
}
// inf = %x69.6e.66 ; inf
-pub(crate) fn inf(input: Input<'_>) -> IResult, f64, ParserError<'_>> {
+pub(crate) fn inf(input: Input<'_>) -> IResult, f64, ContextError<'_>> {
tag(INF).value(f64::INFINITY).parse_next(input)
}
const INF: &[u8] = b"inf";
// nan = %x6e.61.6e ; nan
-pub(crate) fn nan(input: Input<'_>) -> IResult, f64, ParserError<'_>> {
+pub(crate) fn nan(input: Input<'_>) -> IResult, f64, ContextError<'_>> {
tag(NAN).value(f64::NAN).parse_next(input)
}
const NAN: &[u8] = b"nan";
// DIGIT = %x30-39 ; 0-9
-pub(crate) fn digit(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn digit(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
one_of(DIGIT).parse_next(input)
}
const DIGIT: RangeInclusive = b'0'..=b'9';
// HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
-pub(crate) fn hexdig(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn hexdig(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
one_of(HEXDIG).parse_next(input)
}
pub(crate) const HEXDIG: (RangeInclusive, RangeInclusive, RangeInclusive) =
diff --git a/crates/toml_edit/src/parser/strings.rs b/crates/toml_edit/src/parser/strings.rs
index e5015e3d..cbd49b0f 100644
--- a/crates/toml_edit/src/parser/strings.rs
+++ b/crates/toml_edit/src/parser/strings.rs
@@ -27,7 +27,7 @@ use crate::parser::trivia::{from_utf8_unchecked, newline, ws, ws_newlines, NON_A
// ;; String
// string = ml-basic-string / basic-string / ml-literal-string / literal-string
-pub(crate) fn string(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+pub(crate) fn string(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
alt((
ml_basic_string,
basic_string,
@@ -40,7 +40,7 @@ pub(crate) fn string(input: Input<'_>) -> IResult, Cow<'_, str>, Parse
// ;; Basic String
// basic-string = quotation-mark *basic-char quotation-mark
-pub(crate) fn basic_string(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+pub(crate) fn basic_string(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
let (mut input, _) = one_of(QUOTATION_MARK).parse_next(input)?;
let mut c = Cow::Borrowed("");
@@ -64,7 +64,7 @@ pub(crate) fn basic_string(input: Input<'_>) -> IResult, Cow<'_, str>,
pub(crate) const QUOTATION_MARK: u8 = b'"';
// basic-char = basic-unescaped / escaped
-fn basic_chars(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+fn basic_chars(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
alt((
// Deviate from the official grammar by batching the unescaped chars so we build a string a
// chunk at a time, rather than a `char` at a time.
@@ -86,7 +86,7 @@ pub(crate) const BASIC_UNESCAPED: (
) = (WSCHAR, 0x21, 0x23..=0x5B, 0x5D..=0x7E, NON_ASCII);
// escaped = escape escape-seq-char
-fn escaped(input: Input<'_>) -> IResult, char, ParserError<'_>> {
+fn escaped(input: Input<'_>) -> IResult, char, ContextError<'_>> {
preceded(ESCAPE, escape_seq_char).parse_next(input)
}
@@ -102,7 +102,7 @@ pub(crate) const ESCAPE: u8 = b'\\';
// escape-seq-char =/ %x74 ; t tab U+0009
// escape-seq-char =/ %x75 4HEXDIG ; uXXXX U+XXXX
// escape-seq-char =/ %x55 8HEXDIG ; UXXXXXXXX U+XXXXXXXX
-fn escape_seq_char(input: Input<'_>) -> IResult, char, ParserError<'_>> {
+fn escape_seq_char(input: Input<'_>) -> IResult, char, ContextError<'_>> {
dispatch! {any;
b'b' => success('\u{8}'),
b'f' => success('\u{c}'),
@@ -132,7 +132,7 @@ fn escape_seq_char(input: Input<'_>) -> IResult, char, ParserError<'_>
pub(crate) fn hexescape(
input: Input<'_>,
-) -> IResult, char, ParserError<'_>> {
+) -> IResult, char, ContextError<'_>> {
take_while(0..=N, HEXDIG)
.verify(|b: &[u8]| b.len() == N)
.map(|b: &[u8]| unsafe { from_utf8_unchecked(b, "`is_ascii_digit` filters out on-ASCII") })
@@ -145,7 +145,7 @@ pub(crate) fn hexescape(
// ml-basic-string = ml-basic-string-delim [ newline ] ml-basic-body
// ml-basic-string-delim
-fn ml_basic_string(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+fn ml_basic_string(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
delimited(
ML_BASIC_STRING_DELIM,
preceded(opt(newline), cut_err(ml_basic_body)),
@@ -159,7 +159,7 @@ fn ml_basic_string(input: Input<'_>) -> IResult, Cow<'_, str>, ParserE
pub(crate) const ML_BASIC_STRING_DELIM: &[u8] = b"\"\"\"";
// ml-basic-body = *mlb-content *( mlb-quotes 1*mlb-content ) [ mlb-quotes ]
-fn ml_basic_body(mut input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+fn ml_basic_body(mut input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
let mut c = Cow::Borrowed("");
if let Some((i, ci)) = ok_error(mlb_content.parse_next(input))? {
input = i;
@@ -196,7 +196,7 @@ fn ml_basic_body(mut input: Input<'_>) -> IResult, Cow<'_, str>, Parse
// mlb-content = mlb-char / newline / mlb-escaped-nl
// mlb-char = mlb-unescaped / escaped
-fn mlb_content(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+fn mlb_content(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
alt((
// Deviate from the official grammar by batching the unescaped chars so we build a string a
// chunk at a time, rather than a `char` at a time.
@@ -213,8 +213,8 @@ fn mlb_content(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError
// mlb-quotes = 1*2quotation-mark
fn mlb_quotes<'i>(
- mut term: impl winnow::Parser, (), ParserError<'i>>,
-) -> impl Parser, &'i str, ParserError<'i>> {
+ mut term: impl winnow::Parser, (), ContextError<'i>>,
+) -> impl Parser, &'i str, ContextError<'i>> {
move |input| {
let res = terminated(b"\"\"", peek(term.by_ref()))
.map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") })
@@ -243,7 +243,7 @@ pub(crate) const MLB_UNESCAPED: (
// it will be trimmed along with all whitespace
// (including newlines) up to the next non-whitespace
// character or closing delimiter.
-fn mlb_escaped_nl(input: Input<'_>) -> IResult, (), ParserError<'_>> {
+fn mlb_escaped_nl(input: Input<'_>) -> IResult, (), ContextError<'_>> {
repeat(1.., (ESCAPE, ws, ws_newlines))
.map(|()| ())
.value(())
@@ -253,7 +253,7 @@ fn mlb_escaped_nl(input: Input<'_>) -> IResult, (), ParserError<'_>> {
// ;; Literal String
// literal-string = apostrophe *literal-char apostrophe
-pub(crate) fn literal_string(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn literal_string(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
delimited(
APOSTROPHE,
cut_err(take_while(0.., LITERAL_CHAR)),
@@ -279,7 +279,7 @@ pub(crate) const LITERAL_CHAR: (
// ml-literal-string = ml-literal-string-delim [ newline ] ml-literal-body
// ml-literal-string-delim
-fn ml_literal_string(input: Input<'_>) -> IResult, Cow<'_, str>, ParserError<'_>> {
+fn ml_literal_string(input: Input<'_>) -> IResult, Cow<'_, str>, ContextError<'_>> {
delimited(
(ML_LITERAL_STRING_DELIM, opt(newline)),
cut_err(ml_literal_body.map(|t| {
@@ -299,7 +299,7 @@ fn ml_literal_string(input: Input<'_>) -> IResult, Cow<'_, str>, Parse
pub(crate) const ML_LITERAL_STRING_DELIM: &[u8] = b"'''";
// ml-literal-body = *mll-content *( mll-quotes 1*mll-content ) [ mll-quotes ]
-fn ml_literal_body(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+fn ml_literal_body(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(
repeat(0.., mll_content).map(|()| ()),
repeat(
@@ -318,7 +318,7 @@ fn ml_literal_body(input: Input<'_>) -> IResult, &str, ParserError<'_>
}
// mll-content = mll-char / newline
-fn mll_content(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+fn mll_content(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
alt((one_of(MLL_CHAR), newline)).parse_next(input)
}
@@ -332,8 +332,8 @@ const MLL_CHAR: (
// mll-quotes = 1*2apostrophe
fn mll_quotes<'i>(
- mut term: impl winnow::Parser, (), ParserError<'i>>,
-) -> impl Parser, &'i str, ParserError<'i>> {
+ mut term: impl winnow::Parser, (), ContextError<'i>>,
+) -> impl Parser, &'i str, ContextError<'i>> {
move |input| {
let res = terminated(b"''", peek(term.by_ref()))
.map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") })
diff --git a/crates/toml_edit/src/parser/table.rs b/crates/toml_edit/src/parser/table.rs
index 6f4f43f7..14366ccb 100644
--- a/crates/toml_edit/src/parser/table.rs
+++ b/crates/toml_edit/src/parser/table.rs
@@ -27,7 +27,7 @@ const ARRAY_TABLE_CLOSE: &[u8] = b"]]";
// std-table = std-table-open key *( table-key-sep key) std-table-close
pub(crate) fn std_table<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
(
delimited(
@@ -52,7 +52,7 @@ pub(crate) fn std_table<'s, 'i>(
// array-table = array-table-open key *( table-key-sep key) array-table-close
pub(crate) fn array_table<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
(
delimited(
@@ -77,7 +77,7 @@ pub(crate) fn array_table<'s, 'i>(
// table = std-table / array-table
pub(crate) fn table<'s, 'i>(
state: &'s RefCell,
-) -> impl Parser, (), ParserError<'i>> + 's {
+) -> impl Parser, (), ContextError<'i>> + 's {
move |i| {
dispatch!(peek::<_, &[u8],_,_>(take(2usize));
b"[[" => array_table(state),
diff --git a/crates/toml_edit/src/parser/trivia.rs b/crates/toml_edit/src/parser/trivia.rs
index ba47dcde..653bac0b 100644
--- a/crates/toml_edit/src/parser/trivia.rs
+++ b/crates/toml_edit/src/parser/trivia.rs
@@ -28,7 +28,7 @@ pub(crate) unsafe fn from_utf8_unchecked<'b>(
pub(crate) const WSCHAR: (u8, u8) = (b' ', b'\t');
// ws = *wschar
-pub(crate) fn ws(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn ws(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
take_while(0.., WSCHAR)
.map(|b| unsafe { from_utf8_unchecked(b, "`is_wschar` filters out on-ASCII") })
.parse_next(input)
@@ -48,7 +48,7 @@ pub(crate) const NON_EOL: (u8, RangeInclusive, RangeInclusive) =
pub(crate) const COMMENT_START_SYMBOL: u8 = b'#';
// comment = comment-start-symbol *non-eol
-pub(crate) fn comment(input: Input<'_>) -> IResult, &[u8], ParserError<'_>> {
+pub(crate) fn comment(input: Input<'_>) -> IResult, &[u8], ContextError<'_>> {
(COMMENT_START_SYMBOL, take_while(0.., NON_EOL))
.recognize()
.parse_next(input)
@@ -56,7 +56,7 @@ pub(crate) fn comment(input: Input<'_>) -> IResult, &[u8], ParserError
// newline = ( %x0A / ; LF
// %x0D.0A ) ; CRLF
-pub(crate) fn newline(input: Input<'_>) -> IResult, u8, ParserError<'_>> {
+pub(crate) fn newline(input: Input<'_>) -> IResult, u8, ContextError<'_>> {
alt((
one_of(LF).value(b'\n'),
(one_of(CR), one_of(LF)).value(b'\n'),
@@ -67,7 +67,7 @@ pub(crate) const LF: u8 = b'\n';
pub(crate) const CR: u8 = b'\r';
// ws-newline = *( wschar / newline )
-pub(crate) fn ws_newline(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn ws_newline(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
repeat(
0..,
alt((newline.value(&b"\n"[..]), take_while(1.., WSCHAR))),
@@ -79,7 +79,7 @@ pub(crate) fn ws_newline(input: Input<'_>) -> IResult, &str, ParserErr
}
// ws-newlines = newline *( wschar / newline )
-pub(crate) fn ws_newlines(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn ws_newlines(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
(newline, ws_newline)
.recognize()
.map(|b| unsafe {
@@ -90,7 +90,7 @@ pub(crate) fn ws_newlines(input: Input<'_>) -> IResult, &str, ParserEr
// note: this rule is not present in the original grammar
// ws-comment-newline = *( ws-newline-nonempty / comment )
-pub(crate) fn ws_comment_newline(input: Input<'_>) -> IResult, &[u8], ParserError<'_>> {
+pub(crate) fn ws_comment_newline(input: Input<'_>) -> IResult, &[u8], ContextError<'_>> {
repeat(
0..,
alt((
@@ -109,7 +109,7 @@ pub(crate) fn ws_comment_newline(input: Input<'_>) -> IResult, &[u8],
// note: this rule is not present in the original grammar
// line-ending = newline / eof
-pub(crate) fn line_ending(input: Input<'_>) -> IResult, &str, ParserError<'_>> {
+pub(crate) fn line_ending(input: Input<'_>) -> IResult, &str, ContextError<'_>> {
alt((newline.value("\n"), eof.value(""))).parse_next(input)
}
@@ -117,7 +117,7 @@ pub(crate) fn line_ending(input: Input<'_>) -> IResult, &str, ParserEr
// line-trailing = ws [comment] skip-line-ending
pub(crate) fn line_trailing(
input: Input<'_>,
-) -> IResult, std::ops::Range, ParserError<'_>> {
+) -> IResult, std::ops::Range, ContextError<'_>> {
terminated((ws, opt(comment)).span(), line_ending).parse_next(input)
}
diff --git a/crates/toml_edit/src/parser/value.rs b/crates/toml_edit/src/parser/value.rs
index bbbeafcd..c607aa95 100644
--- a/crates/toml_edit/src/parser/value.rs
+++ b/crates/toml_edit/src/parser/value.rs
@@ -17,7 +17,7 @@ use crate::Value;
// val = string / boolean / array / inline-table / date-time / float / integer
pub(crate) fn value<'i>(
check: RecursionCheck,
-) -> impl Parser, v::Value, ParserError<'i>> {
+) -> impl Parser, v::Value, ContextError<'i>> {
move |input| {
dispatch!{peek(any);
crate::parser::strings::QUOTATION_MARK |