File tree 1 file changed +20
-8
lines changed
1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -238,13 +238,23 @@ fn param_ops_path(param_type: &str) -> &'static str {
238
238
}
239
239
}
240
240
241
+ fn parse_expr ( it : & mut Cursor < ' _ > ) -> TokenStream {
242
+ let mut tt = Vec :: new ( ) ;
243
+ while !it. eof ( ) {
244
+ if let Some ( ( punct, _) ) = it. punct ( ) {
245
+ if let ',' | ';' = punct. as_char ( ) {
246
+ break ;
247
+ }
248
+ }
249
+ let ( token, next) = it. token_tree ( ) . unwrap ( ) ;
250
+ tt. push ( token) ;
251
+ * it = next;
252
+ }
253
+ tt. into_iter ( ) . collect ( )
254
+ }
255
+
241
256
fn expect_simple_param_val ( param_type : & str ) -> Box < dyn Fn ( & mut Cursor < ' _ > ) -> String > {
242
257
match param_type {
243
- "bool" => Box :: new ( |param_it| {
244
- let ( ident, next) = param_it. ident ( ) . expect ( "Expected ident" ) ;
245
- * param_it = next;
246
- ident. to_string ( )
247
- } ) ,
248
258
"str" => Box :: new ( |param_it| {
249
259
let s = expect_string ( param_it) ;
250
260
format ! (
@@ -253,9 +263,11 @@ fn expect_simple_param_val(param_type: &str) -> Box<dyn Fn(&mut Cursor<'_>) -> S
253
263
)
254
264
} ) ,
255
265
_ => Box :: new ( |param_it| {
256
- let ( lit, next) = param_it. literal ( ) . expect ( "Expected literal" ) ;
257
- * param_it = next;
258
- lit. to_string ( )
266
+ let expr = parse_expr ( param_it) ;
267
+ if expr. is_empty ( ) {
268
+ panic ! ( "Expected expression" ) ;
269
+ }
270
+ expr. to_string ( )
259
271
} ) ,
260
272
}
261
273
}
You can’t perform that action at this time.
0 commit comments