123456789101112131415161718192021222324252627282930313233343536373839404142434445464748open!Import(** Automaton stack represents a prefix of a sexp (or of a sexp sequence) while it's being
parsed. We have three different types of the stack depending on how much detail about
the sexp structure is being recorded (just the sexp, sexp with comments and positions
(CST), or just positions. *)moduletypeAutomaton_stack=sigmoduleFor_cst:sigtypet=|Empty(** at top-level *)|T_or_commentofCst.t_or_comment*t(** after the given sexp or comment *)|OpenofPositions.pos*t(** after the opening paren *)|In_sexp_commentof{hash_semi_pos:Positions.pos;rev_comments:Cst.commentlist;stack:t}(** [In_sexp_comment] only indicates if the next s-expression is to be commented
out, but if we are nested below parens below an sexp comment, the stack would
look like [Open (.., In_sexp_comment ..)]. *)valempty:t(** Raises if [t] contains a partial sexp. *)valget_many:t->Cst.t_or_commentlistend(** The recorded positions are stored elsewhere *)moduleJust_positions:sigtypet=unitvalempty:tendtypet=|Empty|Openoft|SexpofSexp.t*tvalempty:t(** Raises if [t] is not exactly one complete sexp. *)valget_single:t->Sexp.t(** Raises if [t] contains a partial sexp. *)valget_many:t->Sexp.tlistend