diff --git a/core/src/typed/template/mod.rs b/core/src/typed/template/mod.rs index 79ba5d6..d1e58bf 100644 --- a/core/src/typed/template/mod.rs +++ b/core/src/typed/template/mod.rs @@ -460,11 +460,12 @@ impl EmptyPairContainer for Negative {} /// Match any character. #[derive(Clone, Hash, PartialEq, Eq)] -pub struct ANY { +#[allow(non_camel_case_types)] +pub struct any { /// Matched character. pub content: char, } -impl<'i, R: RuleType> TypedNode<'i, R> for ANY { +impl<'i, R: RuleType> TypedNode<'i, R> for any { #[inline] fn try_parse_with_partial( mut input: Position<'i>, @@ -492,12 +493,12 @@ impl<'i, R: RuleType> TypedNode<'i, R> for ANY { } } } -impl Debug for ANY { +impl Debug for any { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("ANY").field(&self.content).finish() } } -impl EmptyPairContainer for ANY {} +impl EmptyPairContainer for any {} /// Never matches. #[derive(Clone, Debug, Hash, PartialEq, Eq)] @@ -555,8 +556,9 @@ impl EmptyPairContainer for Empty {} /// Match the start of input. #[derive(Clone, Debug, Hash, PartialEq, Eq)] -pub struct SOI; -impl<'i, R: RuleType> TypedNode<'i, R> for SOI { +#[allow(non_camel_case_types)] +pub struct soi; +impl<'i, R: RuleType> TypedNode<'i, R> for soi { #[inline] fn try_parse_with_partial( input: Position<'i>, @@ -582,14 +584,15 @@ impl<'i, R: RuleType> TypedNode<'i, R> for SOI { } } } -impl EmptyPairContainer for SOI {} +impl EmptyPairContainer for soi {} /// Match the end of input. /// -/// [`EOI`] will record its rule if not matched. +/// [`eoi`] will record its rule if not matched. #[derive(Clone, Debug, Hash, PartialEq, Eq)] -pub struct EOI; -impl<'i, R: RuleType> TypedNode<'i, R> for EOI { +#[allow(non_camel_case_types)] +pub struct eoi; +impl<'i, R: RuleType> TypedNode<'i, R> for eoi { #[inline] fn try_parse_with_partial( input: Position<'i>, @@ -615,7 +618,7 @@ impl<'i, R: RuleType> TypedNode<'i, R> for EOI { } } } -impl EmptyPairContainer for EOI {} +impl EmptyPairContainer for eoi {} /// Type of eol. #[derive(Clone, Debug, Hash, PartialEq, Eq)] @@ -631,11 +634,12 @@ pub enum NewLineType { /// Match a new line character. /// A built-in rule. Equivalent to `"\r\n" | "\n" | "\r"`. #[derive(Clone, Hash, PartialEq, Eq)] -pub struct NEWLINE { +#[allow(non_camel_case_types)] +pub struct newline { /// Type of matched character. pub content: NewLineType, } -impl<'i, R: RuleType> TypedNode<'i, R> for NEWLINE { +impl<'i, R: RuleType> TypedNode<'i, R> for newline { #[inline] fn try_parse_with_partial( mut input: Position<'i>, @@ -666,22 +670,22 @@ impl<'i, R: RuleType> TypedNode<'i, R> for NEWLINE { } } } -impl Debug for NEWLINE { +impl Debug for newline { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("NEWLINE").field(&self.content).finish() } } -impl EmptyPairContainer for NEWLINE {} +impl EmptyPairContainer for newline {} /// Peek all spans in stack reversely. /// Will consume input. #[allow(non_camel_case_types)] #[derive(Clone, Hash, PartialEq, Eq)] -pub struct PEEK_ALL<'i> { +pub struct peek_all<'i> { /// Pair span. pub span: Span<'i>, } -impl<'i, R: RuleType> TypedNode<'i, R> for PEEK_ALL<'i> { +impl<'i, R: RuleType> TypedNode<'i, R> for peek_all<'i> { #[inline] fn try_parse_with_partial( input: Position<'i>, @@ -703,26 +707,27 @@ impl<'i, R: RuleType> TypedNode<'i, R> for PEEK_ALL<'i> { Some(input) } } -impl<'i> Debug for PEEK_ALL<'i> { +impl<'i> Debug for peek_all<'i> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("PEEK_ALL").field(&self.span).finish() } } -impl<'i> EmptyPairContainer for PEEK_ALL<'i> {} +impl<'i> EmptyPairContainer for peek_all<'i> {} /// Peek top span in stack. /// Will consume input. #[derive(Clone, Hash, PartialEq, Eq)] -pub struct PEEK<'i> { +#[allow(non_camel_case_types)] +pub struct peek<'i> { /// Pair span. pub span: Span<'i>, } -impl<'i> From> for PEEK<'i> { +impl<'i> From> for peek<'i> { fn from(span: Span<'i>) -> Self { Self { span } } } -impl<'i, R: RuleType> TypedNode<'i, R> for PEEK<'i> { +impl<'i, R: RuleType> TypedNode<'i, R> for peek<'i> { #[inline] fn try_parse_with_partial( mut input: Position<'i>, @@ -759,19 +764,20 @@ impl<'i, R: RuleType> TypedNode<'i, R> for PEEK<'i> { } } } -impl<'i> Debug for PEEK<'i> { +impl<'i> Debug for peek<'i> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("PEEK").field(&self.span).finish() } } -impl<'i> EmptyPairContainer for PEEK<'i> {} +impl<'i> EmptyPairContainer for peek<'i> {} /// Drop the top of the stack. /// /// Fail if there is no span in the stack. #[derive(Clone, Debug, Hash, PartialEq, Eq)] -pub struct DROP; -impl<'i, R: RuleType> TypedNode<'i, R> for DROP { +#[allow(non_camel_case_types)] +pub struct drop; +impl<'i, R: RuleType> TypedNode<'i, R> for drop { #[inline] fn try_parse_with_partial( input: Position<'i>, @@ -801,21 +807,22 @@ impl<'i, R: RuleType> TypedNode<'i, R> for DROP { } } } -impl EmptyPairContainer for DROP {} +impl EmptyPairContainer for drop {} /// Match and pop the top span of the stack. #[derive(Clone, Hash, PartialEq, Eq)] -pub struct POP<'i> { +#[allow(non_camel_case_types)] +pub struct pop<'i> { /// Matched span. pub span: Span<'i>, } -impl<'i> From> for POP<'i> { +impl<'i> From> for pop<'i> { fn from(span: Span<'i>) -> Self { Self { span } } } -impl<'i, R: RuleType> TypedNode<'i, R> for POP<'i> { +impl<'i, R: RuleType> TypedNode<'i, R> for pop<'i> { #[inline] fn try_parse_with_partial( mut input: Position<'i>, @@ -851,33 +858,33 @@ impl<'i, R: RuleType> TypedNode<'i, R> for POP<'i> { } } } -impl<'i> Debug for POP<'i> { +impl<'i> Debug for pop<'i> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("POP").field(&self.span).finish() } } -impl<'i> EmptyPairContainer for POP<'i> {} +impl<'i> EmptyPairContainer for pop<'i> {} /// Match and pop all spans in the stack in top-to-bottom-order. #[allow(non_camel_case_types)] #[derive(Clone, Hash, PartialEq, Eq)] -pub struct POP_ALL<'i> { +pub struct pop_all<'i> { /// Matched span. pub span: Span<'i>, } -impl<'i> From> for POP_ALL<'i> { +impl<'i> From> for pop_all<'i> { fn from(span: Span<'i>) -> Self { Self { span } } } -impl<'i, R: RuleType> TypedNode<'i, R> for POP_ALL<'i> { +impl<'i, R: RuleType> TypedNode<'i, R> for pop_all<'i> { #[inline] fn try_parse_with_partial( input: Position<'i>, stack: &mut Stack>, tracker: &mut Tracker<'i, R>, ) -> Option<(Position<'i>, Self)> { - let (input, res) = PEEK_ALL::try_parse_with_partial(input, stack, tracker)?; + let (input, res) = peek_all::try_parse_with_partial(input, stack, tracker)?; while stack.pop().is_some() {} Some((input, Self::from(res.span))) } @@ -887,30 +894,31 @@ impl<'i, R: RuleType> TypedNode<'i, R> for POP_ALL<'i> { stack: &mut Stack>, tracker: &mut Tracker<'i, R>, ) -> Option> { - let input = PEEK_ALL::check_with_partial(input, stack, tracker)?; + let input = peek_all::check_with_partial(input, stack, tracker)?; while stack.pop().is_some() {} Some(input) } } -impl<'i> Debug for POP_ALL<'i> { +impl<'i> Debug for pop_all<'i> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("POP_ALL").field(&self.span).finish() } } -impl<'i> EmptyPairContainer for POP_ALL<'i> {} +impl<'i> EmptyPairContainer for pop_all<'i> {} /// Match an expression and push it to the [Stack]. #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct PUSH { +#[allow(non_camel_case_types)] +pub struct push { /// Matched content. pub content: T, } -impl From for PUSH { +impl From for push { fn from(content: T) -> Self { Self { content } } } -impl<'i, R: RuleType, T: TypedNode<'i, R>> TypedNode<'i, R> for PUSH { +impl<'i, R: RuleType, T: TypedNode<'i, R>> TypedNode<'i, R> for push { #[inline] fn try_parse_with_partial( input: Position<'i>, @@ -934,23 +942,23 @@ impl<'i, R: RuleType, T: TypedNode<'i, R>> TypedNode<'i, R> for PUSH { Some(input) } } -impl Deref for PUSH { +impl Deref for push { type Target = T; fn deref(&self) -> &Self::Target { &self.content } } -impl DerefMut for PUSH { +impl DerefMut for push { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.content } } -impl Debug for PUSH { +impl Debug for push { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("PUSH").field(&self.content).finish() } } -impl> PairContainer for PUSH { +impl> PairContainer for push { fn for_each_child_pair(&self, f: &mut impl FnMut(crate::token::Pair)) { self.content.for_self_or_for_each_child_pair(f) } @@ -1017,44 +1025,44 @@ impl EmptyPairContainer for PeekSlice1 {} /// ASCII Digit. `'0'..'9'` #[allow(non_camel_case_types)] -pub type ASCII_DIGIT = CharRange<'0', '9'>; +pub type ascii_digit = CharRange<'0', '9'>; /// Non-zero ASCII Digit. `'1'..'9'` #[allow(non_camel_case_types)] -pub type ASCII_NONZERO_DIGIT = CharRange<'1', '9'>; +pub type ascii_nonzero_digit = CharRange<'1', '9'>; /// Binary ASCII Digit. `'0'..'1'` #[allow(non_camel_case_types)] -pub type ASCII_BIN_DIGIT = CharRange<'0', '1'>; +pub type ascii_bin_digit = CharRange<'0', '1'>; /// Octal ASCII Digit. `'0'..'7'` #[allow(non_camel_case_types)] -pub type ASCII_OCT_DIGIT = CharRange<'0', '7'>; +pub type ascii_oct_digit = CharRange<'0', '7'>; use crate::choice::{Choice2, Choice3}; /// Hexadecimal ASCII Digit. `'0'..'9' | 'a'..'f' | 'A'..'F'` #[allow(non_camel_case_types)] -pub type ASCII_HEX_DIGIT = Choice3, CharRange<'A', 'F'>>; +pub type ascii_hex_digit = Choice3, CharRange<'A', 'F'>>; /// Lower case ASCII alphabet. #[allow(non_camel_case_types)] -pub type ASCII_ALPHA_LOWER = CharRange<'a', 'z'>; +pub type ascii_alpha_lower = CharRange<'a', 'z'>; /// Upper case ASCII alphabet. #[allow(non_camel_case_types)] -pub type ASCII_ALPHA_UPPER = CharRange<'A', 'Z'>; +pub type ascii_alpha_upper = CharRange<'A', 'Z'>; /// ASCII alphabet. #[allow(non_camel_case_types)] -pub type ASCII_ALPHA = Choice2; +pub type ascii_alpha = Choice2; /// ASCII alphabet or digit. #[allow(non_camel_case_types)] -pub type ASCII_ALPHANUMERIC = Choice2; +pub type ascii_alphanumeric = Choice2; /// ASCII alphabet. #[allow(non_camel_case_types)] -pub type ASCII = CharRange<'\x00', '\x7f'>; +pub type ascii = CharRange<'\x00', '\x7f'>; /// Match char by a predicate. /// diff --git a/core/src/typed/traits.rs b/core/src/typed/traits.rs index bc54e9f..870fccb 100644 --- a/core/src/typed/traits.rs +++ b/core/src/typed/traits.rs @@ -1,4 +1,4 @@ -use super::template::EOI; +use super::template::eoi; use crate::{error::Error, token::Pair, typed::tracker::Tracker, Position, Span}; use core::{fmt::Debug, hash::Hash}; use pest2::Stack; @@ -29,7 +29,7 @@ pub trait TypedNode<'i, R: RuleType>: Sized { let (input, res) = Self::try_parse_with_partial(input, stack, tracker)?; let (_input, _eoi) = tracker.record_option_during_with( input, - |tracker| EOI::try_parse_with_partial(input, stack, tracker), + |tracker| eoi::try_parse_with_partial(input, stack, tracker), ::EOI, )?; Some(res) @@ -70,7 +70,7 @@ pub trait TypedNode<'i, R: RuleType>: Sized { }; let _input = match tracker.record_option_during_with( input, - |tracker| EOI::check_with_partial(input, stack, tracker), + |tracker| eoi::check_with_partial(input, stack, tracker), ::EOI, ) { Some(input) => input, diff --git a/derive/tests/calc.pest b/derive/tests/calc.pest index e4c433d..cc7f2f4 100644 --- a/derive/tests/calc.pest +++ b/derive/tests/calc.pest @@ -2,7 +2,7 @@ use common::base as common ~ = common::whitespaces* -program = pest::SOI ~ expr ~ pest::EOI +program = pest::soi ~ expr ~ pest::eoi expr = prefix* ~ primary ~ postfix* ~ (infix ~ prefix* ~ primary ~ postfix* )* infix = _{ add | sub | mul | div | pow } add = "+" // Addition diff --git a/derive/tests/grammar.pest b/derive/tests/grammar.pest index da265d1..5f70e76 100644 --- a/derive/tests/grammar.pest +++ b/derive/tests/grammar.pest @@ -35,7 +35,7 @@ repeat_min = string~{2..} repeat_min_atomic = string{2..} repeat_max = string~{..2} repeat_max_atomic = string{..2} -soi_at_start = pest::SOI - string +soi_at_start = pest::soi - string repeat_mutate_stack = (pest::stack::push('a'..'c') - ",")* - pest::stack::pop - pest::stack::pop - pest::stack::pop repeat_mutate_stack_pop_all = (pest::stack::push('a'..'c') - ",")* - pest::stack::pop_all will_fail = repeat_mutate_stack_pop_all - "FAIL" @@ -46,7 +46,7 @@ peek_slice_23 = pest::stack::push(range) - pest::stack::push(range) - pest::stac pop_ = pest::stack::push(range) - pest::stack::push(range) - pest::stack::pop - pest::stack::pop pop_all = pest::stack::push(range) - pest::stack::push(range) - pest::stack::pop_all pop_fail = pest::stack::push(range) - !pest::stack::pop - range - pest::stack::pop -checkpoint_restore = pest::stack::push("") - (pest::stack::push("a") - "b" - pest::stack::pop | pest::stack::drop - "b" | pest::stack::pop - "a") - pest::EOI +checkpoint_restore = pest::stack::push("") - (pest::stack::push("a") - "b" - pest::stack::pop | pest::stack::drop - "b" | pest::stack::pop - "a") - pest::eoi longchoice_builtin = ( "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16") longseq_builtin = ( "01" ~ "02" ~ "03" ~ "04" ~ "05" ~ "06" ~ "07" ~ "08" ~ "09" ~ "10" ~ "11" ~ "12" ~ "13" ~ "14" ~ "15" ~ "16") longchoice_critical = ( "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17") diff --git a/derive/tests/json.pest b/derive/tests/json.pest index 8108679..30ce690 100644 --- a/derive/tests/json.pest +++ b/derive/tests/json.pest @@ -8,7 +8,7 @@ // FIXME: some should be under pest::* use common::base as p -json = pest::SOI ~ value ~ pest::EOI +json = pest::soi ~ value ~ pest::eoi /// Matches object, e.g.: `{ "foo": "bar" }` /// Foobar diff --git a/derive/tests/skip.rs b/derive/tests/skip.rs index 566959c..92d8e3d 100644 --- a/derive/tests/skip.rs +++ b/derive/tests/skip.rs @@ -7,7 +7,7 @@ use pest3_derive::Parser; #[grammar_inline = r#" ~ = (" " | "/*" - (!"*/" - pest::any)* - "*/")* main = "x"~* -program = pest::SOI ~ main ~ pest::EOI +program = pest::soi ~ main ~ pest::eoi "#] struct Parser; diff --git a/generator/src/typed/module.rs b/generator/src/typed/module.rs index 2f34d4b..7911490 100644 --- a/generator/src/typed/module.rs +++ b/generator/src/typed/module.rs @@ -306,8 +306,6 @@ impl<'g> ModuleSystem<'g> { .collect(), ); let pest = HashMap::from([ - pest_builtin!(SOI {}), - pest_builtin!(EOI {}), pest_builtin!(soi {}), pest_builtin!(eoi {}), pest_builtin!(any {}), diff --git a/generator/src/typed/output.rs b/generator/src/typed/output.rs index 10a2491..1bce852 100644 --- a/generator/src/typed/output.rs +++ b/generator/src/typed/output.rs @@ -148,28 +148,26 @@ impl<'g> Tracker<'g> { Positive, Negative, CharRange, Str, Insens, Rep, RepOnce, RepMin, RepMax, RepMinMax, - SOI, EOI, - SOI as soi, - EOI as eoi, - ANY as any, - PEEK as peek, + soi, eoi, + any, + peek, PeekSlice1, PeekSlice2, - PEEK_ALL as peek_all, - DROP as drop, - PUSH as push, - POP as pop, - POP_ALL as pop_all, - ASCII_DIGIT as ascii_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, - ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_OCT_DIGIT as ascii_oct_digit, - ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, - ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, - ASCII as ascii, - NEWLINE as newline, + peek_all, + drop, + push, + pop, + pop_all, + ascii_digit, + ascii_nonzero_digit, + ascii_bin_digit, + ascii_oct_digit, + ascii_hex_digit, + ascii_alpha_lower, + ascii_alpha_upper, + ascii_alpha, + ascii_alphanumeric, + ascii, + newline, }; #(#seq)* #(#chs)* diff --git a/generator/tests/expected.rs b/generator/tests/expected.rs index de3a8b1..4865285 100644 --- a/generator/tests/expected.rs +++ b/generator/tests/expected.rs @@ -1296,7 +1296,7 @@ pub mod rules { (self.span.start(), self.span.end()) } } - #[doc = "Generated for rule `Pos`. Grammar: `&(pest::SOI ~ RepLeftRight[2..4])`."] + #[doc = "Generated for rule `Pos`. Grammar: `&(pest::soi ~ RepLeftRight[2..4])`."] #[derive(Clone, Debug, Eq, PartialEq)] #[allow(non_camel_case_types)] pub struct r#Pos<'i> { @@ -1304,7 +1304,7 @@ pub mod rules { pub content: ::pest3_core::std::Box< super::generics::Positive< super::generics::Sequence2< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, super::generics::RepMinMax< r#RepLeftRight<'i>, @@ -1342,9 +1342,9 @@ pub mod rules { } } } - #[doc = "A helper function to access [`SOI`]."] + #[doc = "A helper function to access [`soi`]."] #[allow(non_snake_case)] - pub fn r#SOI<'s>(&'s self) -> &'s super::generics::r#SOI { + pub fn r#soi<'s>(&'s self) -> &'s super::generics::r#soi { let res = &*self.content; { let res = &res.field_0; @@ -1361,7 +1361,7 @@ pub mod rules { super::Rule::r#Pos, super::generics::Positive::< super::generics::Sequence2::< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, super::generics::RepMinMax::< r#RepLeftRight::<'i>, @@ -1375,7 +1375,7 @@ pub mod rules { ::pest3_core::std::Box< super::generics::Positive::< super::generics::Sequence2::< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, super::generics::RepMinMax::< r#RepLeftRight::<'i>, @@ -1415,7 +1415,7 @@ pub mod rules { (self.span.start(), self.span.end()) } } - #[doc = "Generated for rule `Neg`. Grammar: `!(pest::EOI ~ Pos)`."] + #[doc = "Generated for rule `Neg`. Grammar: `!(pest::eoi ~ Pos)`."] #[derive(Clone, Debug, Eq, PartialEq)] #[allow(non_camel_case_types)] pub struct r#Neg<'i> { @@ -1423,7 +1423,7 @@ pub mod rules { pub content: ::pest3_core::std::Box< super::generics::Negative< super::generics::Sequence2< - super::generics::r#EOI, + super::generics::r#eoi, ::pest3_core::typed::template::Empty, r#Pos<'i>, __OptionalTrivia<'i>, @@ -1449,7 +1449,7 @@ pub mod rules { super::Rule::r#Neg, super::generics::Negative::< super::generics::Sequence2::< - super::generics::r#EOI, + super::generics::r#eoi, ::pest3_core::typed::template::Empty, r#Pos::<'i>, __OptionalTrivia::<'i>, @@ -1458,7 +1458,7 @@ pub mod rules { ::pest3_core::std::Box< super::generics::Negative::< super::generics::Sequence2::< - super::generics::r#EOI, + super::generics::r#eoi, ::pest3_core::typed::template::Empty, r#Pos::<'i>, __OptionalTrivia::<'i>, @@ -2251,13 +2251,9 @@ pub mod generics { pub use pest3_core::sequence::Sequence4; pub use pest3_core::sequence::Sequence7; pub use pest3_core::typed::template::{ - CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, - RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit, - DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all, - POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi, + any, ascii, ascii_alpha, ascii_alpha_lower, ascii_alpha_upper, ascii_alphanumeric, + ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit, drop, + eoi, newline, peek, peek_all, pop, pop_all, push, soi, CharRange, Insens, Negative, + PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, RepMinMax, RepOnce, Str, }; } diff --git a/generator/tests/expected_import_dag.rs b/generator/tests/expected_import_dag.rs index 649d014..f733e56 100644 --- a/generator/tests/expected_import_dag.rs +++ b/generator/tests/expected_import_dag.rs @@ -2884,13 +2884,9 @@ pub mod generics { pub use pest3_core::sequence::Sequence2; pub use pest3_core::sequence::Sequence3; pub use pest3_core::typed::template::{ - CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, - RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit, - DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all, - POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi, + any, ascii, ascii_alpha, ascii_alpha_lower, ascii_alpha_upper, ascii_alphanumeric, + ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit, drop, + eoi, newline, peek, peek_all, pop, pop_all, push, soi, CharRange, Insens, Negative, + PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, RepMinMax, RepOnce, Str, }; } diff --git a/generator/tests/expected_import_inline.rs b/generator/tests/expected_import_inline.rs index 83ad313..0232d3f 100644 --- a/generator/tests/expected_import_inline.rs +++ b/generator/tests/expected_import_inline.rs @@ -642,13 +642,9 @@ pub mod generics { pub use pest3_core::choice::Choice2; pub use pest3_core::sequence::Sequence2; pub use pest3_core::typed::template::{ - CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, - RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit, - DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all, - POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi, + any, ascii, ascii_alpha, ascii_alpha_lower, ascii_alpha_upper, ascii_alphanumeric, + ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit, drop, + eoi, newline, peek, peek_all, pop, pop_all, push, soi, CharRange, Insens, Negative, + PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, RepMinMax, RepOnce, Str, }; } diff --git a/generator/tests/expected_json.rs b/generator/tests/expected_json.rs index ebc2d0e..81d8d29 100644 --- a/generator/tests/expected_json.rs +++ b/generator/tests/expected_json.rs @@ -853,18 +853,18 @@ pub mod rules { super::Rule::p(self) } } - #[doc = "Generated for rule `json`. Grammar: `(pest::SOI ~ (value ~ pest::EOI))`."] + #[doc = "Generated for rule `json`. Grammar: `(pest::soi ~ (value ~ pest::eoi))`."] #[derive(Clone, Debug, Eq, PartialEq)] #[allow(non_camel_case_types)] pub struct r#json<'i> { #[doc = r" Matched structure."] pub content: ::pest3_core::std::Box< super::generics::Sequence3< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, r#value<'i>, __OptionalTrivia<'i>, - super::generics::r#EOI, + super::generics::r#eoi, __OptionalTrivia<'i>, >, >, @@ -878,18 +878,18 @@ pub mod rules { } #[allow(non_camel_case_types)] impl<'i> r#json<'i> { - #[doc = "A helper function to access [`EOI`]."] + #[doc = "A helper function to access [`eoi`]."] #[allow(non_snake_case)] - pub fn r#EOI<'s>(&'s self) -> &'s super::generics::r#EOI { + pub fn r#eoi<'s>(&'s self) -> &'s super::generics::r#eoi { let res = &*self.content; { let res = &res.field_2; res } } - #[doc = "A helper function to access [`SOI`]."] + #[doc = "A helper function to access [`soi`]."] #[allow(non_snake_case)] - pub fn r#SOI<'s>(&'s self) -> &'s super::generics::r#SOI { + pub fn r#soi<'s>(&'s self) -> &'s super::generics::r#soi { let res = &*self.content; { let res = &res.field_0; @@ -914,20 +914,20 @@ pub mod rules { super::Rule, super::Rule::r#json, super::generics::Sequence3::< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, r#value::<'i>, __OptionalTrivia::<'i>, - super::generics::r#EOI, + super::generics::r#eoi, __OptionalTrivia::<'i>, >, ::pest3_core::std::Box< super::generics::Sequence3::< - super::generics::r#SOI, + super::generics::r#soi, ::pest3_core::typed::template::Empty, r#value::<'i>, __OptionalTrivia::<'i>, - super::generics::r#EOI, + super::generics::r#eoi, __OptionalTrivia::<'i>, >, >, @@ -2861,13 +2861,9 @@ pub mod generics { pub use pest3_core::sequence::Sequence3; pub use pest3_core::sequence::Sequence4; pub use pest3_core::typed::template::{ - CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, - RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit, - DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all, - POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi, + any, ascii, ascii_alpha, ascii_alpha_lower, ascii_alpha_upper, ascii_alphanumeric, + ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit, drop, + eoi, newline, peek, peek_all, pop, pop_all, push, soi, CharRange, Insens, Negative, + PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, RepMinMax, RepOnce, Str, }; } diff --git a/generator/tests/expected_sample.rs b/generator/tests/expected_sample.rs index 9409ada..7e6da96 100644 --- a/generator/tests/expected_sample.rs +++ b/generator/tests/expected_sample.rs @@ -6157,13 +6157,9 @@ pub mod generics { pub use pest3_core::sequence::Sequence4; pub use pest3_core::sequence::Sequence6; pub use pest3_core::typed::template::{ - CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, - RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha, - ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower, - ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit, - ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit, - ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit, - DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all, - POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi, + any, ascii, ascii_alpha, ascii_alpha_lower, ascii_alpha_upper, ascii_alphanumeric, + ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit, drop, + eoi, newline, peek, peek_all, pop, pop_all, push, soi, CharRange, Insens, Negative, + PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin, RepMinMax, RepOnce, Str, }; } diff --git a/generator/tests/syntax.pest b/generator/tests/syntax.pest index 39da322..840a8e3 100644 --- a/generator/tests/syntax.pest +++ b/generator/tests/syntax.pest @@ -25,8 +25,8 @@ RepLeft = RepExact{1..} RepRight = RepLeft{..2} RepLeftRight = RepRight{1..2} -Pos = &(pest::SOI ~ RepLeftRight{2..4}) -Neg = !(pest::EOI ~ Pos) +Pos = &(pest::soi ~ RepLeftRight{2..4}) +Neg = !(pest::eoi ~ Pos) Push = pest::stack::push(RepLeft* ~ Neg ~ ExactString+ ~ Push ~ Pop ~ Push ~ PopAll) diff --git a/pest/benches/position.rs b/pest/benches/position.rs index 7d74653..b037e35 100644 --- a/pest/benches/position.rs +++ b/pest/benches/position.rs @@ -9,7 +9,7 @@ use pest3::{ sequence::{Sequence16, Sequence2}, typed::{ template::{ - Char, CharRange, Empty, Insens, RepMinMax, SkipChar, Str, ANY, PEEK, PEEK_ALL, PUSH, + any, peek, peek_all, push, Char, CharRange, Empty, Insens, RepMinMax, SkipChar, Str, }, wrapper, RuleType, TypedNode, }, @@ -46,7 +46,7 @@ fn benchmark(b: &mut Criterion) { mod types { use super::*; - pub type any = RepMinMax; + pub type anyb = RepMinMax; pub type choices_16 = RepMinMax< Choice16< Char<'0'>, @@ -116,17 +116,17 @@ fn benchmark(b: &mut Criterion) { RepMinMax, CharRange<'a', 'f'>>, Empty, TOTAL, TOTAL>; pub type skip_fragments<'i> = RepMinMax, Empty, TIMES, TIMES>; pub type skip_all<'i> = SkipChar<'i, TOTAL>; - pub type push = RepMinMax>, Empty, TIMES, TIMES>; + pub type pushb = RepMinMax>, Empty, TIMES, TIMES>; pub type push_peek<'i> = Sequence2< - PUSH>, + push>, Empty, - RepMinMax, Empty, { TIMES - 1 }, { TIMES - 1 }>, + RepMinMax, Empty, { TIMES - 1 }, { TIMES - 1 }>, Empty, >; pub type push_peek_all<'i> = Sequence2< - PUSH>, + push>, Empty, - RepMinMax, Empty, { TIMES - 1 }, { TIMES - 1 }>, + RepMinMax, Empty, { TIMES - 1 }, { TIMES - 1 }>, Empty, >; } @@ -144,7 +144,7 @@ fn benchmark(b: &mut Criterion) { }; } test_series!( - any, + anyb, choices_16, sequence_16, range, @@ -153,7 +153,7 @@ fn benchmark(b: &mut Criterion) { insensitive_strings, skip_fragments, skip_all, - push, + pushb, push_peek, push_peek_all );