@@ -210,7 +210,7 @@ print_groups(FILE *f, const struct fsm_options *opt,
210
210
}
211
211
212
212
static int
213
- print_case (FILE * f , const struct ir * ir ,
213
+ print_case (FILE * f , const struct ir * ir , fsm_state_t state_id ,
214
214
const struct fsm_options * opt ,
215
215
const struct fsm_hooks * hooks ,
216
216
const char * cp ,
@@ -222,10 +222,16 @@ print_case(FILE *f, const struct ir *ir,
222
222
assert (f != NULL );
223
223
assert (cs != NULL );
224
224
225
+ assert (state_id < ir -> n );
226
+ const struct fsm_state_metadata state_metadata = {
227
+ .end_ids = ir -> states [state_id ].endids .ids ,
228
+ .end_id_count = ir -> states [state_id ].endids .count ,
229
+ };
230
+
225
231
switch (cs -> strategy ) {
226
232
case IR_NONE :
227
233
fprintf (f , "\t\t\t" );
228
- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
234
+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
229
235
return -1 ;
230
236
}
231
237
fprintf (f , "\n" );
@@ -254,7 +260,7 @@ print_case(FILE *f, const struct ir *ir,
254
260
print_groups (f , opt , ir_indexof (ir , cs ), cs -> u .partial .groups , cs -> u .partial .n );
255
261
256
262
fprintf (f , "\t\t\tdefault: " );
257
- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
263
+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
258
264
return -1 ;
259
265
}
260
266
fprintf (f , "\n" );
@@ -285,7 +291,7 @@ print_case(FILE *f, const struct ir *ir,
285
291
286
292
print_ranges (f , opt , cs -> u .error .error .ranges , cs -> u .error .error .n );
287
293
fprintf (f , " " );
288
- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
294
+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
289
295
return -1 ;
290
296
}
291
297
fprintf (f , "\n" );
@@ -398,7 +404,7 @@ print_endstates(FILE *f,
398
404
399
405
/* unexpected EOT */
400
406
fprintf (f , "\tdefault: " );
401
- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
407
+ if (-1 == print_hook_reject (f , opt , hooks , NULL , default_reject , NULL )) {
402
408
return -1 ;
403
409
}
404
410
fprintf (f , "\n" );
@@ -435,7 +441,7 @@ fsm_print_cfrag(FILE *f, const struct ir *ir,
435
441
}
436
442
fprintf (f , "\n" );
437
443
438
- if (-1 == print_case (f , ir , opt , hooks , cp , & ir -> states [i ])) {
444
+ if (-1 == print_case (f , ir , i , opt , hooks , cp , & ir -> states [i ])) {
439
445
return -1 ;
440
446
}
441
447
@@ -500,6 +506,12 @@ fsm_print_c_body(FILE *f, const struct ir *ir,
500
506
break ;
501
507
}
502
508
509
+ if (hooks -> advance != NULL ) {
510
+ if (-1 == hooks -> advance (f , opt , cp , hooks -> hook_opaque )) {
511
+ return -1 ;
512
+ }
513
+ }
514
+
503
515
if (-1 == fsm_print_cfrag (f , ir , opt , hooks , cp )) {
504
516
return -1 ;
505
517
}
0 commit comments