11use winnow:: {
2- PResult , Parser ,
2+ ModalResult , Parser ,
33 ascii:: space0,
44 combinator:: { alt, delimited, eof, opt, separated} ,
55 stream:: AsChar ,
@@ -12,11 +12,11 @@ use super::{Address, Identifier, StructTag, TypeTag};
1212// r"(?:[a-zA-Z][a-zA-Z0-9_]*)|(?:_[a-zA-Z0-9_]+)";
1313static MAX_IDENTIFIER_LENGTH : usize = 128 ;
1414
15- pub ( super ) fn parse_identifier ( mut input : & str ) -> PResult < & str > {
15+ pub ( super ) fn parse_identifier ( mut input : & str ) -> ModalResult < & str > {
1616 ( identifier, eof) . take ( ) . parse_next ( & mut input)
1717}
1818
19- fn identifier < ' s > ( input : & mut & ' s str ) -> PResult < & ' s str > {
19+ fn identifier < ' s > ( input : & mut & ' s str ) -> ModalResult < & ' s str > {
2020 alt ( (
2121 ( one_of ( |c : char | c. is_alpha ( ) ) , valid_remainder ( 0 ) ) ,
2222 ( '_' , valid_remainder ( 1 ) ) ,
@@ -38,17 +38,17 @@ fn valid_remainder<'a>(
3838 }
3939}
4040
41- fn parse_address < ' s > ( input : & mut & ' s str ) -> PResult < & ' s str > {
41+ fn parse_address < ' s > ( input : & mut & ' s str ) -> ModalResult < & ' s str > {
4242 ( "0x" , take_while ( 1 ..=64 , AsChar :: is_hex_digit) )
4343 . take ( )
4444 . parse_next ( input)
4545}
4646
47- pub ( super ) fn parse_type_tag ( mut input : & str ) -> PResult < TypeTag > {
47+ pub ( super ) fn parse_type_tag ( mut input : & str ) -> ModalResult < TypeTag > {
4848 ( type_tag, eof) . parse_next ( & mut input) . map ( |( t, _) | t)
4949}
5050
51- fn type_tag ( input : & mut & str ) -> PResult < TypeTag > {
51+ fn type_tag ( input : & mut & str ) -> ModalResult < TypeTag > {
5252 alt ( (
5353 "u8" . value ( TypeTag :: U8 ) ,
5454 "u16" . value ( TypeTag :: U16 ) ,
@@ -65,11 +65,11 @@ fn type_tag(input: &mut &str) -> PResult<TypeTag> {
6565 . parse_next ( input)
6666}
6767
68- pub ( super ) fn parse_struct_tag ( mut input : & str ) -> PResult < StructTag > {
68+ pub ( super ) fn parse_struct_tag ( mut input : & str ) -> ModalResult < StructTag > {
6969 ( struct_tag, eof) . parse_next ( & mut input) . map ( |( s, _) | s)
7070}
7171
72- fn struct_tag ( input : & mut & str ) -> PResult < StructTag > {
72+ fn struct_tag ( input : & mut & str ) -> ModalResult < StructTag > {
7373 let ( address, _, module, _, name) = (
7474 parse_address. try_map ( |s| s. parse :: < Address > ( ) ) ,
7575 "::" ,
@@ -92,7 +92,7 @@ fn struct_tag(input: &mut &str) -> PResult<StructTag> {
9292 } )
9393}
9494
95- fn generics ( input : & mut & str ) -> PResult < Vec < TypeTag > > {
95+ fn generics ( input : & mut & str ) -> ModalResult < Vec < TypeTag > > {
9696 separated ( 1 .., delimited ( space0, type_tag, space0) , "," ) . parse_next ( input)
9797}
9898
0 commit comments