summaryrefslogtreecommitdiffstats
path: root/vendor/winnow/src/_topic/language.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/winnow/src/_topic/language.rs')
-rw-r--r--vendor/winnow/src/_topic/language.rs67
1 files changed, 41 insertions, 26 deletions
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;