123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143open!Importtypet=|Atomof{loc:Positions.range;atom:string;unescaped:stringoption}|Listof{loc:Positions.range;elements:t_or_commentlist}andt_or_comment=|Sexpoft|Commentofcommentandcomment=|Plain_commentof{loc:Positions.range;comment:string}|Sexp_commentof{hash_semi_pos:Positions.pos;comments:commentlist;sexp:t}[@@deriving_inlinesexp_of]letrecsexp_of_t=(function|Atom{loc=loc__002_;atom=atom__004_;unescaped=unescaped__006_}->letbnds__001_=[]inletbnds__001_=letarg__007_=sexp_of_optionsexp_of_stringunescaped__006_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"unescaped";arg__007_]::bnds__001_inletbnds__001_=letarg__005_=sexp_of_stringatom__004_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"atom";arg__005_]::bnds__001_inletbnds__001_=letarg__003_=Positions.sexp_of_rangeloc__002_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"loc";arg__003_]::bnds__001_inSexplib0.Sexp.List(Sexplib0.Sexp.Atom"Atom"::bnds__001_)|List{loc=loc__009_;elements=elements__011_}->letbnds__008_=[]inletbnds__008_=letarg__012_=sexp_of_listsexp_of_t_or_commentelements__011_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"elements";arg__012_]::bnds__008_inletbnds__008_=letarg__010_=Positions.sexp_of_rangeloc__009_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"loc";arg__010_]::bnds__008_inSexplib0.Sexp.List(Sexplib0.Sexp.Atom"List"::bnds__008_):t->Sexplib0.Sexp.t)andsexp_of_t_or_comment=(function|Sexparg0__013_->letres0__014_=sexp_of_targ0__013_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"Sexp";res0__014_]|Commentarg0__015_->letres0__016_=sexp_of_commentarg0__015_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"Comment";res0__016_]:t_or_comment->Sexplib0.Sexp.t)andsexp_of_comment=(function|Plain_comment{loc=loc__018_;comment=comment__020_}->letbnds__017_=[]inletbnds__017_=letarg__021_=sexp_of_stringcomment__020_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"comment";arg__021_]::bnds__017_inletbnds__017_=letarg__019_=Positions.sexp_of_rangeloc__018_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"loc";arg__019_]::bnds__017_inSexplib0.Sexp.List(Sexplib0.Sexp.Atom"Plain_comment"::bnds__017_)|Sexp_comment{hash_semi_pos=hash_semi_pos__023_;comments=comments__025_;sexp=sexp__027_}->letbnds__022_=[]inletbnds__022_=letarg__028_=sexp_of_tsexp__027_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"sexp";arg__028_]::bnds__022_inletbnds__022_=letarg__026_=sexp_of_listsexp_of_commentcomments__025_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"comments";arg__026_]::bnds__022_inletbnds__022_=letarg__024_=Positions.sexp_of_poshash_semi_pos__023_inSexplib0.Sexp.List[Sexplib0.Sexp.Atom"hash_semi_pos";arg__024_]::bnds__022_inSexplib0.Sexp.List(Sexplib0.Sexp.Atom"Sexp_comment"::bnds__022_):comment->Sexplib0.Sexp.t);;[@@@end]letcompare=Caml.compareletcompare_t_or_comment=Caml.compareletcompare_comment=Caml.comparemoduleForget=struct(* In cps to prevent non-tail recursion.
The polymorphism in the signature ensures that each function returns
only through the continuation. *)moduleCps:sigvalforget_t:t->(Sexp.t->'r)->'rvalforget_toc:t_or_comment->(Sexp.toption->'r)->'rvalforget_tocs:t_or_commentlist->(Sexp.tlist->'r)->'rend=structletrecforget_ttk=matchtwith|Atom{atom;_}->k(Sexp.Atomatom)|List{elements;_}->forget_tocselements(funxs->k(Sexp.Listxs))andforget_tocstocsk=matchtocswith|[]->k[]|toc::tocs->forget_toctoc(function|None->forget_tocstocsk|Somex->forget_tocstocs(funxs->k(x::xs)))andforget_toctock=matchtocwith|Comment_->kNone|Sexpt->forget_tt(funx->k(Somex));;endlettx=Cps.forget_tx(funy->y)lett_or_commentx=Cps.forget_tocx(funy->y)lett_or_commentsx=Cps.forget_tocsx(funy->y)end