···224224225225 and to_dyn sem { id = _; def } = dyn_of_def sem def
226226227227- let with_sem prev next fmt pp () =
228228- let open Fmt in
229229- let wrapped fmt () = sexp fmt (Format.asprintf "%a" Sem.pp next) pp () in
230230- match prev with
231231- | None -> wrapped fmt ()
232232- | Some prev -> if Sem.equal prev next then pp fmt () else wrapped fmt ()
233233- ;;
234234-235227 let rec pp_with_sem sem ch e =
236228 let open Fmt in
237229 match e.def with
238230 | Cst l -> sexp ch "cst" Cset.pp l
239231 | Alt l -> sexp ch "alt" (list (pp_with_sem sem)) l
240232 | Seq (k, e, e') ->
241241- let pp ch () =
242242- let sem = Some k in
243243- sexp ch "seq" (pair (pp_with_sem sem) (pp_with_sem sem)) (e, e')
244244- in
245245- with_sem sem k ch pp ()
233233+ sexp ch "seq" (triple Sem.pp (pp_with_sem sem) (pp_with_sem sem)) (k, e, e')
246234 | Eps -> str ch "eps"
247235 | Rep (_rk, k, e) -> sexp ch "rep" (pair Sem.pp (pp_with_sem (Some k))) (k, e)
248236 | Mark i -> sexp ch "mark" Mark.pp i
···495483 | TExp (marks, _) | TMatch marks -> f marks)
496484 ;;
497485498498- let rec print_state_rec sem ch e (y : Expr.t) =
486486+ let rec print_state_rec ch e (y : Expr.t) =
499487 match e with
500488 | TMatch marks -> Format.fprintf ch "@[<2>(TMatch@ %a)@]" Marks.pp marks
501501- | TSeq (sem', l', x) ->
502502- let pp ch () =
503503- let sem = Some sem' in
504504- Format.fprintf ch "@[<2>(TSeq@ ";
505505- print_state_lst sem ch l' x;
506506- Format.fprintf ch "@ %a)@]" (Expr.pp_with_sem sem) x
507507- in
508508- with_sem sem sem' ch pp ()
489489+ | TSeq (sem, l', x) ->
490490+ Format.fprintf ch "@[<2>(TSeq@ %a@ " Sem.pp sem;
491491+ print_state_lst ch l' x;
492492+ Format.fprintf ch "@ %a)@]" Expr.pp x
509493 | TExp (marks, { def = Eps; _ }) ->
510494 Format.fprintf ch "@[<2>(TExp@ %a@ (%a)@ (eps))@]" Id.pp y.id Marks.pp marks
511495 | TExp (marks, x) ->
512512- Format.fprintf
513513- ch
514514- "@[<2>(TExp@ %a@ (%a)@ %a)@]"
515515- Id.pp
516516- x.id
517517- Marks.pp
518518- marks
519519- (Expr.pp_with_sem sem)
520520- x
496496+ Format.fprintf ch "@[<2>(TExp@ %a@ (%a)@ %a)@]" Id.pp x.id Marks.pp marks Expr.pp x
521497522522- and print_state_lst sem ch l y =
498498+ and print_state_lst ch l y =
523499 match l with
524500 | [] -> Format.fprintf ch "()"
525501 | e :: rem ->
526526- print_state_rec sem ch e y;
502502+ print_state_rec ch e y;
527503 List.iter rem ~f:(fun e ->
528504 Format.fprintf ch "@ | ";
529529- print_state_rec sem ch e y)
505505+ print_state_rec ch e y)
530506 ;;
531507532532- let pp ch t = print_state_lst None ch [ t ] { id = Id.zero; def = Eps }
508508+ let pp ch t = print_state_lst ch [ t ] { id = Id.zero; def = Eps }
533509534510 let rec first_match = function
535511 | [] -> None