@@ -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,10 @@ pub fn expression(input: &[u8]) -> PResult<&str> {
3435 || ( ) ,
3536 |_, _| ( ) ,
3637 ) ,
37- ) ) ,
38+ ) ,
3839 ) ) ,
3940 input_to_str,
40- ) ( input)
41+ ) . parse ( input)
4142}
4243
4344pub fn input_to_str ( s : & [ u8 ] ) -> Result < & str , Utf8Error > {
@@ -48,7 +49,7 @@ pub fn comma_expressions(input: &[u8]) -> PResult<String> {
4849 map (
4950 separated_list0 ( preceded ( tag ( "," ) , many0 ( tag ( " " ) ) ) , expression) ,
5051 |list : Vec < _ > | list. join ( ", " ) ,
51- ) ( input)
52+ ) . parse ( input)
5253}
5354
5455pub fn rust_name ( input : & [ u8 ] ) -> PResult < & str > {
@@ -58,14 +59,14 @@ pub fn rust_name(input: &[u8]) -> PResult<&str> {
5859 opt ( is_a ( "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ) ) ,
5960 ) ) ,
6061 input_to_str,
61- ) ( input)
62+ ) . parse ( input)
6263}
6364
6465fn expr_in_parens ( input : & [ u8 ] ) -> PResult < & str > {
6566 map_res (
6667 recognize ( delimited ( tag ( "(" ) , expr_inside_parens, tag ( ")" ) ) ) ,
6768 input_to_str,
68- ) ( input)
69+ ) . parse ( input)
6970}
7071
7172fn expr_in_brackets ( input : & [ u8 ] ) -> PResult < & str > {
@@ -84,7 +85,7 @@ fn expr_in_brackets(input: &[u8]) -> PResult<&str> {
8485 tag ( "]" ) ,
8586 ) ) ,
8687 input_to_str,
87- ) ( input)
88+ ) . parse ( input)
8889}
8990
9091pub fn expr_in_braces ( input : & [ u8 ] ) -> PResult < & str > {
@@ -103,7 +104,7 @@ pub fn expr_in_braces(input: &[u8]) -> PResult<&str> {
103104 tag ( "}" ) ,
104105 ) ) ,
105106 input_to_str,
106- ) ( input)
107+ ) . parse ( input)
107108}
108109
109110pub fn expr_inside_parens ( input : & [ u8 ] ) -> PResult < & str > {
@@ -118,7 +119,7 @@ pub fn expr_inside_parens(input: &[u8]) -> PResult<&str> {
118119 value ( ( ) , terminated ( tag ( "/" ) , none_of ( "*" ) ) ) ,
119120 ) ) ) ) ,
120121 input_to_str,
121- ) ( input)
122+ ) . parse ( input)
122123}
123124
124125pub fn quoted_string ( input : & [ u8 ] ) -> PResult < & str > {
@@ -129,7 +130,7 @@ pub fn quoted_string(input: &[u8]) -> PResult<&str> {
129130 char ( '"' ) ,
130131 ) ) ,
131132 input_to_str,
132- ) ( input)
133+ ) . parse ( input)
133134}
134135
135136pub fn rust_comment ( input : & [ u8 ] ) -> PResult < & [ u8 ] > {
@@ -140,7 +141,7 @@ pub fn rust_comment(input: &[u8]) -> PResult<&[u8]> {
140141 terminated ( tag ( "*" ) , not ( tag ( "/" ) ) ) ,
141142 ) ) ) ) ,
142143 tag ( "*/" ) ,
143- ) ( input)
144+ ) . parse ( input)
144145}
145146
146147#[ cfg( test) ]
0 commit comments