File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -226,25 +226,34 @@ fn param_ops_path(param_type: &str) -> &'static str {
226
226
}
227
227
}
228
228
229
+ fn parse_expr ( it : & mut Cursor < ' _ > ) -> TokenStream {
230
+ let mut tt = Vec :: new ( ) ;
231
+ while !it. eof ( ) {
232
+ if let Some ( ( punct, _) ) = it. punct ( ) {
233
+ if let ',' | ';' = punct. as_char ( ) {
234
+ break ;
235
+ }
236
+ }
237
+ let ( token, next) = it. token_tree ( ) . unwrap ( ) ;
238
+ tt. push ( token) ;
239
+ * it = next;
240
+ }
241
+ if tt. is_empty ( ) {
242
+ panic ! ( "Expected expression" ) ;
243
+ }
244
+ tt. into_iter ( ) . collect ( )
245
+ }
246
+
229
247
fn expect_simple_param_val ( param_type : & str ) -> Box < dyn Fn ( & mut Cursor < ' _ > ) -> String > {
230
248
match param_type {
231
- "bool" => Box :: new ( |param_it| {
232
- let ( ident, next) = param_it. ident ( ) . expect ( "Expected ident" ) ;
233
- * param_it = next;
234
- ident. to_string ( )
235
- } ) ,
236
249
"str" => Box :: new ( |param_it| {
237
250
let s = expect_string ( param_it) ;
238
251
format ! (
239
252
"kernel::module_param::StringParam::Ref({})" ,
240
253
Literal :: byte_string( s. as_bytes( ) )
241
254
)
242
255
} ) ,
243
- _ => Box :: new ( |param_it| {
244
- let ( lit, next) = param_it. literal ( ) . expect ( "Expected literal" ) ;
245
- * param_it = next;
246
- lit. to_string ( )
247
- } ) ,
256
+ _ => Box :: new ( |param_it| parse_expr ( param_it) . to_string ( ) ) ,
248
257
}
249
258
}
250
259
You can’t perform that action at this time.
0 commit comments