1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192(**************************************************************************
* *
* 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. *
* *
**************************************************************************)openParser_standardincludeParsetree(* we always want all extensions enabled in ocamlformat *)let()=Language_extension.set_universe_and_enable_allLanguage_extension.Universe.Alphatypeuse_file=toplevel_phraselisttype'at=|Structure:structuret|Signature:signaturet|Use_file:use_filet|Core_type:core_typet|Module_type:module_typet|Expression:expressiont(* not implemented *)|Repl_file:unitt|Documentation:unitttypeany_t=Any:'at->any_t[@@unboxed]letof_syntax=function|Syntax.Structure->AnyStructure|Signature->AnySignature|Use_file->AnyUse_file|Core_type->AnyCore_type|Module_type->AnyModule_type|Expression->AnyExpression|Repl_file->AnyRepl_file|Documentation->AnyDocumentationletequal(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.filter_map~f:(funx->matchm.toplevel_phrasemxwith|Ptop_def[]->None|Ptop_def_asx->Somex|Ptop_dir_asx->Somex)|Core_type->m.typm|Module_type->m.module_typem|Expression ->m.exprm|Repl_file->Fn.id|Documentation->Fn.idmoduleParse=structletast(typea)(fg:at)~input_namestr:a=letlexbuf=Lexing.from_stringstrinLocation.initlexbufinput_name;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->()|Documentation->()endmodulePrintast=structincludePrintastletuse_file=Format.pp_print_listtop_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->fun__->()|Documentation->fun__->()end