From c445b4b63924f5d40fcac0f61ee04907f571aa6c Mon Sep 17 00:00:00 2001 From: therealbnut <635596+therealbnut@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:54:59 +1100 Subject: [PATCH 1/3] proof of concept --- peg-macros/translate.rs | 28 ++++++++++++++++------------ src/lib.rs | 16 ++++++++-------- tests/run-pass/errors.rs | 25 ++++++++++++++++++++++++- tests/run-pass/keyval.rs | 4 +--- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/peg-macros/translate.rs b/peg-macros/translate.rs index 01ecc04..c64112b 100644 --- a/peg-macros/translate.rs +++ b/peg-macros/translate.rs @@ -670,7 +670,7 @@ fn compile_expr(context: &Context, e: &SpannedExpr, result_used: bool) -> TokenS let match_sep = if let Some(sep) = sep { let sep_inner = compile_expr(context, sep, false); quote_spanned! { span=> - let __pos = if __repeat_value.is_empty() { __pos } else { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = #sep_inner; match __sep_res { ::peg::RuleResult::Matched(__newpos, _) => { __newpos }, @@ -688,23 +688,24 @@ fn compile_expr(context: &Context, e: &SpannedExpr, result_used: bool) -> TokenS quote!(()) }; - let (repeat_vec, repeat_step) = - if result_used || min.is_some() || max.is_some() || sep.is_some() { - ( - Some(quote_spanned! { span => let mut __repeat_value = vec!(); }), - Some(quote_spanned! { span => __repeat_value.push(__value); }), - ) - } else { - (None, None) - }; + let (repeat_vec, repeat_step) = if result_used { + ( + Some(quote_spanned! { span => let mut __repeat_value = Default::default(); }), + Some( + quote_spanned! { span => core::iter::Extend::extend(&mut __repeat_value, Some(__value)); }, + ), + ) + } else { + (None, None) + }; let max_check = max.map(|max| { - quote_spanned! { span=> if __repeat_value.len() >= #max { break } } + quote_spanned! { span=> if __repeat_count >= #max { break } } }); let result_check = if let Some(min) = min { quote_spanned! { span=> - if __repeat_value.len() >= #min { + if __repeat_count >= #min { ::peg::RuleResult::Matched(__repeat_pos, #result) } else { ::peg::RuleResult::Failed @@ -718,6 +719,7 @@ fn compile_expr(context: &Context, e: &SpannedExpr, result_used: bool) -> TokenS let mut __repeat_pos = __pos; #repeat_vec + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -734,6 +736,8 @@ fn compile_expr(context: &Context, e: &SpannedExpr, result_used: bool) -> TokenS break; } } + + __repeat_count += 1; } #result_check diff --git a/src/lib.rs b/src/lib.rs index 7e71755..319534b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,18 +97,18 @@ //! ### Repetition //! * `expression?` - _Optional:_ match zero or one repetitions of `expression`. Returns an //! `Option`. -//! * `expression*` - _Repeat:_ match zero or more repetitions of `expression` and return the -//! results as a `Vec`. -//! * `expression+` - _One-or-more:_ match one or more repetitions of `expression` and return the -//! results as a `Vec`. +//! * `expression*` - _Repeat:_ match zero or more repetitions of `expression` and stores the +//! results in any collection implementing `Default` and `Extend`. +//! * `expression+` - _One-or-more:_ match one or more repetitions of `expression` and stores the +//! results in any collection implementing `Default` and `Extend`. //! * `expression*` - _Range repeat:_ match between `n` and `m` repetitions of `expression` -//! return the results as a `Vec`. [(details)](#repeat-ranges) +//! store the results in any collection implementing `Default` and `Extend`. [(details)](#repeat-ranges) //! * `expression ** delim` - _Delimited repeat:_ match zero or more repetitions of `expression` -//! delimited with `delim` and return the results as a `Vec`. +//! delimited with `delim` and stores the results in any collection implementing `Default` and `Extend`. //! * `expression ** delim` - _Delimited repeat (range):_ match between `n` and `m` repetitions of `expression` -//! delimited with `delim` and return the results as a `Vec`. [(details)](#repeat-ranges) +//! delimited with `delim` and stores the results in any collection implementing `Default` and `Extend`) //! * `expression ++ delim` - _Delimited repeat (one or more):_ match one or more repetitions of `expression` -//! delimited with `delim` and return the results as a `Vec`. +//! delimited with `delim` and stores the results in any collection implementing `Default` and `Extend`. //! //! ### Special //! * `$(e)` - _Slice:_ match the expression `e`, and return the slice of the input diff --git a/tests/run-pass/errors.rs b/tests/run-pass/errors.rs index 7e921cb..8680801 100644 --- a/tests/run-pass/errors.rs +++ b/tests/run-pass/errors.rs @@ -4,7 +4,10 @@ peg::parser!{ grammar parser() for str { pub rule one_letter() = ['a'..='z'] pub rule parse() -> usize - = v:( "a" / "\n" )* { v.len() } + = v:( "a" / "\n" )* { + let counter: ItemCounter = v; + counter.count() + } pub rule error_pos() = ("a" / "\n" / "\r")* @@ -15,6 +18,26 @@ peg::parser!{ grammar parser() for str { pub rule var(s: &'static str) = expected!(s) }} +struct ItemCounter { + count: usize, +} +impl Default for ItemCounter { + fn default() -> Self { + Self { count: 0 } + } +} +impl ItemCounter { + pub fn count(&self) -> usize { + self.count + } +} +impl Extend<()> for ItemCounter { + #[inline] + fn extend>(&mut self, into_iter: T) { + self.count += into_iter.into_iter().count(); + } +} + fn main() { // errors at eof assert_eq!(parser::one_letter("t"), Ok(())); diff --git a/tests/run-pass/keyval.rs b/tests/run-pass/keyval.rs index 414c79d..ebcf1f0 100644 --- a/tests/run-pass/keyval.rs +++ b/tests/run-pass/keyval.rs @@ -6,9 +6,7 @@ peg::parser!( grammar keyval() for str { = n:$(['0'..='9']+) { n.parse().unwrap() } pub rule keyvals() -> HashMap - = kvs:keyval() ++ "\n" { - kvs.iter().cloned().collect::>() - } + = kvs:keyval() ++ "\n" { kvs } rule keyval() -> (i64, i64) = k:number() ":" + v:number() { (k, v) } From 9c49d86ffeb30b109d884c24140a6de10f6fe17c Mon Sep 17 00:00:00 2001 From: therealbnut <635596+therealbnut@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:19:03 +1100 Subject: [PATCH 2/3] Fix grammar type inference and run bootstrap --- peg-macros/grammar.rs | 181 +++++++++++++++++++++---------------- peg-macros/grammar.rustpeg | 1 + 2 files changed, 104 insertions(+), 78 deletions(-) diff --git a/peg-macros/grammar.rs b/peg-macros/grammar.rs index f7debea..9b3fe83 100644 --- a/peg-macros/grammar.rs +++ b/peg-macros/grammar.rs @@ -113,7 +113,7 @@ pub mod peg { __err_state, __pos, ); - match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "for") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let str_start = __pos ; match match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , :: peg :: ParseSlice :: parse_slice (__input , str_start , __newpos)) } , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , input_type) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! () ; loop { let __pos = __repeat_pos ; let __step_res = __parse_item (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , items) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { Grammar { doc , visibility , name , lifetime_params , args , input_type , items } }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"for\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } + match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "for") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let str_start = __pos ; match match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , :: peg :: ParseSlice :: parse_slice (__input , str_start , __newpos)) } , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , input_type) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __step_res = __parse_item (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , items) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { Grammar { doc , visibility , name , lifetime_params , args , input_type , items } }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"for\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ::peg::RuleResult::Failed => { ::peg::RuleResult::Failed @@ -147,10 +147,11 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -191,14 +192,15 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) } else { ::peg::RuleResult::Failed @@ -258,10 +260,11 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -337,12 +340,13 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) }; @@ -772,10 +776,11 @@ pub mod peg { let __seq_res = match { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -832,14 +837,15 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) } else { ::peg::RuleResult::Failed @@ -943,6 +949,7 @@ pub mod peg { let str_start = __pos; match { let mut __repeat_pos = __pos; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; let __step_res = match ::peg::ParseLiteral::parse_string_literal( @@ -1005,6 +1012,7 @@ pub mod peg { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched(__repeat_pos, ()) } { @@ -1118,7 +1126,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __value) } ::peg::RuleResult::Failed => { - let __choice_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "::") { :: peg :: RuleResult :: Matched (__pos , __val) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! () ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . is_empty () { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = { let __seq_res = match __parse_IDENT (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "as") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = match __parse_IDENT (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"as\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } } if __repeat_value . len () >= 1 { :: peg :: RuleResult :: Matched (__repeat_pos , ()) } else { :: peg :: RuleResult :: Failed } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"::\"") ; :: peg :: RuleResult :: Failed } } ; + let __choice_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "::") { :: peg :: RuleResult :: Matched (__pos , __val) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = { let __seq_res = match __parse_IDENT (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "as") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = match __parse_IDENT (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"as\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } if __repeat_count >= 1 { :: peg :: RuleResult :: Matched (__repeat_pos , ()) } else { :: peg :: RuleResult :: Failed } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"::\"") ; :: peg :: RuleResult :: Failed } } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "as") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = match __parse_IDENT (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"as\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } } } } @@ -1198,10 +1206,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, _) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -1230,14 +1238,14 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -1359,10 +1367,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = @@ -1404,14 +1412,14 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -1441,10 +1449,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "+") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"+\"") ; :: peg :: RuleResult :: Failed } } ; @@ -1475,14 +1483,14 @@ pub mod peg { __value, ) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -1515,11 +1523,11 @@ pub mod peg { let __seq_res = match { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value - .is_empty() + let __pos = if __repeat_count + == 0 { __pos } else { @@ -1527,9 +1535,10 @@ pub mod peg { match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } }; let __step_res = match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; - match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } + match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; } , :: peg :: RuleResult :: Failed => { break ; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched( __repeat_pos, (), @@ -1656,10 +1665,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, _) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -1693,7 +1702,7 @@ pub mod peg { match __seq_res { ::peg::RuleResult::Matched(__pos, _) => { let __seq_res = { - let __choice_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "<") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! () ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . is_empty () { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = { let __choice_res = match __parse_LIFETIME (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => { let __choice_res = match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => { let __choice_res = match __parse_BRACE_GROUP (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => match __parse_LITERAL (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } } } } } ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } } if __repeat_value . len () >= 1 { :: peg :: RuleResult :: Matched (__repeat_pos , ()) } else { :: peg :: RuleResult :: Failed } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ">") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\">\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"<\"") ; :: peg :: RuleResult :: Failed } } ; + let __choice_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "<") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = { let __choice_res = match __parse_LIFETIME (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => { let __choice_res = match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => { let __choice_res = match __parse_BRACE_GROUP (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => match __parse_LITERAL (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } } } } } ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } if __repeat_count >= 1 { :: peg :: RuleResult :: Matched (__repeat_pos , ()) } else { :: peg :: RuleResult :: Failed } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ">") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\">\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"<\"") ; :: peg :: RuleResult :: Failed } } ; match __choice_res { ::peg::RuleResult::Matched( __pos, @@ -1752,14 +1761,14 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -1787,10 +1796,11 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -1836,14 +1846,15 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) } else { ::peg::RuleResult::Failed @@ -1903,10 +1914,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -1943,11 +1954,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() - { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "+") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"+\"") ; :: peg :: RuleResult :: Failed } } ; @@ -1984,14 +1994,14 @@ pub mod peg { __value, ) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched( __repeat_pos, (), @@ -2101,11 +2111,11 @@ pub mod peg { ) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value - .is_empty() + let __pos = if __repeat_count + == 0 { __pos } else { @@ -2116,9 +2126,10 @@ pub mod peg { let __choice_res = match __parse_LIFETIME (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __choice_res { :: peg :: RuleResult :: Matched (__pos , __value) => :: peg :: RuleResult :: Matched (__pos , __value) , :: peg :: RuleResult :: Failed => { let __seq_res = match match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "?") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"?\"") ; :: peg :: RuleResult :: Failed } } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , ()) } , :: peg :: RuleResult :: Failed => { :: peg :: RuleResult :: Matched (__pos , ()) } , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { { let __seq_res = match __parse_rust_ty_path (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , _) => { :: peg :: RuleResult :: Matched (__pos , ()) } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } }; - match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } + match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; } , :: peg :: RuleResult :: Failed => { break ; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched( __repeat_pos, (), @@ -2160,12 +2171,12 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched(__repeat_pos, ()) }; @@ -2224,10 +2235,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = @@ -2261,14 +2272,14 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -2318,10 +2329,10 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = @@ -2398,14 +2409,14 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -2463,10 +2474,11 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, sp) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match ::peg::ParseLiteral::parse_string_literal( @@ -2489,14 +2501,15 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) } else { ::peg::RuleResult::Failed @@ -2506,6 +2519,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, s) => ::peg::RuleResult::Matched( __pos, (|| { + let s: Vec<_> = s; if s.len() == 1 { s.into_iter().next().unwrap() } else { @@ -2533,19 +2547,21 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, sp) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; let __step_res = __parse_labeled(__input, __state, __err_state, __pos); match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) }; @@ -3183,10 +3199,11 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; - let __pos = if __repeat_value.is_empty() { + let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "--") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"--\"") ; :: peg :: RuleResult :: Failed } } ; @@ -3210,12 +3227,16 @@ pub mod peg { __value, ) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend( + &mut __repeat_value, + Some(__value), + ); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched( __repeat_pos, @@ -3382,7 +3403,7 @@ pub mod peg { __err_state, __pos, ); - match __seq_res { :: peg :: RuleResult :: Matched (__pos , name) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "(") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! () ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . is_empty () { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = __parse_rule_arg (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; __repeat_value . push (__value) ; } , :: peg :: RuleResult :: Failed => { break ; } } } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ")") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { RuleExpr (name , args) . at (sp) }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\")\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"(\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } + match __seq_res { :: peg :: RuleResult :: Matched (__pos , name) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "(") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = __parse_rule_arg (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ")") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { RuleExpr (name , args) . at (sp) }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\")\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"(\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ::peg::RuleResult::Failed => { ::peg::RuleResult::Failed @@ -3500,21 +3521,21 @@ pub mod peg { let str_start = __pos; match { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; let __step_res = __input.eat_until(__pos, ','); match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, ()) } else { ::peg::RuleResult::Failed @@ -3547,21 +3568,23 @@ pub mod peg { { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; let __step_res = __parse_precedence_op(__input, __state, __err_state, __pos); match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } - if __repeat_value.len() >= 1 { + if __repeat_count >= 1 { ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) } else { ::peg::RuleResult::Failed @@ -3591,19 +3614,21 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, span) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = vec![]; + let mut __repeat_value = Default::default(); + let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; let __step_res = __parse_labeled(__input, __state, __err_state, __pos); match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - __repeat_value.push(__value); + core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; } } + __repeat_count += 1; } ::peg::RuleResult::Matched(__repeat_pos, __repeat_value) }; diff --git a/peg-macros/grammar.rustpeg b/peg-macros/grammar.rustpeg index 7fdafdb..72fded5 100644 --- a/peg-macros/grammar.rustpeg +++ b/peg-macros/grammar.rustpeg @@ -83,6 +83,7 @@ rule rust_generic_param() rule expression() -> SpannedExpr = choice() rule choice() -> SpannedExpr = sp:sp() s:sequence() ++ "/" { + let s: Vec<_> = s; if s.len() == 1 { s.into_iter().next().unwrap() } else { From b14b1c84e1ee239b2025812010989e6bb0150528 Mon Sep 17 00:00:00 2001 From: therealbnut <635596+therealbnut@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:37:53 +1100 Subject: [PATCH 3/3] fix core namespaces --- peg-macros/grammar.rs | 53 +++++++++++++++++++++++++---------------- peg-macros/translate.rs | 6 +++-- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/peg-macros/grammar.rs b/peg-macros/grammar.rs index 9b3fe83..c3afa1f 100644 --- a/peg-macros/grammar.rs +++ b/peg-macros/grammar.rs @@ -113,7 +113,7 @@ pub mod peg { __err_state, __pos, ); - match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "for") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let str_start = __pos ; match match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , :: peg :: ParseSlice :: parse_slice (__input , str_start , __newpos)) } , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , input_type) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __step_res = __parse_item (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , items) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { Grammar { doc , visibility , name , lifetime_params , args , input_type , items } }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"for\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } + match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "for") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let str_start = __pos ; match match __parse_rust_type (__input , __state , __err_state , __pos) { :: peg :: RuleResult :: Matched (pos , _) => :: peg :: RuleResult :: Matched (pos , ()) , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } { :: peg :: RuleResult :: Matched (__newpos , _) => { :: peg :: RuleResult :: Matched (__newpos , :: peg :: ParseSlice :: parse_slice (__input , str_start , __newpos)) } , :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , input_type) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "{") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = :: core :: default :: Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __step_res = __parse_item (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; :: core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , items) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "}") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { Grammar { doc , visibility , name , lifetime_params , args , input_type , items } }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"}\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"{\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"for\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ::peg::RuleResult::Failed => { ::peg::RuleResult::Failed @@ -147,7 +147,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -192,7 +192,7 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; @@ -260,7 +260,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -340,7 +340,7 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; @@ -776,7 +776,7 @@ pub mod peg { let __seq_res = match { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -837,7 +837,10 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend( + &mut __repeat_value, + Some(__value), + ); } ::peg::RuleResult::Failed => { break; @@ -1796,7 +1799,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -1846,7 +1849,7 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; @@ -2474,7 +2477,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, sp) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -2501,7 +2504,10 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend( + &mut __repeat_value, + Some(__value), + ); } ::peg::RuleResult::Failed => { break; @@ -2547,7 +2553,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, sp) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -2555,7 +2561,10 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend( + &mut __repeat_value, + Some(__value), + ); } ::peg::RuleResult::Failed => { break; @@ -3199,7 +3208,8 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __val) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = + ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -3227,7 +3237,7 @@ pub mod peg { __value, ) => { __repeat_pos = __newpos; - core::iter::Extend::extend( + ::core::iter::Extend::extend( &mut __repeat_value, Some(__value), ); @@ -3403,7 +3413,7 @@ pub mod peg { __err_state, __pos, ); - match __seq_res { :: peg :: RuleResult :: Matched (__pos , name) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "(") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = __parse_rule_arg (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ")") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { RuleExpr (name , args) . at (sp) }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\")\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"(\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } + match __seq_res { :: peg :: RuleResult :: Matched (__pos , name) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , "(") { :: peg :: RuleResult :: Matched (__pos , __val) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = :: core :: default :: Default :: default () ; let mut __repeat_count = 0usize ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_count == 0 { __pos } else { let __sep_res = match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ",") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , __val) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\",\"") ; :: peg :: RuleResult :: Failed } } ; match __sep_res { :: peg :: RuleResult :: Matched (__newpos , _) => { __newpos } , :: peg :: RuleResult :: Failed => break , } } ; let __step_res = __parse_rule_arg (__input , __state , __err_state , __pos) ; match __step_res { :: peg :: RuleResult :: Matched (__newpos , __value) => { __repeat_pos = __newpos ; :: core :: iter :: Extend :: extend (& mut __repeat_value , Some (__value)) ; } , :: peg :: RuleResult :: Failed => { break ; } } __repeat_count += 1 ; } :: peg :: RuleResult :: Matched (__repeat_pos , __repeat_value) } ; match __seq_res { :: peg :: RuleResult :: Matched (__pos , args) => { match :: peg :: ParseLiteral :: parse_string_literal (__input , __pos , ")") { :: peg :: RuleResult :: Matched (__pos , __val) => { :: peg :: RuleResult :: Matched (__pos , (|| { RuleExpr (name , args) . at (sp) }) ()) } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\")\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } } :: peg :: RuleResult :: Failed => { __err_state . mark_failure (__pos , "\"(\"") ; :: peg :: RuleResult :: Failed } } } :: peg :: RuleResult :: Failed => :: peg :: RuleResult :: Failed , } } ::peg::RuleResult::Failed => { ::peg::RuleResult::Failed @@ -3568,7 +3578,7 @@ pub mod peg { { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -3576,7 +3586,7 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend(&mut __repeat_value, Some(__value)); } ::peg::RuleResult::Failed => { break; @@ -3614,7 +3624,7 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, span) => { let __seq_res = { let mut __repeat_pos = __pos; - let mut __repeat_value = Default::default(); + let mut __repeat_value = ::core::default::Default::default(); let mut __repeat_count = 0usize; loop { let __pos = __repeat_pos; @@ -3622,7 +3632,10 @@ pub mod peg { match __step_res { ::peg::RuleResult::Matched(__newpos, __value) => { __repeat_pos = __newpos; - core::iter::Extend::extend(&mut __repeat_value, Some(__value)); + ::core::iter::Extend::extend( + &mut __repeat_value, + Some(__value), + ); } ::peg::RuleResult::Failed => { break; diff --git a/peg-macros/translate.rs b/peg-macros/translate.rs index c64112b..232c601 100644 --- a/peg-macros/translate.rs +++ b/peg-macros/translate.rs @@ -690,9 +690,11 @@ fn compile_expr(context: &Context, e: &SpannedExpr, result_used: bool) -> TokenS let (repeat_vec, repeat_step) = if result_used { ( - Some(quote_spanned! { span => let mut __repeat_value = Default::default(); }), Some( - quote_spanned! { span => core::iter::Extend::extend(&mut __repeat_value, Some(__value)); }, + quote_spanned! { span => let mut __repeat_value = ::core::default::Default::default(); }, + ), + Some( + quote_spanned! { span => ::core::iter::Extend::extend(&mut __repeat_value, Some(__value)); }, ), ) } else {