summaryrefslogtreecommitdiffstats
path: root/vendor/pest_generator
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
commit2ff14448863ac1a1dd9533461708e29aae170c2d (patch)
tree85b9fea2bbfe3f06473cfa381eed11f273b57c5c /vendor/pest_generator
parentAdding debian version 1.64.0+dfsg1-1. (diff)
downloadrustc-2ff14448863ac1a1dd9533461708e29aae170c2d.tar.xz
rustc-2ff14448863ac1a1dd9533461708e29aae170c2d.zip
Adding debian version 1.65.0+dfsg1-2.debian/1.65.0+dfsg1-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/pest_generator')
-rw-r--r--vendor/pest_generator/.cargo-checksum.json2
-rw-r--r--vendor/pest_generator/Cargo.toml34
-rw-r--r--vendor/pest_generator/_README.md23
-rw-r--r--vendor/pest_generator/src/generator.rs72
-rw-r--r--vendor/pest_generator/src/macros.rs14
5 files changed, 96 insertions, 49 deletions
diff --git a/vendor/pest_generator/.cargo-checksum.json b/vendor/pest_generator/.cargo-checksum.json
index 54f869f8e..573d6c49f 100644
--- a/vendor/pest_generator/.cargo-checksum.json
+++ b/vendor/pest_generator/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"0f2f8b8f880c20e4281e53b2675356ee672d7c04b015f4c182509ed2ca614e6e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"e9901b6c4d50403bfda7e08a92b5c395a8c51eba868c7bd07b03e00ccba702f3","src/generator.rs":"7b0b67ec000ccde0ec8df83b26f84e0a7b2a17e255e900ab28379984e7dbba27","src/lib.rs":"1cc63047aad721587a23eeea54d4c398bf5c085d934e41100a8766954a1b6071","src/macros.rs":"03ae0a9ec0210b19c8e6becc275df11b504003d22f3ff758d8bf3ee997d2b476"},"package":"99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"} \ No newline at end of file
+{"files":{"Cargo.toml":"f047138333fb2c65ecd773393f1f61e4778ad467a376b5417d9047c300274be5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"01ba71f02581f9f5018962e083ca77bc8e8af2b6f8a73111bfa04e847a6440e2","src/generator.rs":"51081975a6237bc77cdc4535841c7fbf777e3c466b4c89c821ab68850eeb656a","src/lib.rs":"1cc63047aad721587a23eeea54d4c398bf5c085d934e41100a8766954a1b6071","src/macros.rs":"6522f9b7a2fb172d9ff6ad75c3dcfd547596b5c6ea23f3f5a386220d4f85afa4"},"package":"5803d8284a629cc999094ecd630f55e91b561a1d1ba75e233b00ae13b91a69ad"} \ No newline at end of file
diff --git a/vendor/pest_generator/Cargo.toml b/vendor/pest_generator/Cargo.toml
index 1ef45f99a..5db0c4b01 100644
--- a/vendor/pest_generator/Cargo.toml
+++ b/vendor/pest_generator/Cargo.toml
@@ -3,30 +3,36 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
+edition = "2018"
+rust-version = "1.56"
name = "pest_generator"
-version = "2.1.3"
+version = "2.3.0"
authors = ["DragoČ™ Tiselice <dragostiselice@gmail.com>"]
description = "pest code generator"
homepage = "https://pest-parser.github.io/"
documentation = "https://docs.rs/pest"
readme = "_README.md"
-keywords = ["pest", "generator"]
+keywords = [
+ "pest",
+ "generator",
+]
categories = ["parsing"]
license = "MIT/Apache-2.0"
repository = "https://github.com/pest-parser/pest"
+
[dependencies.pest]
-version = "2.1.0"
+version = "2.3.0"
+default-features = false
[dependencies.pest_meta]
-version = "2.1.0"
+version = "2.3.0"
[dependencies.proc-macro2]
version = "1.0"
@@ -36,11 +42,7 @@ version = "1.0"
[dependencies.syn]
version = "1.0"
-[badges.codecov]
-repository = "pest-parser/pest"
-
-[badges.maintenance]
-status = "actively-developed"
-[badges.travis-ci]
-repository = "pest-parser/pest"
+[features]
+default = ["std"]
+std = ["pest/std"]
diff --git a/vendor/pest_generator/_README.md b/vendor/pest_generator/_README.md
index 8e55f29a2..f91188ccb 100644
--- a/vendor/pest_generator/_README.md
+++ b/vendor/pest_generator/_README.md
@@ -1,3 +1,4 @@
+
<p align="center">
<img src="https://raw.github.com/pest-parser/pest/master/pest-logo.svg?sanitize=true" width="80%"/>
</p>
@@ -8,9 +9,10 @@
[![Book](https://img.shields.io/badge/book-WIP-4d76ae.svg)](https://pest-parser.github.io/book)
[![Docs](https://docs.rs/pest/badge.svg)](https://docs.rs/pest)
-[![Build Status](https://travis-ci.org/pest-parser/pest.svg?branch=master)](https://travis-ci.org/pest-parser/pest)
+[![pest Continuous Integration](https://github.com/pest-parser/pest/actions/workflows/ci.yml/badge.svg)](https://github.com/pest-parser/pest/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/pest-parser/pest/branch/master/graph/badge.svg)](https://codecov.io/gh/pest-parser/pest)
-[![Fuzzit Status](https://app.fuzzit.dev/badge?org_id=pest-parser)](https://app.fuzzit.dev/orgs/pest-parser/dashboard)
+<a href="https://blog.rust-lang.org/2021/11/01/Rust-1.56.1.html"><img alt="Rustc Version 1.56.1+" src="https://img.shields.io/badge/rustc-1.56.1%2B-lightgrey.svg"/></a>
+
[![Crates.io](https://img.shields.io/crates/d/pest.svg)](https://crates.io/crates/pest)
[![Crates.io](https://img.shields.io/crates/v/pest.svg)](https://crates.io/crates/pest)
@@ -38,7 +40,7 @@ Other helpful resources:
## Example
-The following is an example of a grammar for a list of alpha-numeric identifiers
+The following is an example of a grammar for a list of alphanumeric identifiers
where the first identifier does not start with a digit:
```rust
@@ -143,16 +145,18 @@ Digit: 2
* [pest_meta](https://github.com/pest-parser/pest/blob/master/meta/src/grammar.pest) (bootstrapped)
* [AshPaper](https://github.com/shnewto/ashpaper)
* [brain](https://github.com/brain-lang/brain)
-* [Chelone](https://github.com/Aaronepower/chelone)
+* [cicada](https://github.com/mitnk/cicada)
* [comrak](https://github.com/kivikakk/comrak)
* [elastic-rs](https://github.com/cch123/elastic-rs)
* [graphql-parser](https://github.com/Keats/graphql-parser)
* [handlebars-rust](https://github.com/sunng87/handlebars-rust)
* [hexdino](https://github.com/Luz/hexdino)
* [Huia](https://gitlab.com/jimsy/huia/)
+* [insta](https://github.com/mitsuhiko/insta)
* [jql](https://github.com/yamafaktory/jql)
* [json5-rs](https://github.com/callum-oakley/json5-rs)
* [mt940](https://github.com/svenstaro/mt940-rs)
+* [Myoxine](https://github.com/d3bate/myoxine)
* [py_literal](https://github.com/jturner314/py_literal)
* [rouler](https://github.com/jarcane/rouler)
* [RuSh](https://github.com/lwandrebeck/RuSh)
@@ -162,6 +166,17 @@ Digit: 2
* [ui_gen](https://github.com/emoon/ui_gen)
* [ukhasnet-parser](https://github.com/adamgreig/ukhasnet-parser)
* [ZoKrates](https://github.com/ZoKrates/ZoKrates)
+* [Vector](https://github.com/timberio/vector)
+* [AutoCorrect](https://github.com/huacnlee/autocorrect)
+* [yaml-peg](https://github.com/aofdev/yaml-peg)
+* [qubit](https://github.com/abhimanyu003/qubit)
+* [caith](https://github.com/Geobert/caith) (a dice roller crate)
+* [Melody](https://github.com/yoav-lavi/melody)
+
+## Minimum Supported Rust Version (MSRV)
+
+This library should always compile with default features on **Rust 1.56.1**
+or **Rust 1.61** with `const_prec_climber`.
## Special thanks
diff --git a/vendor/pest_generator/src/generator.rs b/vendor/pest_generator/src/generator.rs
index bed56f34a..0d3051e27 100644
--- a/vendor/pest_generator/src/generator.rs
+++ b/vendor/pest_generator/src/generator.rs
@@ -17,7 +17,6 @@ use pest_meta::ast::*;
use pest_meta::optimizer::*;
use pest_meta::UNICODE_PROPERTY_NAMES;
-#[allow(clippy::needless_pass_by_value)]
pub fn generate(
name: Ident,
generics: &Generics,
@@ -52,17 +51,20 @@ pub fn generate(
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+ let result = result_type();
+
let parser_impl = quote! {
#[allow(clippy::all)]
impl #impl_generics ::pest::Parser<Rule> for #name #ty_generics #where_clause {
fn parse<'i>(
rule: Rule,
input: &'i str
- ) -> ::std::result::Result<
+ ) -> #result<
::pest::iterators::Pairs<'i, Rule>,
::pest::error::Error<Rule>
> {
mod rules {
+ #![allow(clippy::upper_case_acronyms)]
pub mod hidden {
use super::super::Rule;
#skip
@@ -98,7 +100,7 @@ fn generate_builtin_rules() -> Vec<(&'static str, TokenStream)> {
let mut builtins = Vec::new();
insert_builtin!(builtins, ANY, state.skip(1));
- insert_public_builtin!(
+ insert_builtin!(
builtins,
EOI,
state.rule(Rule::EOI, |state| state.end_of_input())
@@ -149,13 +151,15 @@ fn generate_builtin_rules() -> Vec<(&'static str, TokenStream)> {
.or_else(|state| state.match_string("\r"))
);
+ let box_ty = box_type();
+
for property in UNICODE_PROPERTY_NAMES {
let property_ident: Ident = syn::parse_str(property).unwrap();
// insert manually for #property substitution
builtins.push((property, quote! {
#[inline]
#[allow(dead_code, non_snake_case, unused_variables)]
- fn #property_ident(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ fn #property_ident(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.match_char_by(::pest::unicode::#property_ident)
}
}));
@@ -183,7 +187,7 @@ fn generate_enum(rules: &[OptimizedRule], uses_eoi: bool) -> TokenStream {
.map(|rule| Ident::new(rule.name.as_str(), Span::call_site()));
if uses_eoi {
quote! {
- #[allow(dead_code, non_camel_case_types)]
+ #[allow(dead_code, non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Rule {
EOI,
@@ -192,7 +196,7 @@ fn generate_enum(rules: &[OptimizedRule], uses_eoi: bool) -> TokenStream {
}
} else {
quote! {
- #[allow(dead_code, non_camel_case_types)]
+ #[allow(dead_code, non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Rule {
#( #rules ),*
@@ -239,11 +243,13 @@ fn generate_rule(rule: OptimizedRule) -> TokenStream {
generate_expr(rule.expr)
};
+ let box_ty = box_type();
+
match rule.ty {
RuleType::Normal => quote! {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn #name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn #name(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.rule(Rule::#name, |state| {
#expr
})
@@ -252,14 +258,14 @@ fn generate_rule(rule: OptimizedRule) -> TokenStream {
RuleType::Silent => quote! {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn #name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn #name(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
#expr
}
},
RuleType::Atomic => quote! {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn #name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn #name(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.rule(Rule::#name, |state| {
state.atomic(::pest::Atomicity::Atomic, |state| {
#expr
@@ -270,7 +276,7 @@ fn generate_rule(rule: OptimizedRule) -> TokenStream {
RuleType::CompoundAtomic => quote! {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn #name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn #name(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
state.rule(Rule::#name, |state| {
#expr
@@ -281,7 +287,7 @@ fn generate_rule(rule: OptimizedRule) -> TokenStream {
RuleType::NonAtomic => quote! {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn #name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn #name(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.atomic(::pest::Atomicity::NonAtomic, |state| {
state.rule(Rule::#name, |state| {
#expr
@@ -619,13 +625,38 @@ struct QuoteOption<T>(Option<T>);
impl<T: ToTokens> ToTokens for QuoteOption<T> {
fn to_tokens(&self, tokens: &mut TokenStream) {
+ let option = option_type();
tokens.append_all(match self.0 {
- Some(ref t) => quote! { ::std::option::Option::Some(#t) },
- None => quote! { ::std::option::Option::None },
+ Some(ref t) => quote! { #option::Some(#t) },
+ None => quote! { #option::None },
});
}
}
+fn box_type() -> TokenStream {
+ #[cfg(feature = "std")]
+ quote! { ::std::boxed::Box }
+
+ #[cfg(not(feature = "std"))]
+ quote! { ::alloc::boxed::Box }
+}
+
+fn result_type() -> TokenStream {
+ #[cfg(feature = "std")]
+ quote! { ::std::result::Result }
+
+ #[cfg(not(feature = "std"))]
+ quote! { ::core::result::Result }
+}
+
+fn option_type() -> TokenStream {
+ #[cfg(feature = "std")]
+ quote! { ::std::option::Option }
+
+ #[cfg(not(feature = "std"))]
+ quote! { ::core::option::Option }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -641,7 +672,7 @@ mod tests {
assert_eq!(
generate_enum(&rules, false).to_string(),
quote! {
- #[allow(dead_code, non_camel_case_types)]
+ #[allow(dead_code, non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Rule {
f
@@ -935,6 +966,8 @@ mod tests {
expr: OptimizedExpr::Str("b".to_owned()),
}];
let defaults = vec!["ANY"];
+ let result = result_type();
+ let box_ty = box_type();
let mut current_dir = std::env::current_dir().expect("Unable to get current directory");
current_dir.push("test.pest");
let test_path = current_dir.to_str().expect("path contains invalid unicode");
@@ -944,7 +977,7 @@ mod tests {
#[allow(non_upper_case_globals)]
const _PEST_GRAMMAR_MyParser: &'static str = include_str!(#test_path);
- #[allow(dead_code, non_camel_case_types)]
+ #[allow(dead_code, non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Rule {
a
@@ -955,17 +988,18 @@ mod tests {
fn parse<'i>(
rule: Rule,
input: &'i str
- ) -> ::std::result::Result<
+ ) -> #result<
::pest::iterators::Pairs<'i, Rule>,
::pest::error::Error<Rule>
> {
mod rules {
+ #![allow(clippy::upper_case_acronyms)]
pub mod hidden {
use super::super::Rule;
#[inline]
#[allow(dead_code, non_snake_case, unused_variables)]
- pub fn skip(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn skip(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
Ok(state)
}
}
@@ -975,13 +1009,13 @@ mod tests {
#[inline]
#[allow(non_snake_case, unused_variables)]
- pub fn a(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn a(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.match_string("b")
}
#[inline]
#[allow(dead_code, non_snake_case, unused_variables)]
- pub fn ANY(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn ANY(state: #box_ty<::pest::ParserState<Rule>>) -> ::pest::ParseResult<#box_ty<::pest::ParserState<Rule>>> {
state.skip(1)
}
}
diff --git a/vendor/pest_generator/src/macros.rs b/vendor/pest_generator/src/macros.rs
index 9d02725da..37ef531f3 100644
--- a/vendor/pest_generator/src/macros.rs
+++ b/vendor/pest_generator/src/macros.rs
@@ -13,30 +13,26 @@ macro_rules! insert_builtin {
};
}
-macro_rules! insert_public_builtin {
- ($builtin: expr, $name: ident, $pattern: expr) => {
- $builtin.push((stringify!($name), generate_public_rule!($name, $pattern)));
- };
-}
-
+#[cfg(feature = "std")]
macro_rules! generate_rule {
($name: ident, $pattern: expr) => {
quote! {
#[inline]
#[allow(dead_code, non_snake_case, unused_variables)]
- pub fn $name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn $name(state: ::std::boxed::Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<::std::boxed::Box<::pest::ParserState<Rule>>> {
$pattern
}
}
}
}
-macro_rules! generate_public_rule {
+#[cfg(not(feature = "std"))]
+macro_rules! generate_rule {
($name: ident, $pattern: expr) => {
quote! {
#[inline]
#[allow(dead_code, non_snake_case, unused_variables)]
- pub fn $name(state: Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+ pub fn $name(state: ::alloc::boxed::Box<::pest::ParserState<Rule>>) -> ::pest::ParseResult<::alloc::boxed::Box<::pest::ParserState<Rule>>> {
$pattern
}
}