123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214(* This file is used to control what we use from the current compiler and what is embed in
this library.
It must be opened in all modules, especially the ones coming from the compiler.
*)(*$ open Ast_cinaps_helpers $*)moduleJs=Versions.OCaml_500moduleOcaml=Versions.OCaml_currentmoduleSelect_ast(Ocaml:Versions.OCaml_version)=structincludeJsmoduleType=structtype('js,'ocaml)t=(*$ foreach_type (fun _ s ->
printf
" | %s\n\
\ : ( Js.Ast.Parsetree.%s,\n\
\ Ocaml.Ast.Parsetree.%s )\n\
\ t\n"
(capitalize_ascii s) s s
)
*)|Structure:(Js.Ast.Parsetree.structure,Ocaml.Ast.Parsetree.structure)t|Signature:(Js.Ast.Parsetree.signature,Ocaml.Ast.Parsetree.signature)t|Toplevel_phrase:(Js.Ast.Parsetree.toplevel_phrase,Ocaml.Ast.Parsetree.toplevel_phrase)t|Core_type:(Js.Ast.Parsetree.core_type,Ocaml.Ast.Parsetree.core_type)t|Expression:(Js.Ast.Parsetree.expression,Ocaml.Ast.Parsetree.expression)t|Pattern:(Js.Ast.Parsetree.pattern,Ocaml.Ast.Parsetree.pattern)t|Case:(Js.Ast.Parsetree.case,Ocaml.Ast.Parsetree.case)t|Type_declaration:(Js.Ast.Parsetree.type_declaration,Ocaml.Ast.Parsetree.type_declaration)t|Type_extension:(Js.Ast.Parsetree.type_extension,Ocaml.Ast.Parsetree.type_extension)t|Extension_constructor:(Js.Ast.Parsetree.extension_constructor,Ocaml.Ast.Parsetree.extension_constructor)t|Class_expr:(Js.Ast.Parsetree.class_expr,Ocaml.Ast.Parsetree.class_expr)t|Class_field:(Js.Ast.Parsetree.class_field,Ocaml.Ast.Parsetree.class_field)t|Class_type:(Js.Ast.Parsetree.class_type,Ocaml.Ast.Parsetree.class_type)t|Class_signature:(Js.Ast.Parsetree.class_signature,Ocaml.Ast.Parsetree.class_signature)t|Class_type_field:(Js.Ast.Parsetree.class_type_field,Ocaml.Ast.Parsetree.class_type_field)t|Module_expr:(Js.Ast.Parsetree.module_expr,Ocaml.Ast.Parsetree.module_expr)t|Module_type:(Js.Ast.Parsetree.module_type,Ocaml.Ast.Parsetree.module_type)t|Signature_item:(Js.Ast.Parsetree.signature_item,Ocaml.Ast.Parsetree.signature_item)t|Structure_item:(Js.Ast.Parsetree.structure_item,Ocaml.Ast.Parsetree.structure_item)t(*$*)|List:('a,'b)t->('alist,'blist)t|Pair:('a,'b)t*('c,'d)t->('a*'c,'b*'d)tendopenTypemoduleOf_ocaml=Versions.Convert(Ocaml)(Js)moduleTo_ocaml=Versions.Convert(Js)(Ocaml)letrecof_ocaml:typeocamljs.(js,ocaml)Type.t->ocaml->js=letopenOf_ocamlinfunnode->matchnodewith(*$ foreach_type (fun _ s ->
printf
" | %s -> copy_%s\n"
(capitalize_ascii s) s
)
*)|Structure->copy_structure|Signature->copy_signature|Toplevel_phrase->copy_toplevel_phrase|Core_type->copy_core_type|Expression->copy_expression|Pattern->copy_pattern|Case->copy_case|Type_declaration->copy_type_declaration|Type_extension->copy_type_extension|Extension_constructor->copy_extension_constructor|Class_expr->copy_class_expr|Class_field->copy_class_field|Class_type->copy_class_type|Class_signature->copy_class_signature|Class_type_field->copy_class_type_field|Module_expr->copy_module_expr|Module_type->copy_module_type|Signature_item->copy_signature_item|Structure_item->copy_structure_item(*$*)|Listt->List.map(of_ocamlt)|Pair(a,b)->letf=of_ocamlainletg=of_ocamlbinfun(x,y)->(fx,gy)letrecto_ocaml:typeocamljs.(js,ocaml)Type.t->js->ocaml=letopenTo_ocamlinfunnode->matchnodewith(*$ foreach_type (fun _ s ->
printf
" | %s -> copy_%s\n"
(capitalize_ascii s) s
)
*)|Structure->copy_structure|Signature->copy_signature|Toplevel_phrase->copy_toplevel_phrase|Core_type->copy_core_type|Expression->copy_expression|Pattern->copy_pattern|Case->copy_case|Type_declaration->copy_type_declaration|Type_extension->copy_type_extension|Extension_constructor->copy_extension_constructor|Class_expr->copy_class_expr|Class_field->copy_class_field|Class_type->copy_class_type|Class_signature->copy_class_signature|Class_type_field->copy_class_type_field|Module_expr->copy_module_expr|Module_type->copy_module_type|Signature_item->copy_signature_item|Structure_item->copy_structure_item(*$*)|Listt->List.map(to_ocamlt)|Pair(a,b)->letf=to_ocamlainletg=to_ocamlbinfun(x,y)->(fx,gy)letof_ocaml_mapperitemfctxtx=to_ocamlitemx|>fctxt|>of_ocamlitemletto_ocaml_mapperitemfctxtx=of_ocamlitemx|>fctxt|>to_ocamlitemendmoduleSelected_ast=Select_ast(Ocaml)moduleAst_helper=Ast_helper_lite(* Modules from Ast_<n> of Astlib, where <n> is the compiler version the ppxlib driver is compiled with *)moduleParsetree=Selected_ast.Ast.ParsetreemoduleAsttypes=Selected_ast.Ast.Asttypes(* Other Astlib modules *)moduleLocation=Astlib.LocationmoduleLongident=Astlib.LongidentmoduleParse=structincludeAstlib.ParsemoduleOf_ocaml=Versions.Convert(Ocaml)(Js)letimplementationlexbuf=implementationlexbuf|>Of_ocaml.copy_structureletinterfacelexbuf=interfacelexbuf|>Of_ocaml.copy_signaturelettoplevel_phraselexbuf=toplevel_phraselexbuf|>Of_ocaml.copy_toplevel_phraseletuse_filelexbuf=use_filelexbuf|>List.mapOf_ocaml.copy_toplevel_phraseletcore_typelexbuf=core_typelexbuf|>Of_ocaml.copy_core_typeletexpressionlexbuf=expressionlexbuf|>Of_ocaml.copy_expressionletpatternlexbuf=patternlexbuf|>Of_ocaml.copy_patternend