11#[ cfg( feature = "compiled-path" ) ]
22pub ( crate ) mod parse_impl {
33 use crate :: ast:: parse:: { JSPathParser , Rule } ;
4- use crate :: ast:: { kw, CompOp , IndexSelector , Main , NameSelector } ;
54 use crate :: ast:: {
65 AbsSingularQuery , AtomExpr , Bool , BracketName , BracketedSelection , ChildSegment , CompExpr ,
7- Comparable , DescendantSegment , FilterSelector , FunctionArgument , FunctionExpr , FunctionName , IndexSegment ,
8- JPQuery , JSInt , JSString , Literal , LogicalExpr , LogicalExprAnd , MemberNameShorthand ,
9- NameSegment , NotOp , Null , Number , ParenExpr , PestIgnoredPunctuated , PestLiteralWithoutRule ,
10- RelQuery , RelSingularQuery , Root , Segment , Segments , Selector , SingularQuery ,
11- SingularQuerySegment , SingularQuerySegments , SliceEnd , SliceSelector , SliceStart , SliceStep , Test , TestExpr ,
12- WildcardSelector , WildcardSelectorOrMemberNameShorthand , EOI ,
6+ Comparable , DescendantSegment , EOI , FilterSelector , FunctionArgument , FunctionExpr ,
7+ FunctionName , IndexSegment , JPQuery , JSInt , JSString , Literal , LogicalExpr , LogicalExprAnd ,
8+ MemberNameShorthand , NameSegment , NotOp , Null , Number , ParenExpr , PestIgnoredPunctuated ,
9+ PestLiteralWithoutRule , RelQuery , RelSingularQuery , Root , Segment , Segments , Selector ,
10+ SingularQuery , SingularQuerySegment , SingularQuerySegments , SliceEnd , SliceSelector ,
11+ SliceStart , SliceStep , Test , TestExpr , WildcardSelector ,
12+ WildcardSelectorOrMemberNameShorthand ,
1313 } ;
14+ use crate :: ast:: { CompOp , IndexSelector , Main , NameSelector , kw} ;
1415 use pest:: Parser ;
1516 use proc_macro2:: { Ident , TokenStream } ;
16- use quote:: { quote , ToTokens } ;
17+ use quote:: { ToTokens , quote } ;
1718 use syn:: parse:: { Parse , ParseStream } ;
1819 use syn:: punctuated:: Punctuated ;
19- use syn:: { token, LitBool , LitInt , LitStr , Token } ;
2020 use syn:: token:: Token ;
21+ use syn:: { LitBool , LitInt , LitStr , Token , token} ;
2122
2223 pub trait ParseUtilsExt : Parse {
2324 fn peek ( input : ParseStream ) -> bool ;
@@ -43,10 +44,16 @@ pub(crate) mod parse_impl {
4344 Ok ( PestIgnoredPunctuated ( Punctuated :: parse_terminated ( input) ?) )
4445 }
4546
46- pub ( crate ) fn parse_separated_nonempty ( input : ParseStream ) -> syn:: Result < Self > where P : Token {
47+ pub ( crate ) fn parse_separated_nonempty ( input : ParseStream ) -> syn:: Result < Self >
48+ where
49+ P : Token ,
50+ {
4751 let res = Punctuated :: parse_separated_nonempty ( input) ?;
4852 if res. is_empty ( ) {
49- Err ( input. error ( format ! ( "Expected at least one {}" , std:: any:: type_name:: <T >( ) ) ) )
53+ Err ( input. error ( format ! (
54+ "Expected at least one {}" ,
55+ std:: any:: type_name:: <T >( )
56+ ) ) )
5057 } else {
5158 Ok ( PestIgnoredPunctuated ( res) )
5259 }
@@ -558,9 +565,15 @@ pub(crate) mod parse_impl {
558565 impl ToTokens for Comparable {
559566 fn to_tokens ( & self , tokens : & mut TokenStream ) {
560567 let variant = match self {
561- Comparable :: Literal ( inner) => { quote ! ( new_literal( #inner) ) }
562- Comparable :: SingularQuery ( inner) => { quote ! ( new_singular_query( #inner) ) }
563- Comparable :: FunctionExpr ( inner) => { quote ! ( new_function_expr( #inner) ) }
568+ Comparable :: Literal ( inner) => {
569+ quote ! ( new_literal( #inner) )
570+ }
571+ Comparable :: SingularQuery ( inner) => {
572+ quote ! ( new_singular_query( #inner) )
573+ }
574+ Comparable :: FunctionExpr ( inner) => {
575+ quote ! ( new_function_expr( #inner) )
576+ }
564577 } ;
565578 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: Comparable :: #variant) ) ;
566579 }
@@ -569,10 +582,18 @@ pub(crate) mod parse_impl {
569582 impl ToTokens for Literal {
570583 fn to_tokens ( & self , tokens : & mut TokenStream ) {
571584 let variant = match self {
572- Literal :: Number ( inner) => { quote ! ( new_number( #inner) ) }
573- Literal :: String ( inner) => { quote ! ( new_string( #inner) ) }
574- Literal :: Bool ( inner) => { quote ! ( new_bool( #inner) ) }
575- Literal :: Null ( inner) => { quote ! ( new_null( #inner) ) }
585+ Literal :: Number ( inner) => {
586+ quote ! ( new_number( #inner) )
587+ }
588+ Literal :: String ( inner) => {
589+ quote ! ( new_string( #inner) )
590+ }
591+ Literal :: Bool ( inner) => {
592+ quote ! ( new_bool( #inner) )
593+ }
594+ Literal :: Null ( inner) => {
595+ quote ! ( new_null( #inner) )
596+ }
576597 } ;
577598 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: Literal :: #variant) )
578599 }
@@ -581,8 +602,12 @@ pub(crate) mod parse_impl {
581602 impl ToTokens for Number {
582603 fn to_tokens ( & self , tokens : & mut TokenStream ) {
583604 let variant = match self {
584- Number :: Int ( inner) => { quote ! ( new_int( #inner) ) }
585- Number :: Float ( inner) => { quote ! ( new_float( #inner) ) }
605+ Number :: Int ( inner) => {
606+ quote ! ( new_int( #inner) )
607+ }
608+ Number :: Float ( inner) => {
609+ quote ! ( new_float( #inner) )
610+ }
586611 } ;
587612 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: Number :: #variant) )
588613 }
@@ -591,8 +616,12 @@ pub(crate) mod parse_impl {
591616 impl ToTokens for SingularQuery {
592617 fn to_tokens ( & self , tokens : & mut TokenStream ) {
593618 let variant = match self {
594- SingularQuery :: RelSingularQuery ( inner) => { quote ! ( new_rel_singular_query( #inner) ) }
595- SingularQuery :: AbsSingularQuery ( inner) => { quote ! ( new_abs_singular_query( #inner) ) }
619+ SingularQuery :: RelSingularQuery ( inner) => {
620+ quote ! ( new_rel_singular_query( #inner) )
621+ }
622+ SingularQuery :: AbsSingularQuery ( inner) => {
623+ quote ! ( new_abs_singular_query( #inner) )
624+ }
596625 } ;
597626 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: SingularQuery :: #variant ) )
598627 }
@@ -610,7 +639,11 @@ pub(crate) mod parse_impl {
610639
611640 impl ToTokens for FunctionExpr {
612641 fn to_tokens ( & self , tokens : & mut TokenStream ) {
613- let Self { name, paren : _, args } = self ;
642+ let Self {
643+ name,
644+ paren : _,
645+ args,
646+ } = self ;
614647 tokens. extend ( quote ! {
615648 :: jsonpath_ast:: ast:: FunctionExpr :: new(
616649 #name,
@@ -624,12 +657,24 @@ pub(crate) mod parse_impl {
624657 impl ToTokens for CompOp {
625658 fn to_tokens ( & self , tokens : & mut TokenStream ) {
626659 let variant = match self {
627- CompOp :: Eq ( _) => { quote ! ( new_eq) }
628- CompOp :: Ne ( _) => { quote ! ( new_ne) }
629- CompOp :: Le ( _) => { quote ! ( new_le) }
630- CompOp :: Ge ( _) => { quote ! ( new_ge) }
631- CompOp :: Lt ( _) => { quote ! ( new_lt) }
632- CompOp :: Gt ( _) => { quote ! ( new_gt) }
660+ CompOp :: Eq ( _) => {
661+ quote ! ( new_eq)
662+ }
663+ CompOp :: Ne ( _) => {
664+ quote ! ( new_ne)
665+ }
666+ CompOp :: Le ( _) => {
667+ quote ! ( new_le)
668+ }
669+ CompOp :: Ge ( _) => {
670+ quote ! ( new_ge)
671+ }
672+ CompOp :: Lt ( _) => {
673+ quote ! ( new_lt)
674+ }
675+ CompOp :: Gt ( _) => {
676+ quote ! ( new_gt)
677+ }
633678 } ;
634679 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: CompOp :: #variant( Default :: default ( ) ) ) ) ;
635680 }
@@ -679,7 +724,8 @@ pub(crate) mod parse_impl {
679724 for segment in self . segments . iter ( ) {
680725 out. extend ( quote ! ( #segment, ) ) ;
681726 }
682- tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: SingularQuerySegments :: new( Vec :: from( [ #out] ) ) ) ) ;
727+ tokens
728+ . extend ( quote ! ( :: jsonpath_ast:: ast:: SingularQuerySegments :: new( Vec :: from( [ #out] ) ) ) ) ;
683729 }
684730 }
685731
@@ -777,9 +823,15 @@ pub(crate) mod parse_impl {
777823 impl ToTokens for Test {
778824 fn to_tokens ( & self , tokens : & mut TokenStream ) {
779825 let variant = match self {
780- Test :: RelQuery ( inner) => { quote ! ( new_rel_query( #inner) ) }
781- Test :: JPQuery ( inner) => { quote ! ( new_jp_query( #inner) ) }
782- Test :: FunctionExpr ( inner) => { quote ! ( new_function_expr( #inner) ) }
826+ Test :: RelQuery ( inner) => {
827+ quote ! ( new_rel_query( #inner) )
828+ }
829+ Test :: JPQuery ( inner) => {
830+ quote ! ( new_jp_query( #inner) )
831+ }
832+ Test :: FunctionExpr ( inner) => {
833+ quote ! ( new_function_expr( #inner) )
834+ }
783835 } ;
784836 tokens. extend ( quote ! ( :: jsonpath_ast:: ast:: Test :: #variant) ) ;
785837 }
0 commit comments