123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171(**************************************************************************)(* *)(* OCamlFormat *)(* *)(* Copyright (c) Facebook, Inc. and its affiliates. *)(* *)(* This source code is licensed under the MIT license found in *)(* the LICENSE file in the root directory of this source tree. *)(* *)(**************************************************************************)openOcaml_413_extendedincludeParsetreeletequal_core_type:core_type->core_type->bool=Poly.equaltypeuse_file=toplevel_phraselisttyperepl_file=repl_phraselisttype'at=|Structure:structuret|Signature:signaturet|Use_file:use_filet|Core_type:core_typet|Module_type:module_typet|Expression:expressiont|Repl_file:repl_filetletequal(typea)(_:at):a->a->bool=Poly.equalletmap(typea)(x:at)(m:Ast_mapper.mapper):a->a=matchxwith|Structure->m.structurem|Signature ->m.signaturem|Use_file->List.map~f:(m.toplevel_phrasem)|Core_type->m.typm|Module_type->m.module_type m|Expression ->m.exprm|Repl_file->List.map~f:(m.repl_phrasem)moduleParse=structletfix_letop_locs=letbinding_op(m:Ast_mapper.mapper)b=letb'=letloc_start=b.pbop_op.loc.loc_start inletloc_end=b.pbop_exp.pexp_loc.loc_endin{bwith pbop_loc={b.pbop_locwithloc_start;loc_end}}inAst_mapper.default_mapper.binding_opmb'inAst_mapper.{default_mapperwithbinding_op}letlist_pat pat=letreclist_pat_patacc=matchpat.ppat_descwith|Ppat_construct({txt=Lident"[]";loc=_},None)->((* Empty lists are always represented as Lident [] *)matchaccwith[]->None|_->Some(List.revacc))|Ppat_construct({txt=Lident"::";loc=_},Some([],{ppat_desc=Ppat_tuple[hd;({ppat_attributes=[];_}astl)];ppat_attributes=[];_}))->list_pat_ tl(hd::acc)|_->Noneinlist_pat_pat[]letlist_expexp=letreclist_exp_ expacc=matchexp.pexp_descwith|Pexp_construct({txt=Lident"[]";loc=_},None)->((* Empty lists are always represented as Lident [] *)matchaccwith[]->None|_->Some(List.revacc))|Pexp_construct({txt=Lident"::";loc=_},Some{pexp_desc=Pexp_tuple[hd;({pexp_attributes=[];_}astl)];pexp_attributes=[];_})->list_exp_tl(hd::acc)|_->Noneinlist_exp_exp[]letnormalize_lists=letexpr(m:Ast_mapper.mapper)e=lete'=matchlist_expewith|Someexprs->{ewithpexp_desc=Pexp_listexprs}|None->einAst_mapper.default_mapper.exprme'inletpat(m:Ast_mapper.mapper)p=letp'=matchlist_patpwith|Somepats->{pwithppat_desc=Ppat_listpats}|None->pinAst_mapper.default_mapper.patmp'inAst_mapper.{default_mapperwithexpr;pat}letnormalizefgx=mapfgfix_letop_locs@@map fgnormalize_lists@@xletast(typea)(fg:at)lexbuf:a=normalizefg@@matchfgwith|Structure->Parse.implementationlexbuf|Signature->Parse.interfacelexbuf|Use_file->Parse.use_filelexbuf|Core_type->Parse.core_typelexbuf|Module_type->Parse.module_typelexbuf|Expression->Parse.expressionlexbuf|Repl_file->Toplevel_lexer.repl_filelexbufendmodulePprintast=structincludePprintastletuse_file=Format.pp_print_listtop_phraseletrepl_file=Format.pp_print_listrepl_phraseletast(typea):at->_->a->_=function|Structure->structure|Signature->signature|Use_file->use_file|Core_type->core_type|Module_type->module_type|Expression->expression|Repl_file->repl_fileendmodulePrintast=structincludePrintastletuse_file=Format.pp_print_listtop_phraseletrepl_file=Format.pp_print_listrepl_phraseletast(typea):at->_->a->_=function|Structure->implementation|Signature ->interface|Use_file->use_file|Core_type->core_type0|Module_type->module_type0|Expression->expression0|Repl_file->repl_fileendmoduleAsttypes=structincludeAsttypesletis_private=functionPrivate->true|Public->falseletis_open:closed_flag->bool=function|Open->true|Closed ->falseletis_override=functionOverride->true|Fresh->falseletis_mutable=functionMutable->true|Immutable->falseletis_recursive=functionRecursive->true|Nonrecursive->falseend