fix(CCParse): fix issue in recurse

recursively parsing a slice means we temporarily switch the state
to the slice; but once the sub-parser returns we need to switch back to
the old state.
This commit is contained in:
Simon Cruanes 2023-04-10 16:31:16 -04:00
parent 6d013251fe
commit 10a8a7ce0f
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -1,4 +1,3 @@
open CCShims_ open CCShims_
module Memo_tbl = Hashtbl.Make (struct module Memo_tbl = Hashtbl.Make (struct
@ -300,11 +299,11 @@ end
let recurse slice p : _ t = let recurse slice p : _ t =
{ {
run = run =
(fun _st ~ok ~err -> (fun st ~ok ~err ->
(* make sure these states are related. all slices share the (* make sure these states are related. all slices share the
same reference as the initial state they derive from. *) same reference as the initial state they derive from. *)
assert (CCShims_.Stdlib.(_st.cs == slice.cs)); assert (CCShims_.Stdlib.(st.cs == slice.cs));
p.run slice ~ok ~err); p.run slice ~ok:(fun _st x -> ok st x) ~err);
} }
let all = let all =