summaryrefslogtreecommitdiffstats
path: root/vendor/winnow/src/_topic
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/winnow/src/_topic
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/winnow/src/_topic')
-rw-r--r--vendor/winnow/src/_topic/error.rs4
-rw-r--r--vendor/winnow/src/_topic/language.rs67
-rw-r--r--vendor/winnow/src/_topic/performance.rs10
-rw-r--r--vendor/winnow/src/_topic/stream.rs4
4 files changed, 50 insertions, 35 deletions
diff --git a/vendor/winnow/src/_topic/error.rs b/vendor/winnow/src/_topic/error.rs
index abf2f8dbb..c5374b4a8 100644
--- a/vendor/winnow/src/_topic/error.rs
+++ b/vendor/winnow/src/_topic/error.rs
@@ -1,9 +1,9 @@
//! # Custom Errors
//!
-//! The most basic error type is [`ParseError`][crate::error::ParseError]
+//! The most basic error type is [`ParserError`][crate::error::ParserError]
//!
//! Optional traits include:
-//! - [`ContextError`][crate::error::ContextError]
+//! - [`AddContext`][crate::error::AddContext]
//! - [`FromExternalError`][crate::error::FromExternalError]
//!
//! # Example
diff --git a/vendor/winnow/src/_topic/language.rs b/vendor/winnow/src/_topic/language.rs
index 245bab4c7..0cebc99b7 100644
--- a/vendor/winnow/src/_topic/language.rs
+++ b/vendor/winnow/src/_topic/language.rs
@@ -27,14 +27,14 @@
//! ```rust
//! use winnow::prelude::*;
//! use winnow::{
-//! error::ParseError,
+//! error::ParserError,
//! combinator::delimited,
//! ascii::multispace0,
//! };
//!
//! /// A combinator that takes a parser `inner` and produces a parser that also consumes both leading and
//! /// trailing whitespace, returning the output of `inner`.
-//! fn ws<'a, F, O, E: ParseError<&'a str>>(inner: F) -> impl Parser<&'a str, O, E>
+//! fn ws<'a, F, O, E: ParserError<&'a str>>(inner: F) -> impl Parser<&'a str, O, E>
//! where
//! F: Parser<&'a str, O, E>,
//! {
@@ -61,13 +61,13 @@
//! ```rust
//! use winnow::prelude::*;
//! use winnow::{
-//! error::ParseError,
+//! error::ParserError,
//! token::take_till1,
//! };
//!
-//! pub fn peol_comment<'a, E: ParseError<&'a str>>(i: &'a str) -> IResult<&'a str, (), E>
+//! pub fn peol_comment<'a, E: ParserError<&'a str>>(i: &mut &'a str) -> PResult<(), E>
//! {
-//! ('%', take_till1("\n\r"))
+//! ('%', take_till1(['\n', '\r']))
//! .void() // Output is thrown away.
//! .parse_next(i)
//! }
@@ -81,11 +81,11 @@
//! ```rust
//! use winnow::prelude::*;
//! use winnow::{
-//! error::ParseError,
+//! error::ParserError,
//! token::{tag, take_until0},
//! };
//!
-//! pub fn pinline_comment<'a, E: ParseError<&'a str>>(i: &'a str) -> IResult<&'a str, (), E> {
+//! pub fn pinline_comment<'a, E: ParserError<&'a str>>(i: &mut &'a str) -> PResult<(), E> {
//! (
//! "(*",
//! take_until0("*)"),
@@ -111,7 +111,7 @@
//! token::one_of,
//! };
//!
-//! pub fn identifier(input: &str) -> IResult<&str, &str> {
+//! pub fn identifier<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! (
//! one_of(|c: char| c.is_alpha() || c == '_'),
//! take_while(0.., |c: char| c.is_alphanum() || c == '_')
@@ -136,6 +136,8 @@
#![doc = include_str!("../../examples/string/parser.rs")]
//! ```
//!
+//! See also [`escaped`] and [`escaped_transform`].
+//!
//! ### Integers
//!
//! The following recipes all return string slices rather than integer values. How to obtain an
@@ -160,11 +162,11 @@
//! token::tag,
//! };
//!
-//! fn hexadecimal(input: &str) -> IResult<&str, &str> { // <'a, E: ParseError<&'a str>>
+//! fn hexadecimal<'s>(input: &mut &'s str) -> PResult<&'s str> { // <'a, E: ParserError<&'a str>>
//! preceded(
//! alt(("0x", "0X")),
//! repeat(1..,
-//! terminated(one_of("0123456789abcdefABCDEF"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of(('0'..='9', 'a'..='f', 'A'..='F')), repeat(0.., '_').map(|()| ()))
//! ).map(|()| ()).recognize()
//! ).parse_next(input)
//! }
@@ -182,11 +184,11 @@
//! token::tag,
//! };
//!
-//! fn hexadecimal_value(input: &str) -> IResult<&str, i64> {
+//! fn hexadecimal_value(input: &mut &str) -> PResult<i64> {
//! preceded(
//! alt(("0x", "0X")),
//! repeat(1..,
-//! terminated(one_of("0123456789abcdefABCDEF"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of(('0'..='9', 'a'..='f', 'A'..='F')), repeat(0.., '_').map(|()| ()))
//! ).map(|()| ()).recognize()
//! ).try_map(
//! |out: &str| i64::from_str_radix(&str::replace(&out, "_", ""), 16)
@@ -194,6 +196,8 @@
//! }
//! ```
//!
+//! See also [`hex_uint`]
+//!
//! #### Octal
//!
//! ```rust
@@ -206,11 +210,11 @@
//! token::tag,
//! };
//!
-//! fn octal(input: &str) -> IResult<&str, &str> {
+//! fn octal<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! preceded(
//! alt(("0o", "0O")),
//! repeat(1..,
-//! terminated(one_of("01234567"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of('0'..='7'), repeat(0.., '_').map(|()| ()))
//! ).map(|()| ()).recognize()
//! ).parse_next(input)
//! }
@@ -228,11 +232,11 @@
//! token::tag,
//! };
//!
-//! fn binary(input: &str) -> IResult<&str, &str> {
+//! fn binary<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! preceded(
//! alt(("0b", "0B")),
//! repeat(1..,
-//! terminated(one_of("01"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of('0'..='1'), repeat(0.., '_').map(|()| ()))
//! ).map(|()| ()).recognize()
//! ).parse_next(input)
//! }
@@ -243,21 +247,22 @@
//! ```rust
//! use winnow::prelude::*;
//! use winnow::{
-//! IResult,
//! combinator::{repeat},
//! combinator::terminated,
//! token::one_of,
//! };
//!
-//! fn decimal(input: &str) -> IResult<&str, &str> {
+//! fn decimal<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! repeat(1..,
-//! terminated(one_of("0123456789"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of('0'..='9'), repeat(0.., '_').map(|()| ()))
//! ).map(|()| ())
//! .recognize()
//! .parse_next(input)
//! }
//! ```
//!
+//! See also [`dec_uint`] and [`dec_int`]
+//!
//! ### Floating Point Numbers
//!
//! The following is adapted from [the Python parser by Valentin Lorentz](https://github.com/ProgVal/rust-python-parser/blob/master/src/numbers.rs).
@@ -272,15 +277,15 @@
//! token::one_of,
//! };
//!
-//! fn float(input: &str) -> IResult<&str, &str> {
+//! fn float<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! alt((
//! // Case one: .42
//! (
//! '.',
//! decimal,
//! opt((
-//! one_of("eE"),
-//! opt(one_of("+-")),
+//! one_of(['e', 'E']),
+//! opt(one_of(['+', '-'])),
//! decimal
//! ))
//! ).recognize()
@@ -291,8 +296,8 @@
//! '.',
//! decimal,
//! )),
-//! one_of("eE"),
-//! opt(one_of("+-")),
+//! one_of(['e', 'E']),
+//! opt(one_of(['+', '-'])),
//! decimal
//! ).recognize()
//! , // Case three: 42. and 42.42
@@ -304,12 +309,22 @@
//! )).parse_next(input)
//! }
//!
-//! fn decimal(input: &str) -> IResult<&str, &str> {
+//! fn decimal<'s>(input: &mut &'s str) -> PResult<&'s str> {
//! repeat(1..,
-//! terminated(one_of("0123456789"), repeat(0.., '_').map(|()| ()))
+//! terminated(one_of('0'..='9'), repeat(0.., '_').map(|()| ()))
//! ).
//! map(|()| ())
//! .recognize()
//! .parse_next(input)
//! }
//! ```
+//!
+//! See also [`float`]
+
+#![allow(unused_imports)]
+use crate::ascii::dec_int;
+use crate::ascii::dec_uint;
+use crate::ascii::escaped;
+use crate::ascii::escaped_transform;
+use crate::ascii::float;
+use crate::ascii::hex_uint;
diff --git a/vendor/winnow/src/_topic/performance.rs b/vendor/winnow/src/_topic/performance.rs
index fac12da4c..5bda958ee 100644
--- a/vendor/winnow/src/_topic/performance.rs
+++ b/vendor/winnow/src/_topic/performance.rs
@@ -6,7 +6,7 @@
//!
//! Tips
//! - When enough cases of an [`alt`] have unique prefixes, prefer [`dispatch`]
-//! - When parsing text, try to parse is as bytes (`u8`) rather than `char`s ([`BStr`] can make
+//! - When parsing text, try to parse as bytes (`u8`) rather than `char`s ([`BStr`] can make
//! debugging easier)
//! - Find simplified subsets of the grammar to parse, falling back to the full grammar when it
//! doesn't work. For example, when parsing json strings, parse them without support for escapes,
@@ -14,7 +14,7 @@
//! - Watch for large return types. A surprising place these can show up is when chaining parsers
//! with a tuple.
//!
-//! ## Built-time Performance
+//! ## Build-time Performance
//!
//! Returning complex types as `impl Trait` can negatively impact build times. This can hit in
//! surprising cases like:
@@ -24,7 +24,7 @@
//! # where
//! # I: winnow::stream::Stream<Token=O>,
//! # I: winnow::stream::StreamIsPartial,
-//! # E: winnow::error::ParseError<I>,
+//! # E: winnow::error::ParserError<I>,
//! {
//! // ...some chained combinators...
//! # winnow::token::any
@@ -38,9 +38,9 @@
//! # where
//! # I: winnow::stream::Stream<Token=O>,
//! # I: winnow::stream::StreamIsPartial,
-//! # E: winnow::error::ParseError<I>,
+//! # E: winnow::error::ParserError<I>,
//! {
-//! move |input: I| {
+//! move |input: &mut I| {
//! // ...some chained combinators...
//! # winnow::token::any
//! .parse_next(input)
diff --git a/vendor/winnow/src/_topic/stream.rs b/vendor/winnow/src/_topic/stream.rs
index 7455e185b..4f94a94b9 100644
--- a/vendor/winnow/src/_topic/stream.rs
+++ b/vendor/winnow/src/_topic/stream.rs
@@ -13,14 +13,14 @@
//! ## Implementing a custom stream
//!
//! Let's assume we have an input type we'll call `MyStream`. `MyStream` is a sequence of `MyItem` type.
-//! The goal is to define parsers with this signature: `MyStream -> IResult<MyStream, Output>`.
+//! The goal is to define parsers with this signature: `&mut MyStream -> PResult<Output>`.
//!
//! ```rust
//! # use winnow::prelude::*;
//! # use winnow::token::tag;
//! # type MyStream<'i> = &'i str;
//! # type Output<'i> = &'i str;
-//! fn parser(i: MyStream<'_>) -> IResult<MyStream<'_>, Output<'_>> {
+//! fn parser<'s>(i: &mut MyStream<'s>) -> PResult<Output<'s>> {
//! "test".parse_next(i)
//! }
//! ```