diff --git a/peg-tests/build.rs b/peg-tests/build.rs index f625288..98ac6fd 100644 --- a/peg-tests/build.rs +++ b/peg-tests/build.rs @@ -1,5 +1,7 @@ extern crate peg; fn main() { + peg::cargo_build("src/test_subgrammar.rustpeg"); + peg::cargo_build("src/test_subgrammar_with_args.rustpeg"); peg::cargo_build("src/test_grammar.rustpeg"); } diff --git a/peg-tests/src/test_grammar.rustpeg b/peg-tests/src/test_grammar.rustpeg index fa0d183..bdc7e08 100644 --- a/peg-tests/src/test_grammar.rustpeg +++ b/peg-tests/src/test_grammar.rustpeg @@ -119,3 +119,12 @@ issue152 -> i32 // a } pub error_pos = ("a" / "\n" / "\r")* + +import test_subgrammar + +pub subgrammar_rule = test_subgrammar::only_rule + +import test_subgrammar_with_args through { 5 } + +pub subgrammar_with_args_rule = test_subgrammar_with_args::repeater + diff --git a/peg-tests/src/test_subgrammar.rustpeg b/peg-tests/src/test_subgrammar.rustpeg new file mode 100644 index 0000000..a2d0f51 --- /dev/null +++ b/peg-tests/src/test_subgrammar.rustpeg @@ -0,0 +1,3 @@ +shared only_rule -> () + = "this is the only subgrammar rule" + diff --git a/peg-tests/src/test_subgrammar_with_args.rustpeg b/peg-tests/src/test_subgrammar_with_args.rustpeg new file mode 100644 index 0000000..4fdf288 --- /dev/null +++ b/peg-tests/src/test_subgrammar_with_args.rustpeg @@ -0,0 +1,4 @@ +#![arguments(my_arg: usize)] + +shared repeater -> () + = "a"*<{my_arg}> diff --git a/peg-tests/src/tests.rs b/peg-tests/src/tests.rs index 7bf794d..f3de4bd 100644 --- a/peg-tests/src/tests.rs +++ b/peg-tests/src/tests.rs @@ -6,6 +6,14 @@ mod test_grammar { include!(concat!(env!("OUT_DIR"), "/test_grammar.rs")); } +mod test_subgrammar { + include!(concat!(env!("OUT_DIR"), "/test_subgrammar.rs")); +} + +mod test_subgrammar_with_args { + include!(concat!(env!("OUT_DIR"), "/test_subgrammar_with_args.rs")); +} + use self::test_grammar::*; #[test] @@ -131,6 +139,16 @@ fn test_renamed_imports() { assert_eq!(renamed_imports("").unwrap(), (42, 42)); } +#[test] +fn test_subgrammar() { + assert!(subgrammar_rule("this is the only subgrammar rule").is_ok()) +} + +#[test] +fn test_subgrammar_with_args() { + assert!(subgrammar_with_args_rule("aaaaa").is_ok()) +} + #[test] fn test_neg_lookahead_err() { let err = neg_lookahead_err("ac").err().unwrap(); @@ -186,3 +204,5 @@ fn test_error_pos() { assert_eq!(err.line, 3); assert_eq!(err.column, 4); } + + diff --git a/src/grammar.rs b/src/grammar.rs index afb1683..8983886 100644 --- a/src/grammar.rs +++ b/src/grammar.rs @@ -1,2 +1,2 @@ // Generated by rust-peg. Do not edit. -use self :: RuleResult :: { Matched , Failed } ; use translate ::*; use std :: char ; use codemap :: { self , Spanned } ; fn escape_default ( s : & str ) -> String { s . chars ( ) . flat_map ( | c | c . escape_default ( ) ) . collect ( ) } fn char_range_at ( s : & str , pos : usize ) -> ( char , usize ) { let c = & s [ pos .. ] . chars ( ) . next ( ) . unwrap ( ) ; let next_pos = pos + c . len_utf8 ( ) ; ( * c , next_pos ) } # [ derive ( Clone ) ] enum RuleResult < T > { Matched ( usize , T ) , Failed , } # [ derive ( PartialEq , Eq , Debug , Clone ) ] pub struct ParseError { pub line : usize , pub column : usize , pub offset : usize , pub expected : :: std :: collections :: HashSet < & 'static str > , } pub type ParseResult < T > = Result < T , ParseError > ; impl :: std :: fmt :: Display for ParseError { fn fmt ( & self , fmt : & mut :: std :: fmt :: Formatter ) -> :: std :: result :: Result < ( ) , :: std :: fmt :: Error > { try ! ( write ! ( fmt , "error at {}:{}: expected " , self . line , self . column ) ) ; if self . expected . len ( ) == 0 { try ! ( write ! ( fmt , "EOF" ) ) ; } else if self . expected . len ( ) == 1 { try ! ( write ! ( fmt , "`{}`" , escape_default ( self . expected . iter ( ) . next ( ) . unwrap ( ) ) ) ) ; } else { let mut iter = self . expected . iter ( ) ; try ! ( write ! ( fmt , "one of `{}`" , escape_default ( iter . next ( ) . unwrap ( ) ) ) ) ; for elem in iter { try ! ( write ! ( fmt , ", `{}`" , escape_default ( elem ) ) ) ; } } Ok ( ( ) ) } } impl :: std :: error :: Error for ParseError { fn description ( & self ) -> & str { "parse error" } } fn slice_eq ( input : & str , state : & mut ParseState , pos : usize , m : & 'static str ) -> RuleResult < ( ) > { # ! [ inline ( always ) ] # ! [ allow ( dead_code ) ] let l = m . len ( ) ; if input . len ( ) >= pos + l && & input . as_bytes ( ) [ pos .. pos + l ] == m . as_bytes ( ) { Matched ( pos + l , ( ) ) } else { state . mark_failure ( pos , m ) } } fn slice_eq_case_insensitive ( input : & str , state : & mut ParseState , pos : usize , m : & 'static str ) -> RuleResult < ( ) > { # ! [ inline ] # ! [ allow ( dead_code ) ] let mut used = 0usize ; let mut input_iter = input [ pos .. ] . chars ( ) . flat_map ( | x | x . to_uppercase ( ) ) ; for m_char_upper in m . chars ( ) . flat_map ( | x | x . to_uppercase ( ) ) { used += m_char_upper . len_utf8 ( ) ; let input_char_result = input_iter . next ( ) ; if input_char_result . is_none ( ) || input_char_result . unwrap ( ) != m_char_upper { return state . mark_failure ( pos , m ) ; } } Matched ( pos + used , ( ) ) } fn any_char ( input : & str , state : & mut ParseState , pos : usize ) -> RuleResult < ( ) > { # ! [ inline ] # ! [ allow ( dead_code ) ] if input . len ( ) > pos { let ( _ , next ) = char_range_at ( input , pos ) ; Matched ( next , ( ) ) } else { state . mark_failure ( pos , "" ) } } fn pos_to_line ( input : & str , pos : usize ) -> ( usize , usize ) { let before = & input [ .. pos ] ; let line = before . as_bytes ( ) . iter ( ) . filter ( | && c | c == b'\n' ) . count ( ) + 1 ; let col = before . chars ( ) . rev ( ) . take_while ( | & c | c != '\n' ) . count ( ) + 1 ; ( line , col ) } impl < 'input > ParseState < 'input > { # [ inline ( never ) ] fn mark_failure_slow_path ( & mut self , pos : usize , expected : & 'static str ) { if pos == self . max_err_pos { self . expected . insert ( expected ) ; } } # [ inline ( always ) ] fn mark_failure ( & mut self , pos : usize , expected : & 'static str ) -> RuleResult < ( ) > { if self . suppress_fail == 0 { if self . reparsing_on_error { self . mark_failure_slow_path ( pos , expected ) ; } else if pos > self . max_err_pos { self . max_err_pos = pos ; } } Failed } } struct ParseState < 'input > { max_err_pos : usize , suppress_fail : usize , reparsing_on_error : bool , expected : :: std :: collections :: HashSet < & 'static str > , _phantom : :: std :: marker :: PhantomData < & 'input ( ) > , primary_cache : :: std :: collections :: HashMap < usize , RuleResult < Spanned < Expr > >> } impl < 'input > ParseState < 'input > { fn new ( ) -> ParseState < 'input > { ParseState { max_err_pos : 0 , suppress_fail : 0 , reparsing_on_error : false , expected : :: std :: collections :: HashSet :: new ( ) , _phantom : :: std :: marker :: PhantomData , primary_cache : :: std :: collections :: HashMap :: new ( ) } } } fn __parse_items < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Vec < Spanned < Item >> > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = __parse_item ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , items ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { items } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_rule < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Rule > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_exportflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , legacy_exported ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_cacheflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , cached ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_pubflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , public ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_returntype ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , returns ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "=" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Rule { name : name , expr : Box :: new ( expression ) , ret_type : returns , exported : public || legacy_exported , cached : cached } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_pubflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_PUB ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } } fn __parse_exportflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { __state . suppress_fail += 1 ; let res = { let __choice_res = { let __seq_res = { let __choice_res = slice_eq ( __input , __state , __pos , "#[export]" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "#[pub]" ) } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } ; __state . suppress_fail -= 1 ; res } } fn __parse_cacheflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#[cache]" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } } fn __parse_template < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Template > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , params ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "=" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Template { name : name , params : params , expr : Box :: new ( expression ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_item < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Item > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_rust_use ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , u ) => { Matched ( __pos , { Item :: Use ( u ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rule ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , r ) => { Matched ( __pos , { Item :: Rule ( r ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_template ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , t ) => { Matched ( __pos , { Item :: Template ( t ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_grammar_args ( __input , __state , __pos , file_span ) } } } } } } } fn __parse_grammar_args < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Item > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "#![" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "arguments" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_grammar_argument ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , args ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "]" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Item :: GrammarArgs ( args ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_grammar_argument < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( String , String ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , i ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_type_string ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , t ) => { Matched ( __pos , { ( i , t ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_type_string < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match __parse_rust_type ( __input , __state , __pos , file_span ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , tp ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { tp . to_owned ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_returntype < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "->" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_type_string ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , tp ) => { Matched ( __pos , { tp } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { "()" . to_string ( ) } ) } } } fn __parse_rust_identifier < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { __state . suppress_fail += 1 ; let res = { let __seq_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z_]" ) } ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; res } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { __state . mark_failure ( __pos , "identifier" ) ; Failed } } } } fn __parse_rust_use < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let __seq_res = __parse_USE ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_path ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "*" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { match { let __seq_res = slice_eq ( __input , __state , __pos , "as" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => match { let __seq_res = slice_eq ( __input , __state , __pos , "as" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_identifier ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } } } } } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , v ) => { Matched ( __pos , { v . to_owned ( ) } ) } Failed => Failed , } } } fn __parse_rust_path < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } } fn __parse_rust_type < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "[" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_type ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "]" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "&" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = slice_eq ( __input , __state , __pos , "mut" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_type ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_identifier ( __input , __state , __pos , file_span ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_rust_type ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ">" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_type ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_rust_type ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ")" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_rust_identifier ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_expression < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] __parse_choice ( __input , __state , __pos , file_span ) } fn __parse_choice < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __seq_res = __parse_sequence ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , head ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "/" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_sequence ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , s ) => { Matched ( __pos , { s } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , tail ) => { Matched ( __pos , { if tail . len ( ) > 0 { let mut list = tail ; list . insert ( 0 , head ) ; ChoiceExpr ( list ) } else { head . node } } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_sequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_labeled ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , elements ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_action ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , code ) => { Matched ( __pos , { ActionExpr ( elements , code . 0 , code . 1 ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , elements ) => { Matched ( __pos , { if elements . len ( ) != 1 { SequenceExpr ( elements ) } else { elements . into_iter ( ) . next ( ) . unwrap ( ) . node } } ) } Failed => Failed , } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_labeled < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < TaggedExpr > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , label ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { TaggedExpr { name : Some ( label ) , expr : Box :: new ( expression ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expr ) => { Matched ( __pos , { TaggedExpr { name : None , expr : Box :: new ( expr ) } } ) } Failed => Failed , } } } } } fn __parse_prefixed < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "$" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { MatchStrExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "&" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { PosAssertExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "!" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { NegAssertExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_suffixed ( __input , __state , __pos , file_span ) } } } fn __parse_suffixed < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "?" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { OptionalExpr ( Box :: new ( e ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "**" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatcount ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , count ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , sep ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , count , Some ( Box :: new ( sep ) ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "++" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , sep ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , BoundedRepeat :: Plus , Some ( Box :: new ( sep ) ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "*" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatcount ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , count ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , count , None ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "+" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , BoundedRepeat :: Plus , None ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_primary ( __input , __state , __pos , file_span ) } } } fn __parse_repeatcount < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < BoundedRepeat > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatnum ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , n ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { BoundedRepeat :: Exact ( n ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match __parse_repeatnum ( __input , __state , __pos , file_span ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , min ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match __parse_repeatnum ( __input , __state , __pos , file_span ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , max ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { BoundedRepeat :: Both ( min , max ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { BoundedRepeat :: None } ) } } } } } fn __parse_repeatnum < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_integer ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , i ) => { Matched ( __pos , { i . to_string ( ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { e } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } fn __parse_primary < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] if let Some ( entry ) = __state . primary_cache . get ( & __pos ) { return entry . clone ( ) ; } let __rule_result = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __choice_res = slice_eq ( __input , __state , __pos , "<" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "->" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "=" ) } } } } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { RuleExpr ( name ) } ) } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , args ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "=" ) } Failed => Failed , } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { TemplateInvoke ( name , args ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_literal ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_class ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "." ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { AnyCharExpr } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#position" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { PositionExpr } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#quiet" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { QuietExpr ( Box :: new ( e ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#expected" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { FailExpr ( s ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#infix" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , atom ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_infix_level ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , __repeat_value ) } else { Failed } } ; match __seq_res { Matched ( __pos , levels ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixExpr { atom : Box :: new ( atom ) , levels : levels } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { expression . node } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } } } } } } } } } } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; __state . primary_cache . insert ( __pos , __rule_result . clone ( ) ) ; __rule_result } fn __parse_infix_level < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < InfixLevel > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#L" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixAssoc :: Left } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "#R" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixAssoc :: Right } ) } Failed => Failed , } } } } ; match __seq_res { Matched ( __pos , assoc ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_infix_op ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , __repeat_value ) } else { Failed } } ; match __seq_res { Matched ( __pos , operators ) => { Matched ( __pos , { InfixLevel { assoc : assoc , operators : operators } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_infix_op < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < InfixOperator > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , l ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , var ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { var } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , op ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , r ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , action ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixOperator { operator : Box :: new ( e ) , action : action , l_arg : l , op_arg : op , r_arg : r } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_rust_expr < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_braced ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_nonBraceCharacters ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , literal ) => { Matched ( __pos , { format ! ( "{{ {} }}" , literal ) } ) } Failed => Failed , } } } fn __parse_action < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( String , bool ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "?" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , cond ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , literal ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { ( literal , cond . is_some ( ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_braced < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_braced ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_nonBraceCharacters ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "}" ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_nonBraceCharacters < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '{' | '}' => __state . mark_failure ( __pos , "[^{}]" ) , _ => Matched ( __next , ( ) ) , } } else { __state . mark_failure ( __pos , "[^{}]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } } fn __parse_USE < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "use" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_PUB < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "pub" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_keyword < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_USE ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_PUB ( __input , __state , __pos , file_span ) } } } fn __parse_integer < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < usize > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9]" ) , } } else { __state . mark_failure ( __pos , "[0-9]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , i ) => { Matched ( __pos , { i . parse ( ) . unwrap ( ) } ) } Failed => Failed , } } } fn __parse_identifier < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { __state . suppress_fail += 1 ; let res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_keyword ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let __seq_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z_]" ) } ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , chars ) => { Matched ( __pos , { chars . to_owned ( ) } ) } Failed => Failed , } } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; res } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { __state . mark_failure ( __pos , "identifier" ) ; Failed } } } } fn __parse_literal < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Expr > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_singleQuotedString ( __input , __state , __pos , file_span ) } } ; match __seq_res { Matched ( __pos , value ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "i" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , case_insensitive ) => { Matched ( __pos , { LiteralExpr ( value , case_insensitive . is_some ( ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_string < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_singleQuotedString ( __input , __state , __pos , file_span ) } } ; match __seq_res { Matched ( __pos , string ) => { Matched ( __pos , { string } ) } Failed => Failed , } } } fn __parse_doubleQuotedString < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_doubleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { s . into_iter ( ) . collect ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_doubleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleDoubleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleDoubleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_singleQuotedString < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_singleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { s . into_iter ( ) . collect ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_singleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleSingleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleSingleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_class < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Expr > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "[" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "^" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , inverted ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_classCharacterRange ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_classCharacter ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , parts ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "]" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "i" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , flags ) => { Matched ( __pos , { CharSetExpr ( inverted . is_some ( ) , parts ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_classCharacterRange < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < CharSetCase > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , begin ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "-" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { CharSetCase { start : begin , end : end } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_classCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < CharSetCase > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , char_ ) => { Matched ( __pos , { CharSetCase { start : char_ , end : char_ } } ) } Failed => Failed , } } } fn __parse_bracketDelimitedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleBracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleBracketDelimitedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "]" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_simpleEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = __parse_digit ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "x" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "u" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { match c . chars ( ) . next ( ) . unwrap ( ) { 'n' => '\n' , 'r' => '\r' , 't' => '\t' , x => x } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_zeroEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\0" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_digit ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { 0u8 as char } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_hex2EscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\x" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let __seq_res = __parse_hexDigit ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_hexDigit ( __input , __state , __pos , file_span ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , value ) => { Matched ( __pos , { char :: from_u32 ( u32 :: from_str_radix ( value , 16 ) . unwrap ( ) ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_unicodeEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\u{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_hexDigit ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , value ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { char :: from_u32 ( u32 :: from_str_radix ( value , 16 ) . unwrap ( ) ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_eolEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_eol ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { '\n' } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_digit < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9]" ) , } } else { __state . mark_failure ( __pos , "[0-9]" ) } } fn __parse_hexDigit < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' | 'a' ... 'f' | 'A' ... 'F' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9a-fA-F]" ) , } } else { __state . mark_failure ( __pos , "[0-9a-fA-F]" ) } } fn __parse__ < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { __state . suppress_fail += 1 ; let res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_whitespace ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_eol ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_comment ( __input , __state , __pos , file_span ) } } } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; __state . suppress_fail -= 1 ; res } } fn __parse_comment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_singleLineComment ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_multiLineComment ( __input , __state , __pos , file_span ) } } } fn __parse_singleLineComment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "//" ) ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_eolChar ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { any_char ( __input , __state , __pos ) } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } } fn __parse_multiLineComment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "/*" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = slice_eq ( __input , __state , __pos , "*/" ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { any_char ( __input , __state , __pos ) } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "*/" ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_eol < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = slice_eq ( __input , __state , __pos , "\n" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\r\n" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\r" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\u{2028}" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "\u{2029}" ) } } } } } } } } } fn __parse_eolChar < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '\n' | '\r' | '\u{2028}' | '\u{2029}' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[\n\r\u{2028}\u{2029}]" ) , } } else { __state . mark_failure ( __pos , "[\n\r\u{2028}\u{2029}]" ) } } fn __parse_whitespace < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { ' ' | '\t' | '\u{a0}' | '\u{feff}' | '\u{1680}' | '\u{180e}' | '\u{2000}' ... '\u{200a}' | '\u{202f}' | '\u{205f}' | '\u{3000}' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[ \t\u{a0}\u{feff}\u{1680}\u{180e}\u{2000}-\u{200a}\u{202f}\u{205f}\u{3000}]" ) , } } else { __state . mark_failure ( __pos , "[ \t\u{a0}\u{feff}\u{1680}\u{180e}\u{2000}-\u{200a}\u{202f}\u{205f}\u{3000}]" ) } } pub fn items < 'input > ( __input : & 'input str , file_span : codemap :: Span ) -> ParseResult < Vec < Spanned < Item >> > { # ! [ allow ( non_snake_case , unused ) ] let mut __state = ParseState :: new ( ) ; match __parse_items ( __input , & mut __state , 0 , file_span ) { Matched ( __pos , __value ) => { if __pos == __input . len ( ) { return Ok ( __value ) } } _ => ( ) } let __err_pos = __state . max_err_pos ; __state = ParseState :: new ( ) ; __state . reparsing_on_error = true ; __state . max_err_pos = __err_pos ; __parse_items ( __input , & mut __state , 0 , file_span ) ; let ( __line , __col ) = pos_to_line ( __input , __err_pos ) ; Err ( ParseError { line : __line , column : __col , offset : __err_pos , expected : __state . expected , } ) } \ No newline at end of file +use self :: RuleResult :: { Matched , Failed } ; use translate ::*; use std :: char ; use codemap :: { self , Spanned } ; fn escape_default ( s : & str ) -> String { s . chars ( ) . flat_map ( | c | c . escape_default ( ) ) . collect ( ) } fn char_range_at ( s : & str , pos : usize ) -> ( char , usize ) { let c = & s [ pos .. ] . chars ( ) . next ( ) . unwrap ( ) ; let next_pos = pos + c . len_utf8 ( ) ; ( * c , next_pos ) } # [ derive ( Clone ) ] pub enum RuleResult < T > { Matched ( usize , T ) , Failed , } # [ derive ( PartialEq , Eq , Debug , Clone ) ] pub struct ParseError { pub line : usize , pub column : usize , pub offset : usize , pub expected : :: std :: collections :: HashSet < & 'static str > , } pub type ParseResult < T > = Result < T , ParseError > ; impl :: std :: fmt :: Display for ParseError { fn fmt ( & self , fmt : & mut :: std :: fmt :: Formatter ) -> :: std :: result :: Result < ( ) , :: std :: fmt :: Error > { try ! ( write ! ( fmt , "error at {}:{}: expected " , self . line , self . column ) ) ; if self . expected . len ( ) == 0 { try ! ( write ! ( fmt , "EOF" ) ) ; } else if self . expected . len ( ) == 1 { try ! ( write ! ( fmt , "`{}`" , escape_default ( self . expected . iter ( ) . next ( ) . unwrap ( ) ) ) ) ; } else { let mut iter = self . expected . iter ( ) ; try ! ( write ! ( fmt , "one of `{}`" , escape_default ( iter . next ( ) . unwrap ( ) ) ) ) ; for elem in iter { try ! ( write ! ( fmt , ", `{}`" , escape_default ( elem ) ) ) ; } } Ok ( ( ) ) } } impl :: std :: error :: Error for ParseError { fn description ( & self ) -> & str { "parse error" } } fn slice_eq ( input : & str , state : & mut ParseState , pos : usize , m : & 'static str ) -> RuleResult < ( ) > { # ! [ inline ( always ) ] # ! [ allow ( dead_code ) ] let l = m . len ( ) ; if input . len ( ) >= pos + l && & input . as_bytes ( ) [ pos .. pos + l ] == m . as_bytes ( ) { Matched ( pos + l , ( ) ) } else { state . mark_failure ( pos , m ) } } fn slice_eq_case_insensitive ( input : & str , state : & mut ParseState , pos : usize , m : & 'static str ) -> RuleResult < ( ) > { # ! [ inline ] # ! [ allow ( dead_code ) ] let mut used = 0usize ; let mut input_iter = input [ pos .. ] . chars ( ) . flat_map ( | x | x . to_uppercase ( ) ) ; for m_char_upper in m . chars ( ) . flat_map ( | x | x . to_uppercase ( ) ) { used += m_char_upper . len_utf8 ( ) ; let input_char_result = input_iter . next ( ) ; if input_char_result . is_none ( ) || input_char_result . unwrap ( ) != m_char_upper { return state . mark_failure ( pos , m ) ; } } Matched ( pos + used , ( ) ) } fn any_char ( input : & str , state : & mut ParseState , pos : usize ) -> RuleResult < ( ) > { # ! [ inline ] # ! [ allow ( dead_code ) ] if input . len ( ) > pos { let ( _ , next ) = char_range_at ( input , pos ) ; Matched ( next , ( ) ) } else { state . mark_failure ( pos , "" ) } } fn pos_to_line ( input : & str , pos : usize ) -> ( usize , usize ) { let before = & input [ .. pos ] ; let line = before . as_bytes ( ) . iter ( ) . filter ( | && c | c == b'\n' ) . count ( ) + 1 ; let col = before . chars ( ) . rev ( ) . take_while ( | & c | c != '\n' ) . count ( ) + 1 ; ( line , col ) } impl < 'input > ParseState < 'input > { # [ inline ( never ) ] fn mark_failure_slow_path ( & mut self , pos : usize , expected : & 'static str ) { if pos == self . max_err_pos { self . expected . insert ( expected ) ; } } # [ inline ( always ) ] fn mark_failure ( & mut self , pos : usize , expected : & 'static str ) -> RuleResult < ( ) > { if self . suppress_fail == 0 { if self . reparsing_on_error { self . mark_failure_slow_path ( pos , expected ) ; } else if pos > self . max_err_pos { self . max_err_pos = pos ; } } Failed } } pub ( crate ) struct ParseState < 'input > { pub max_err_pos : usize , pub suppress_fail : usize , pub reparsing_on_error : bool , pub expected : :: std :: collections :: HashSet < & 'static str > , _phantom : :: std :: marker :: PhantomData < & 'input ( ) > , primary_cache : :: std :: collections :: HashMap < usize , RuleResult < Spanned < Expr > >> } impl < 'input > ParseState < 'input > { pub fn from ( max_err_pos : usize , suppress_fail : usize , reparsing_on_error : bool , expected : & :: std :: collections :: HashSet < & 'static str > ) -> ParseState < 'input > { # ! [ allow ( unused ) ] ParseState { max_err_pos : max_err_pos , suppress_fail : suppress_fail , reparsing_on_error : reparsing_on_error , expected : expected . clone ( ) , _phantom : :: std :: marker :: PhantomData , primary_cache : :: std :: collections :: HashMap :: new ( ) } } fn new ( ) -> ParseState < 'input > { # ! [ allow ( unused ) ] ParseState { max_err_pos : 0 , suppress_fail : 0 , reparsing_on_error : false , expected : :: std :: collections :: HashSet :: new ( ) , _phantom : :: std :: marker :: PhantomData , primary_cache : :: std :: collections :: HashMap :: new ( ) } } } fn __parse_items < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Vec < Spanned < Item >> > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = __parse_item ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , items ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { items } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_rule < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Rule > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_exportflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , legacy_exported ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_cacheflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , cached ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_pubflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , public ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_shareflag ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , is_shared ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_returntype ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , returns ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "=" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Rule { name : name , expr : Box :: new ( expression ) , ret_type : returns , exported : public || legacy_exported , shared : is_shared , cached : cached } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_pubflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_PUB ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } } fn __parse_shareflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_SHARED ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } } fn __parse_exportflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { __state . suppress_fail += 1 ; let res = { let __choice_res = { let __seq_res = { let __choice_res = slice_eq ( __input , __state , __pos , "#[export]" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "#[pub]" ) } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } ; __state . suppress_fail -= 1 ; res } } fn __parse_cacheflag < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < bool > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#[cache]" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { true } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { false } ) } } } fn __parse_template < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Template > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , params ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "=" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Template { name : name , params : params , expr : Box :: new ( expression ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_subgrammar < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Subgrammar > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_IMPORT ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , grammar_name ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_THROUGH ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , code ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { code } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , converter ) => { Matched ( __pos , { Subgrammar { name : grammar_name , converter : converter } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_item < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Item > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_rust_use ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , u ) => { Matched ( __pos , { Item :: Use ( u ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rule ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , r ) => { Matched ( __pos , { Item :: Rule ( r ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_template ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , t ) => { Matched ( __pos , { Item :: Template ( t ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_subgrammar ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , s ) => { Matched ( __pos , { Item :: Subgrammar ( s ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_grammar_args ( __input , __state , __pos , file_span ) } } } } } } } } } fn __parse_grammar_args < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Item > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "#![" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "arguments" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_grammar_argument ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , args ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "]" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Item :: GrammarArgs ( args ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_grammar_argument < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( String , String ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , i ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_type_string ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , t ) => { Matched ( __pos , { ( i , t ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_type_string < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match __parse_rust_type ( __input , __state , __pos , file_span ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , tp ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { tp . to_owned ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_returntype < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "->" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_type_string ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , tp ) => { Matched ( __pos , { tp } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { "()" . to_string ( ) } ) } } } fn __parse_rust_identifier < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { __state . suppress_fail += 1 ; let res = { let __seq_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z_]" ) } ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; res } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { __state . mark_failure ( __pos , "identifier" ) ; Failed } } } } fn __parse_rust_use < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let __seq_res = __parse_USE ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_path ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "*" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { match { let __seq_res = slice_eq ( __input , __state , __pos , "as" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => match { let __seq_res = slice_eq ( __input , __state , __pos , "as" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_identifier ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } } } } } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ";" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , v ) => { Matched ( __pos , { v . to_owned ( ) } ) } Failed => Failed , } } } fn __parse_rust_path < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } } fn __parse_rust_type < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "[" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_type ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "]" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "&" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = slice_eq ( __input , __state , __pos , "mut" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_type ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_identifier ( __input , __state , __pos , file_span ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_rust_type ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ">" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_rust_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_rust_type ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_rust_type ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , ")" ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_rust_identifier ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_expression < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] __parse_choice ( __input , __state , __pos , file_span ) } fn __parse_choice < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __seq_res = __parse_sequence ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , head ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "/" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_sequence ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , s ) => { Matched ( __pos , { s } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , tail ) => { Matched ( __pos , { if tail . len ( ) > 0 { let mut list = tail ; list . insert ( 0 , head ) ; ChoiceExpr ( list ) } else { head . node } } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_sequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_labeled ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , elements ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_action ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , code ) => { Matched ( __pos , { ActionExpr ( elements , code . 0 , code . 1 ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , elements ) => { Matched ( __pos , { if elements . len ( ) != 1 { SequenceExpr ( elements ) } else { elements . into_iter ( ) . next ( ) . unwrap ( ) . node } } ) } Failed => Failed , } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_labeled < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < TaggedExpr > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , label ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { TaggedExpr { name : Some ( label ) , expr : Box :: new ( expression ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = __parse_prefixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expr ) => { Matched ( __pos , { TaggedExpr { name : None , expr : Box :: new ( expr ) } } ) } Failed => Failed , } } } } } fn __parse_prefixed < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "$" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { MatchStrExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "&" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { PosAssertExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "!" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_suffixed ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { Matched ( __pos , { NegAssertExpr ( Box :: new ( expression ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_suffixed ( __input , __state , __pos , file_span ) } } } fn __parse_suffixed < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "?" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { OptionalExpr ( Box :: new ( e ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "**" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatcount ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , count ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , sep ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , count , Some ( Box :: new ( sep ) ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "++" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , sep ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , BoundedRepeat :: Plus , Some ( Box :: new ( sep ) ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "*" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatcount ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , count ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , count , None ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "+" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { Repeat ( Box :: new ( e ) , BoundedRepeat :: Plus , None ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_primary ( __input , __state , __pos , file_span ) } } } fn __parse_repeatcount < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < BoundedRepeat > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_repeatnum ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , n ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { BoundedRepeat :: Exact ( n ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match __parse_repeatnum ( __input , __state , __pos , file_span ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , min ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match __parse_repeatnum ( __input , __state , __pos , file_span ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , max ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { BoundedRepeat :: Both ( min , max ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => Matched ( __pos , { BoundedRepeat :: None } ) } } } } } fn __parse_repeatnum < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { let __seq_res = __parse_integer ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , i ) => { Matched ( __pos , { i . to_string ( ) } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { e } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } fn __parse_primary < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Spanned < Expr > > { # ! [ allow ( non_snake_case , unused ) ] if let Some ( entry ) = __state . primary_cache . get ( & __pos ) { return entry . clone ( ) ; } let __rule_result = { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , start ) => { { let __seq_res = { let __choice_res = { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __choice_res = slice_eq ( __input , __state , __pos , "<" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "->" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "=" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "::" ) } } } } } } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { RuleExpr ( name ) } ) } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , grammar_name ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "::" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , rule_name ) => { Matched ( __pos , { SubgrammarRuleExpr ( grammar_name , rule_name ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , name ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { 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 . len ( ) > 0 { let __sep_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "," ) ; match __seq_res { Matched ( __pos , _ ) => { __parse__ ( __input , __state , __pos , file_span ) } Failed => Failed , } } } Failed => Failed , } } ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , list ) => { { let __seq_res = match { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "," ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , ( ) ) } , Failed => { Matched ( __pos , ( ) ) } , } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { list } ) } Failed => Failed , } } } Failed => Failed , } } ; match __seq_res { Matched ( __pos , args ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "=" ) } Failed => Failed , } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { TemplateInvoke ( name , args ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_literal ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_class ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "." ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { AnyCharExpr } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#position" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { PositionExpr } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#quiet" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { QuietExpr ( Box :: new ( e ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#expected" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { FailExpr ( s ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#infix" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "<" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , atom ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ">" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_infix_level ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , __repeat_value ) } else { Failed } } ; match __seq_res { Matched ( __pos , levels ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixExpr { atom : Box :: new ( atom ) , levels : levels } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "(" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_expression ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , expression ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ")" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { expression . node } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } } } } } } } } } } } } } } } } } } } } ; match __seq_res { Matched ( __pos , node ) => { { let __seq_res = Matched ( __pos , __pos ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { codemap :: Spanned { node , span : file_span . subspan ( start as u64 , end as u64 ) } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } ; __state . primary_cache . insert ( __pos , __rule_result . clone ( ) ) ; __rule_result } fn __parse_infix_level < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < InfixLevel > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = { let __seq_res = slice_eq ( __input , __state , __pos , "#L" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixAssoc :: Left } ) } Failed => Failed , } } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __seq_res = slice_eq ( __input , __state , __pos , "#R" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixAssoc :: Right } ) } Failed => Failed , } } } } ; match __seq_res { Matched ( __pos , assoc ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __pos = if __repeat_value . len ( ) > 0 { let __sep_res = __parse__ ( __input , __state , __pos , file_span ) ; match __sep_res { Matched ( __newpos , _ ) => { __newpos } , Failed => break , } } else { __pos } ; let __step_res = __parse_infix_op ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , __repeat_value ) } else { Failed } } ; match __seq_res { Matched ( __pos , operators ) => { Matched ( __pos , { InfixLevel { assoc : assoc , operators : operators } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_infix_op < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < InfixOperator > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , l ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , var ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , ":" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { var } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , op ) => { { let __seq_res = __parse_primary ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , e ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_identifier ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , r ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , action ) => { { let __seq_res = __parse__ ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { InfixOperator { operator : Box :: new ( e ) , action : action , l_arg : l , op_arg : op , r_arg : r } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_rust_expr < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_braced ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_nonBraceCharacters ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , literal ) => { Matched ( __pos , { format ! ( "{{ {} }}" , literal ) } ) } Failed => Failed , } } } fn __parse_action < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( String , bool ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "?" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , cond ) => { { let __seq_res = __parse_rust_expr ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , literal ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { ( literal , cond . is_some ( ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_braced < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_braced ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_nonBraceCharacters ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "}" ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_nonBraceCharacters < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '{' | '}' => __state . mark_failure ( __pos , "[^{}]" ) , _ => Matched ( __next , ( ) ) , } } else { __state . mark_failure ( __pos , "[^{}]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } } fn __parse_USE < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "use" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_PUB < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "pub" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_SHARED < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "shared" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_IMPORT < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "import" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_THROUGH < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "through" ) ; match __seq_res { Matched ( __pos , _ ) => { { __state . suppress_fail += 1 ; let __assert_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } } Failed => Failed , } } } fn __parse_keyword < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_USE ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_PUB ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_SHARED ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_IMPORT ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_THROUGH ( __input , __state , __pos , file_span ) } } } } } } } } } fn __parse_integer < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < usize > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9]" ) , } } else { __state . mark_failure ( __pos , "[0-9]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , i ) => { Matched ( __pos , { i . parse ( ) . unwrap ( ) } ) } Failed => Failed , } } } fn __parse_identifier < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = { __state . suppress_fail += 1 ; let res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_keyword ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let __seq_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z_]" ) } ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[a-zA-Z0-9_]" ) } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , chars ) => { Matched ( __pos , { chars . to_owned ( ) } ) } Failed => Failed , } } } Failed => Failed , } } ; __state . suppress_fail -= 1 ; res } ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { __state . mark_failure ( __pos , "identifier" ) ; Failed } } } } fn __parse_literal < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Expr > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_singleQuotedString ( __input , __state , __pos , file_span ) } } ; match __seq_res { Matched ( __pos , value ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "i" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , case_insensitive ) => { Matched ( __pos , { LiteralExpr ( value , case_insensitive . is_some ( ) ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_string < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { let __choice_res = __parse_doubleQuotedString ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_singleQuotedString ( __input , __state , __pos , file_span ) } } ; match __seq_res { Matched ( __pos , string ) => { Matched ( __pos , { string } ) } Failed => Failed , } } } fn __parse_doubleQuotedString < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_doubleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { s . into_iter ( ) . collect ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_doubleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleDoubleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleDoubleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "\"" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_singleQuotedString < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < String > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_singleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , s ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { s . into_iter ( ) . collect ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_singleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleSingleQuotedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleSingleQuotedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "\'" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_class < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < Expr > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "[" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "^" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , inverted ) => { { let __seq_res = { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_classCharacterRange ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_classCharacter ( __input , __state , __pos , file_span ) } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } Matched ( __repeat_pos , __repeat_value ) } ; match __seq_res { Matched ( __pos , parts ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "]" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = match slice_eq ( __input , __state , __pos , "i" ) { Matched ( __newpos , __value ) => { Matched ( __newpos , Some ( __value ) ) } , Failed => { Matched ( __pos , None ) } , } ; match __seq_res { Matched ( __pos , flags ) => { Matched ( __pos , { CharSetExpr ( inverted . is_some ( ) , parts ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_classCharacterRange < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < CharSetCase > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , begin ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "-" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , end ) => { Matched ( __pos , { CharSetCase { start : begin , end : end } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_classCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < CharSetCase > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = __parse_bracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , char_ ) => { Matched ( __pos , { CharSetCase { start : char_ , end : char_ } } ) } Failed => Failed , } } } fn __parse_bracketDelimitedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_simpleBracketDelimitedCharacter ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_simpleEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_zeroEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_hex2EscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_unicodeEscapeSequence ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolEscapeSequence ( __input , __state , __pos , file_span ) } } } } } } } } } } } fn __parse_simpleBracketDelimitedCharacter < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = slice_eq ( __input , __state , __pos , "]" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { c . chars ( ) . next ( ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_simpleEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = { let __choice_res = __parse_digit ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "x" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "u" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_eolChar ( __input , __state , __pos , file_span ) } } } } } } ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match any_char ( __input , __state , __pos ) { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , c ) => { Matched ( __pos , { match c . chars ( ) . next ( ) . unwrap ( ) { 'n' => '\n' , 'r' => '\r' , 't' => '\t' , x => x } } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_zeroEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\0" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_digit ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { 0u8 as char } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_hex2EscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\x" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let __seq_res = __parse_hexDigit ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { __parse_hexDigit ( __input , __state , __pos , file_span ) } Failed => Failed , } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , value ) => { Matched ( __pos , { char :: from_u32 ( u32 :: from_str_radix ( value , 16 ) . unwrap ( ) ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_unicodeEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\u{" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let str_start = __pos ; match { let mut __repeat_pos = __pos ; let mut __repeat_value = vec ! ( ) ; loop { let __pos = __repeat_pos ; let __step_res = __parse_hexDigit ( __input , __state , __pos , file_span ) ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } } } if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed } } { Matched ( __newpos , _ ) => { Matched ( __newpos , & __input [ str_start .. __newpos ] ) } , Failed => Failed , } } ; match __seq_res { Matched ( __pos , value ) => { { let __seq_res = slice_eq ( __input , __state , __pos , "}" ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { char :: from_u32 ( u32 :: from_str_radix ( value , 16 ) . unwrap ( ) ) . unwrap ( ) } ) } Failed => Failed , } } } Failed => Failed , } } } Failed => Failed , } } } fn __parse_eolEscapeSequence < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < char > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "\\" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = __parse_eol ( __input , __state , __pos , file_span ) ; match __seq_res { Matched ( __pos , _ ) => { Matched ( __pos , { '\n' } ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_digit < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9]" ) , } } else { __state . mark_failure ( __pos , "[0-9]" ) } } fn __parse_hexDigit < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' | 'a' ... 'f' | 'A' ... 'F' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9a-fA-F]" ) , } } else { __state . mark_failure ( __pos , "[0-9a-fA-F]" ) } } fn __parse__ < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { __state . suppress_fail += 1 ; let res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __choice_res = __parse_whitespace ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = __parse_eol ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_comment ( __input , __state , __pos , file_span ) } } } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; __state . suppress_fail -= 1 ; res } } fn __parse_comment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = __parse_singleLineComment ( __input , __state , __pos , file_span ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => __parse_multiLineComment ( __input , __state , __pos , file_span ) } } } fn __parse_singleLineComment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "//" ) ; match __seq_res { Matched ( __pos , _ ) => { { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = __parse_eolChar ( __input , __state , __pos , file_span ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { any_char ( __input , __state , __pos ) } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } } Failed => Failed , } } } fn __parse_multiLineComment < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __seq_res = slice_eq ( __input , __state , __pos , "/*" ) ; match __seq_res { Matched ( __pos , _ ) => { { let __seq_res = { let mut __repeat_pos = __pos ; loop { let __pos = __repeat_pos ; let __step_res = { let __seq_res = { __state . suppress_fail += 1 ; let __assert_res = slice_eq ( __input , __state , __pos , "*/" ) ; __state . suppress_fail -= 1 ; match __assert_res { Failed => Matched ( __pos , ( ) ) , Matched ( .. ) => Failed , } } ; match __seq_res { Matched ( __pos , _ ) => { any_char ( __input , __state , __pos ) } Failed => Failed , } } ; match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; } , Failed => { break ; } } } Matched ( __repeat_pos , ( ) ) } ; match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "*/" ) } Failed => Failed , } } } Failed => Failed , } } } fn __parse_eol < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] { let __choice_res = slice_eq ( __input , __state , __pos , "\n" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\r\n" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\r" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => { let __choice_res = slice_eq ( __input , __state , __pos , "\u{2028}" ) ; match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "\u{2029}" ) } } } } } } } } } fn __parse_eolChar < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '\n' | '\r' | '\u{2028}' | '\u{2029}' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[\n\r\u{2028}\u{2029}]" ) , } } else { __state . mark_failure ( __pos , "[\n\r\u{2028}\u{2029}]" ) } } fn __parse_whitespace < 'input > ( __input : & 'input str , __state : & mut ParseState < 'input > , __pos : usize , file_span : codemap :: Span ) -> RuleResult < ( ) > { # ! [ allow ( non_snake_case , unused ) ] if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { ' ' | '\t' | '\u{a0}' | '\u{feff}' | '\u{1680}' | '\u{180e}' | '\u{2000}' ... '\u{200a}' | '\u{202f}' | '\u{205f}' | '\u{3000}' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[ \t\u{a0}\u{feff}\u{1680}\u{180e}\u{2000}-\u{200a}\u{202f}\u{205f}\u{3000}]" ) , } } else { __state . mark_failure ( __pos , "[ \t\u{a0}\u{feff}\u{1680}\u{180e}\u{2000}-\u{200a}\u{202f}\u{205f}\u{3000}]" ) } } pub fn items < 'input > ( __input : & 'input str , file_span : codemap :: Span ) -> ParseResult < Vec < Spanned < Item >> > { # ! [ allow ( non_snake_case , unused ) ] let mut __state = ParseState :: new ( ) ; match __parse_items ( __input , & mut __state , 0 , file_span ) { Matched ( __pos , __value ) => { if __pos == __input . len ( ) { return Ok ( __value ) } } _ => ( ) } let __err_pos = __state . max_err_pos ; __state = ParseState :: new ( ) ; __state . reparsing_on_error = true ; __state . max_err_pos = __err_pos ; __parse_items ( __input , & mut __state , 0 , file_span ) ; let ( __line , __col ) = pos_to_line ( __input , __err_pos ) ; Err ( ParseError { line : __line , column : __col , offset : __err_pos , expected : __state . expected , } ) } \ No newline at end of file diff --git a/src/grammar.rustpeg b/src/grammar.rustpeg index 2e8ed4c..990f7f5 100644 --- a/src/grammar.rustpeg +++ b/src/grammar.rustpeg @@ -11,17 +11,19 @@ spanned pub items -> Vec> = _ items:spanned**_ _ { items } rule -> Rule - = legacy_exported:exportflag _ cached:cacheflag _ public:pubflag _ name:identifier _ returns:returntype _ "=" _ expression:expression (_ ";")? { + = legacy_exported:exportflag _ cached:cacheflag _ public:pubflag _ is_shared:shareflag _ name:identifier _ returns:returntype _ "=" _ expression:expression (_ ";")? { Rule{ name: name, expr: Box::new(expression), ret_type: returns, exported: public || legacy_exported, + shared: is_shared, cached: cached } } pubflag -> bool = PUB { true } / { false } + shareflag -> bool = SHARED { true } / { false } exportflag -> bool = #quiet<("#[export]" / "#[pub]") {true} / {false}> cacheflag -> bool = "#[cache]" {true} / {false} @@ -30,10 +32,14 @@ template -> Template Template { name: name, params: params, expr: Box::new(expression) } } +subgrammar -> Subgrammar + = IMPORT _ grammar_name:identifier converter:( _ THROUGH _ "{" _ code:rust_expr _ "}" { code })? { Subgrammar { name: grammar_name, converter: converter } } + item -> Item = u:rust_use { Item::Use(u) } / r:rule { Item::Rule(r) } / t:template { Item::Template(t) } + / s:subgrammar { Item::Subgrammar(s) } / grammar_args grammar_args -> Item @@ -148,9 +154,12 @@ repeatnum -> String #[cache] primary -> Spanned = spanned< - name:identifier !(_ ("<" / "->" / "=")) { + name:identifier !(_ ("<" / "->" / "=" / "::")) { RuleExpr(name) } + / grammar_name:identifier "::" rule_name:identifier { + SubgrammarRuleExpr(grammar_name, rule_name) + } / name:identifier _ "<" _ args:COMMASEP _ ">" !( _ "=") { TemplateInvoke(name, args) } @@ -189,8 +198,11 @@ nonBraceCharacters = [^{}]+ KEYWORD = k !([a-zA-Z0-9_]) USE = KEYWORD<"use"> PUB = KEYWORD<"pub"> +SHARED = KEYWORD<"shared"> +IMPORT = KEYWORD<"import"> +THROUGH = KEYWORD<"through"> -keyword = USE / PUB +keyword = USE / PUB / SHARED / IMPORT / THROUGH integer -> usize = i:$([0-9]+) { i.parse().unwrap() } diff --git a/src/translate.rs b/src/translate.rs index ab4ed41..4b84345 100644 --- a/src/translate.rs +++ b/src/translate.rs @@ -11,6 +11,7 @@ fn raw(s: &str) -> TokenStream { pub(crate) struct Grammar { pub imports: Vec, + pub subgrammars : Vec, pub rules: Vec, pub templates: HashMap, pub args: Vec<(String, String)>, @@ -19,6 +20,7 @@ pub(crate) struct Grammar { impl Grammar { pub fn from_ast(compiler: &mut PegCompiler, items: Vec>) -> Result { let mut imports = Vec::new(); + let mut subgrammars : Vec = Vec::new(); let mut rules: Vec = Vec::new(); let mut templates = HashMap::new(); @@ -47,6 +49,17 @@ impl Grammar { ) } } + Item::Subgrammar(subgrammar) => { + if subgrammars.iter().any(|imported_grammar| imported_grammar.name == subgrammar.name) { + compiler.span_error( + format!("Subgrammar `{}` imported multiple times", subgrammar.name), + item.span, + Some("duplicate import".to_owned()) + ) + } + + subgrammars.push(subgrammar); + } Item::GrammarArgs(args) => { if grammar_args.is_none() { grammar_args = Some(args); @@ -61,7 +74,7 @@ impl Grammar { } } - Ok(Grammar{ imports:imports, rules:rules, templates:templates, args: grammar_args.unwrap_or(vec![]) }) + Ok(Grammar{ imports:imports, subgrammars:subgrammars, rules:rules, templates:templates, args: grammar_args.unwrap_or(vec![]) }) } fn find_rule(&self, name: &str) -> Option<&Rule> { @@ -90,6 +103,7 @@ pub enum Item { Use(String), Rule(Rule), Template(Template), + Subgrammar(Subgrammar), GrammarArgs(Vec<(String, String)>) } @@ -98,6 +112,7 @@ pub struct Rule { pub expr: Box>, pub ret_type: String, pub exported: bool, + pub shared: bool, pub cached: bool, } @@ -107,6 +122,11 @@ pub struct Template { pub expr: Box>, } +pub struct Subgrammar { + pub name: String, + pub converter: Option, +} + #[derive(Clone)] pub struct CharSetCase { pub start: char, @@ -125,6 +145,7 @@ pub enum Expr { LiteralExpr(String,bool), CharSetExpr(bool, Vec), RuleExpr(String), + SubgrammarRuleExpr(String, String), SequenceExpr(Vec>), ChoiceExpr(Vec>), OptionalExpr(Box>), @@ -178,7 +199,7 @@ static HELPERS: &'static str = stringify! { } #[derive(Clone)] - enum RuleResult { + pub enum RuleResult { Matched(usize, T), Failed, } @@ -326,25 +347,40 @@ fn make_parse_state(rules: &[Rule]) -> TokenStream { } } + let cache_field_new = cache_fields.iter(); + let cache_field_from = cache_fields.iter(); + quote! { - struct ParseState<'input> { - max_err_pos: usize, - suppress_fail: usize, - reparsing_on_error: bool, - expected: ::std::collections::HashSet<&'static str>, + pub(crate) struct ParseState<'input> { + pub max_err_pos: usize, + pub suppress_fail: usize, + pub reparsing_on_error: bool, + pub expected: ::std::collections::HashSet<&'static str>, _phantom: ::std::marker::PhantomData<&'input ()>, #(#cache_fields_def),* } impl<'input> ParseState<'input> { + pub fn from(max_err_pos: usize, suppress_fail: usize, reparsing_on_error: bool, expected: &::std::collections::HashSet<&'static str>) -> ParseState<'input> { + #![allow(unused)] + ParseState { + max_err_pos: max_err_pos, + suppress_fail: suppress_fail, + reparsing_on_error: reparsing_on_error, + expected: expected.clone(), + _phantom: ::std::marker::PhantomData, + #(#cache_field_from: ::std::collections::HashMap::new()),* + } + } fn new() -> ParseState<'input> { + #![allow(unused)] ParseState { max_err_pos: 0, suppress_fail: 0, reparsing_on_error: false, expected: ::std::collections::HashSet::new(), _phantom: ::std::marker::PhantomData, - #(#cache_fields: ::std::collections::HashMap::new()),* + #(#cache_field_new: ::std::collections::HashMap::new()),* } } } @@ -382,6 +418,11 @@ fn compile_rule(compiler: &mut PegCompiler, grammar: &Grammar, rule: &Rule) -> T let nl = raw("\n\n"); // make output slightly more readable let extra_args_def = grammar.extra_args_def(); + let shared = if rule.shared { + raw("pub(crate)") + } else { + raw("") + }; if rule.cached { let cache_field = Ident::new(&format!("{}_cache", rule.name), Span::call_site()); @@ -399,7 +440,7 @@ fn compile_rule(compiler: &mut PegCompiler, grammar: &Grammar, rule: &Rule) -> T }; quote! { #nl - fn #name<'input>(__input: &'input str, __state: &mut ParseState<'input>, __pos: usize #extra_args_def) -> RuleResult<#ret_ty> { + #shared fn #name<'input>(__input: &'input str, __state: &mut ParseState<'input>, __pos: usize #extra_args_def) -> RuleResult<#ret_ty> { #![allow(non_snake_case, unused)] if let Some(entry) = __state.#cache_field.get(&__pos) { #cache_trace @@ -412,7 +453,7 @@ fn compile_rule(compiler: &mut PegCompiler, grammar: &Grammar, rule: &Rule) -> T } } else { quote! { #nl - fn #name<'input>(__input: &'input str, __state: &mut ParseState<'input>, __pos: usize #extra_args_def) -> RuleResult<#ret_ty> { + #shared fn #name<'input>(__input: &'input str, __state: &mut ParseState<'input>, __pos: usize #extra_args_def) -> RuleResult<#ret_ty> { #![allow(non_snake_case, unused)] #wrapped_body } @@ -608,6 +649,46 @@ fn compile_expr(compiler: &mut PegCompiler, cx: Context, e: &Spanned) -> T } } + SubgrammarRuleExpr(ref subgrammar_name, ref rule_name) => { + if let Some(ref subgrammar) = cx.grammar.subgrammars.iter().find(|ref sg| &sg.name == subgrammar_name) { + let func = raw(&format!("super::{}::__parse_{}", subgrammar_name, rule_name)); + let subgrammar_module = raw(subgrammar_name); + let converter = subgrammar.converter.as_ref() + .map(|code| raw(&format!(", {}", code))) + .unwrap_or(raw("")); + + let subgrammar_path = quote!{ super::#subgrammar_module }; + + let state_conversion = + quote! { + &mut #subgrammar_path::ParseState::from( + __state.max_err_pos, + __state.suppress_fail, + __state.reparsing_on_error, + &__state.expected + ) + }; + + if cx.result_used { + quote!{ #func(__input, #state_conversion, __pos #converter) } + } else { + quote!{ + match #func(__input, #state_conversion, __pos #converter) { + #subgrammar_path::RuleResult::Matched(pos, _) => Matched(pos, ()), + #subgrammar_path::RuleResult::Failed => Failed, + } + } + } + } else { + compiler.span_error( + format!("No subgrammar named `{}` found", subgrammar_name), + e.span, + Some("subgrammar not found".to_owned()) + ); + quote!() + } + } + TemplateInvoke(ref name, ref params) => { let template = match cx.grammar.templates.get(&name[..]) { Some(x) => x,