@@ -3,16 +3,17 @@ use nom::branch::alt;
33use nom:: bytes:: complete:: { escaped, is_a, is_not, tag} ;
44use nom:: character:: complete:: { alpha1, char, digit1, none_of, one_of} ;
55use nom:: combinator:: { map, map_res, not, opt, recognize, value} ;
6- use nom:: error:: context; //, VerboseError};
6+ use nom:: error:: context;
77use nom:: multi:: { fold_many0, many0, separated_list0} ;
8- use nom:: sequence:: { delimited, pair, preceded, terminated, tuple} ;
8+ use nom:: sequence:: { delimited, pair, preceded, terminated} ;
9+ use nom:: Parser as _;
910use std:: str:: { from_utf8, Utf8Error } ;
1011
1112pub fn expression ( input : & [ u8 ] ) -> PResult < & str > {
1213 map_res (
1314 recognize ( context (
1415 "Expected rust expression" ,
15- tuple ( (
16+ (
1617 map_res ( alt ( ( tag ( "&" ) , tag ( "*" ) , tag ( "" ) ) ) , input_to_str) ,
1718 alt ( (
1819 rust_name,
@@ -34,10 +35,11 @@ pub fn expression(input: &[u8]) -> PResult<&str> {
3435 || ( ) ,
3536 |_, _| ( ) ,
3637 ) ,
37- ) ) ,
38+ ) ,
3839 ) ) ,
3940 input_to_str,
40- ) ( input)
41+ )
42+ . parse ( input)
4143}
4244
4345pub fn input_to_str ( s : & [ u8 ] ) -> Result < & str , Utf8Error > {
@@ -48,7 +50,8 @@ pub fn comma_expressions(input: &[u8]) -> PResult<String> {
4850 map (
4951 separated_list0 ( preceded ( tag ( "," ) , many0 ( tag ( " " ) ) ) , expression) ,
5052 |list : Vec < _ > | list. join ( ", " ) ,
51- ) ( input)
53+ )
54+ . parse ( input)
5255}
5356
5457pub fn rust_name ( input : & [ u8 ] ) -> PResult < & str > {
@@ -58,14 +61,15 @@ pub fn rust_name(input: &[u8]) -> PResult<&str> {
5861 opt ( is_a ( "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ) ) ,
5962 ) ) ,
6063 input_to_str,
61- ) ( input)
64+ ) . parse ( input)
6265}
6366
6467fn expr_in_parens ( input : & [ u8 ] ) -> PResult < & str > {
6568 map_res (
6669 recognize ( delimited ( tag ( "(" ) , expr_inside_parens, tag ( ")" ) ) ) ,
6770 input_to_str,
68- ) ( input)
71+ )
72+ . parse ( input)
6973}
7074
7175fn expr_in_brackets ( input : & [ u8 ] ) -> PResult < & str > {
@@ -84,7 +88,8 @@ fn expr_in_brackets(input: &[u8]) -> PResult<&str> {
8488 tag ( "]" ) ,
8589 ) ) ,
8690 input_to_str,
87- ) ( input)
91+ )
92+ . parse ( input)
8893}
8994
9095pub fn expr_in_braces ( input : & [ u8 ] ) -> PResult < & str > {
@@ -103,7 +108,8 @@ pub fn expr_in_braces(input: &[u8]) -> PResult<&str> {
103108 tag ( "}" ) ,
104109 ) ) ,
105110 input_to_str,
106- ) ( input)
111+ )
112+ . parse ( input)
107113}
108114
109115pub fn expr_inside_parens ( input : & [ u8 ] ) -> PResult < & str > {
@@ -118,7 +124,8 @@ pub fn expr_inside_parens(input: &[u8]) -> PResult<&str> {
118124 value ( ( ) , terminated ( tag ( "/" ) , none_of ( "*" ) ) ) ,
119125 ) ) ) ) ,
120126 input_to_str,
121- ) ( input)
127+ )
128+ . parse ( input)
122129}
123130
124131pub fn quoted_string ( input : & [ u8 ] ) -> PResult < & str > {
@@ -129,7 +136,8 @@ pub fn quoted_string(input: &[u8]) -> PResult<&str> {
129136 char ( '"' ) ,
130137 ) ) ,
131138 input_to_str,
132- ) ( input)
139+ )
140+ . parse ( input)
133141}
134142
135143pub fn rust_comment ( input : & [ u8 ] ) -> PResult < & [ u8 ] > {
@@ -140,7 +148,8 @@ pub fn rust_comment(input: &[u8]) -> PResult<&[u8]> {
140148 terminated ( tag ( "*" ) , not ( tag ( "/" ) ) ) ,
141149 ) ) ) ) ,
142150 tag ( "*/" ) ,
143- ) ( input)
151+ )
152+ . parse ( input)
144153}
145154
146155#[ cfg( test) ]
0 commit comments